Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only run eta_reduction on calls w/ ExprPath callee #4189

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/ui/eta.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<T>(Box<dyn FnMut() -> T>);
Expand Down
14 changes: 1 addition & 13 deletions tests/ui/eta.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
|
Expand Down Expand Up @@ -70,12 +64,6 @@ error: redundant closure found
LL | let e: std::vec::Vec<char> = 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
|
Expand All @@ -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