Skip to content

Commit 78225cc

Browse files
Add regression test for #8528
1 parent 891e387 commit 78225cc

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

tests/ui/map_flatten.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ fn long_span() {
5555
.collect();
5656
}
5757

58+
#[allow(clippy::useless_vec)]
59+
fn no_suggestion_if_comments_present() {
60+
let vec = vec![vec![1, 2, 3]];
61+
let _ = vec
62+
.iter()
63+
// a lovely comment explaining the code in very detail
64+
.map(|x| x.iter())
65+
//~^ ERROR: called `map(..).flatten()` on `Iterator`
66+
// the answer to life, the universe and everything could be here
67+
.flatten();
68+
}
69+
5870
fn main() {
5971
long_span();
6072
}

tests/ui/map_flatten.stderr

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,14 @@ LL + }
102102
LL + })
103103
|
104104

105-
error: aborting due to 4 previous errors
105+
error: called `map(..).flatten()` on `Iterator`
106+
--> tests/ui/map_flatten.rs:64:10
107+
|
108+
LL | .map(|x| x.iter())
109+
| __________^
110+
... |
111+
LL | | .flatten();
112+
| |__________________^ help: try replacing `map` with `flat_map` and remove the `.flatten()`: `flat_map(|x| x.iter())`
113+
114+
error: aborting due to 5 previous errors
106115

0 commit comments

Comments
 (0)