Skip to content

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

Closed
@benwh1

Description

@benwh1

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions