Skip to content

Commit

Permalink
modify test
Browse files Browse the repository at this point in the history
  • Loading branch information
tamaroning committed Feb 8, 2022
1 parent 09a0e32 commit d33763b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tests/ui/map_then_identity_transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fn main() {
let _ = a.into_iter().map(|x| foo(x)).filter_map(|y| Some(!y));
let _ = a.into_iter().map(|x| x + 30).fold(1, |pd, x| pd * x + 1);
let _ = a.into_iter().map(|x| foo(x)).map(|y| bar(y));
let _ = a.into_iter().map(|x| foo(x)).position(|y| bar(y));

// should not lint
let _ = a.into_iter().map(|x| x > 1).all(|y| foo(0));
Expand All @@ -25,6 +26,7 @@ fn main() {
let _ = a.into_iter().map(|x| foo(x)).filter_map(|y| Some(true));
let _ = a.into_iter().map(|x| x + 30).fold(1, |pd, x| pd * x * x);
let _ = a.into_iter().map(|x| foo(x)).map(|y| bar(y) && y);
let _ = a.into_iter().map(|x| foo(x)).map(|y| true);
}

fn foo(a: i32) -> bool {
Expand Down
16 changes: 15 additions & 1 deletion tests/ui/map_then_identity_transformer.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,19 @@ LL | let _ = a.into_iter().map(|x| foo(x)).map(|y| bar(y));
| |
| with this expression

error: aborting due to 7 previous errors
error: this `map` can be collapsed into the `position`
--> $DIR/map_then_identity_transformer.rs:18:27
|
LL | let _ = a.into_iter().map(|x| foo(x)).position(|y| bar(y));
| ^^^
|
help: these `map` and `position` can be merged into a single `position`
--> $DIR/map_then_identity_transformer.rs:18:35
|
LL | let _ = a.into_iter().map(|x| foo(x)).position(|y| bar(y));
| ^^^^^^ ^ replace this variable
| |
| with this expression

error: aborting due to 8 previous errors

0 comments on commit d33763b

Please sign in to comment.