Skip to content

map_flatten removes comments between iterator methods with --fix 😞  #8528

@matthiaskrgr

Description

@matthiaskrgr

Summary

.

Reproducer

I tried this code:

    vec.iter()
        // a lovely comment explaining the code in very detail
        .map(|x| x.iter())
        // the answer to life, the universe and everything could be here
        .flatten();

This is especially annoying when running --fix, clippy will just transform this
vec.iter().flat_map(|x| x.iter());
and eat all the comments.

Version

rustc 1.61.0-nightly (335ffbfa5 2022-03-11)
binary: rustc
commit-hash: 335ffbfa547df94ac236f5c56130cecf99c8d82b
commit-date: 2022-03-11
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions