Skip to content

Commit

Permalink
Add regression test for #8528
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jan 4, 2025
1 parent d911b58 commit fbc1f00
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
12 changes: 12 additions & 0 deletions tests/ui/map_flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ fn long_span() {
.collect();
}

#[allow(clippy::useless_vec)]
fn no_suggestion_if_comments_present() {
let vec = vec![vec![1, 2, 3]];
let _ = vec
.iter()
// a lovely comment explaining the code in very detail
.map(|x| x.iter())
//~^ ERROR: called `map(..).flatten()` on `Iterator`
// the answer to life, the universe and everything could be here
.flatten();
}

fn main() {
long_span();
}
11 changes: 10 additions & 1 deletion tests/ui/map_flatten.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,14 @@ LL + }
LL + })
|

error: aborting due to 4 previous errors
error: called `map(..).flatten()` on `Iterator`
--> tests/ui/map_flatten.rs:64:10
|
LL | .map(|x| x.iter())
| __________^
... |
LL | | .flatten();
| |__________________^ help: try replacing `map` with `flat_map` and remove the `.flatten()`: `flat_map(|x| x.iter())`

error: aborting due to 5 previous errors

0 comments on commit fbc1f00

Please sign in to comment.