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

Formatting removes comments within braces of imports #5319

Closed
clarfonthey opened this issue Apr 24, 2022 · 2 comments
Closed

Formatting removes comments within braces of imports #5319

clarfonthey opened this issue Apr 24, 2022 · 2 comments

Comments

@clarfonthey
Copy link

clarfonthey commented Apr 24, 2022

Minimal example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=942d0b7867cbdf3c09ff7d639a41719c

pub use std::collections::{
    // HashMap,
    HashSet,
};

Rustfmt will turn this into:

pub use std::collections::HashSet;

And completely discard the commented-out HashMap. Similarly, this will also remove all comments within the braces for imports, regardless of whether they include valid imports.

@ytmimi
Copy link
Contributor

ytmimi commented Apr 24, 2022

Thanks for the report!

This is actually a duplicate of #4708 and #3984. This issue was fixed in another branch and we're waiting for #5290 to be merged so we can backport that fix. I've gone ahead and tested your code snippet on the #5290 branch and the comments are left in place 😄

Since this is a duplicate I'm going to go ahead and close the issue. Thanks again for taking the time to bring this to our attention!

@ytmimi ytmimi closed this as completed Apr 24, 2022
@clarfonthey
Copy link
Author

Looks like I didn't search hard enough. ><

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants