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

Comments in imports are formatted incorrectly #5852

Closed
rsammelson opened this issue Jul 21, 2023 · 1 comment · Fixed by #5853
Closed

Comments in imports are formatted incorrectly #5852

rsammelson opened this issue Jul 21, 2023 · 1 comment · Fixed by #5853
Labels
a-comments a-imports `use` syntax bug Panic, non-idempotency, invalid code, etc.

Comments

@rsammelson
Copy link
Contributor

Examples:

use std::{
    fs,
    // (temporarily commented, we'll need this again in a second) io,
};

use foo::{
    self // this is important
};

Becomes:

use std::fs;

use foo::{self, // this is important};

Which now has syntax errors.

@okaneco
Copy link

okaneco commented Aug 7, 2023

I ran into this issue and a similar issue that resulted in unexpected and unwanted behavior.

Formatting deletes the import if all of the items are commented out.

Before

use std::fs::{
    // File
};

After

Expected

use std::fs::{
    // File
};

rsammelson added a commit to rsammelson/rustfmt that referenced this issue Aug 30, 2023
rsammelson added a commit to rsammelson/rustfmt that referenced this issue Aug 31, 2023
ytmimi pushed a commit that referenced this issue Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-comments a-imports `use` syntax bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants