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

Invalid code generated when using "Remove all the unused imports" #16181

Closed
benwh1 opened this issue Dec 22, 2023 · 2 comments · Fixed by #16185
Closed

Invalid code generated when using "Remove all the unused imports" #16181

benwh1 opened this issue Dec 22, 2023 · 2 comments · Fixed by #16185
Assignees
Labels
A-assists C-bug Category: bug

Comments

@benwh1
Copy link

benwh1 commented Dec 22, 2023

rust-analyzer version: 0.4.1778

rustc version: rustc 1.76.0-nightly (3f28fe133 2023-12-18)

Using "Remove all the unused imports" on this code:

mod m {
    pub mod x {
        pub struct A;
        pub struct B;
    }
    pub mod y {
        pub struct C;
    }
}

use m::{
    x::{A, B},
    y::C,
};

fn main() {
    B;
}

turns the import into

use m::
    x::B,
;

I think there must have been some recent change where braces around single imports are now automatically removed because I don't remember this happening before, and it isn't broken on the stable release.

@benwh1 benwh1 added the C-bug Category: bug label Dec 22, 2023
@lnicola
Copy link
Member

lnicola commented Dec 22, 2023

This must be #16066, CC @Young-Flash

@Young-Flash
Copy link
Member

we should take care about the tailing ,

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assists C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants