From bde54292f80c858ff4e0f8a12f1333702ff2126b Mon Sep 17 00:00:00 2001 From: Andre Bogus Date: Mon, 10 Jun 2019 11:42:15 +0200 Subject: [PATCH] only run eta_reduction on calls w/ ExprPath callee This fixes #4187 --- tests/ui/eta.fixed | 4 ++-- tests/ui/eta.stderr | 14 +------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/tests/ui/eta.fixed b/tests/ui/eta.fixed index 1ad836d25ff6..a3212f9addc7 100644 --- a/tests/ui/eta.fixed +++ b/tests/ui/eta.fixed @@ -20,7 +20,7 @@ use std::path::PathBuf; fn main() { let a = Some(1u8).map(foo); meta(foo); - let c = Some(1u8).map({1+2; foo}); + let c = Some(1u8).map(|a| {1+2; foo}(a)); let d = Some(1u8).map(|a| foo((|b| foo2(b))(a))); //is adjusted? all(&[1, 2, 3], &2, |x, y| below(x, y)); //is adjusted unsafe { @@ -105,7 +105,7 @@ fn test_redundant_closures_containing_method_calls() { let mut some = Some(|x| x * x); let arr = [Ok(1), Err(2)]; - let _: Vec<_> = arr.iter().map(|x| x.map_err(some.take().unwrap())).collect(); + let _: Vec<_> = arr.iter().map(|x| x.map_err(|e| some.take().unwrap()(e))).collect(); } struct Thunk(Box T>); diff --git a/tests/ui/eta.stderr b/tests/ui/eta.stderr index ff402a1850ed..d19d21eec0db 100644 --- a/tests/ui/eta.stderr +++ b/tests/ui/eta.stderr @@ -12,12 +12,6 @@ error: redundant closure found LL | meta(|a| foo(a)); | ^^^^^^^^^^ help: remove closure as shown: `foo` -error: redundant closure found - --> $DIR/eta.rs:23:27 - | -LL | let c = Some(1u8).map(|a| {1+2; foo}(a)); - | ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `{1+2; foo}` - error: this expression borrows a reference that is immediately dereferenced by the compiler --> $DIR/eta.rs:25:21 | @@ -70,12 +64,6 @@ error: redundant closure found LL | let e: std::vec::Vec = vec!['a', 'b', 'c'].iter().map(|c| c.to_ascii_uppercase()).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `char::to_ascii_uppercase` -error: redundant closure found - --> $DIR/eta.rs:108:50 - | -LL | let _: Vec<_> = arr.iter().map(|x| x.map_err(|e| some.take().unwrap()(e))).collect(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `some.take().unwrap()` - error: redundant closure found --> $DIR/eta.rs:173:27 | @@ -88,5 +76,5 @@ error: redundant closure found LL | let a = Some(1u8).map(|a| closure(a)); | ^^^^^^^^^^^^^^ help: remove closure as shown: `closure` -error: aborting due to 14 previous errors +error: aborting due to 12 previous errors