diff options
| author | Fridtjof Stoldt <xFrednet@gmail.com> | 2025-01-07 09:09:19 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-07 09:09:19 +0000 |
| commit | d0d5b8a34a133c7ae47f9a38e63d6c26bd999095 (patch) | |
| tree | f411fbf27c8d0211ea0080c8e3eeed670e003ee8 /tests | |
| parent | 98b9a263bc91b16eedfa2616089cbd172cebb919 (diff) | |
| parent | 78225ccca8980e357123ac936655a40e0b0c8b8f (diff) | |
Don't emit machine applicable `map_flatten` lint if there are code comments (#13940)
Fixes https://github.com/rust-lang/rust-clippy/issues/8528. Similar to #13911, if there are code comments, we don't want to remove them automatically. changelog: Don't emit machine applicable `map_flatten` lint if there are code comments r? @xFrednet
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/map_flatten.rs | 12 | ||||
| -rw-r--r-- | tests/ui/map_flatten.stderr | 11 |
2 files changed, 22 insertions, 1 deletions
diff --git a/tests/ui/map_flatten.rs b/tests/ui/map_flatten.rs index 76916d46591..eafc8b6e81c 100644 --- a/tests/ui/map_flatten.rs +++ b/tests/ui/map_flatten.rs @@ -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(); } diff --git a/tests/ui/map_flatten.stderr b/tests/ui/map_flatten.stderr index a5837b97617..34bd174d7dd 100644 --- a/tests/ui/map_flatten.stderr +++ b/tests/ui/map_flatten.stderr @@ -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 |
