Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
matthiaskrgr opened this issue Mar 12, 2022 · 1 comment
Open
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Mar 12, 2022

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

@matthiaskrgr matthiaskrgr added the C-bug Category: Clippy is not doing the correct thing label Mar 12, 2022
@J-ZhengLi J-ZhengLi removed their assignment Mar 16, 2022
@J-ZhengLi
Copy link
Member

J-ZhengLi commented Mar 16, 2022

Hi~ Sorry I keep mentioning this issue and deleting it cuz I was very sleepy and couldn't make up my mind🤦, you might wondering why there were many notifications or something...

Anyway, I just wanna mention that after PR #8520 , the comment above .map() should not be removed, but the one between it and .flatten() will still be removed. I can try find a way to keep it, but will that still make sense after the code below it is technically gone? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

No branches or pull requests

2 participants