rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Feature Request: `unused-import` assist should remove unnecessary braces if only one import remains in the group after running

Open sadderchris opened this issue 3 years ago • 1 comments

Let's say I have a situation like this:

use foo::bar::{baz, quxx};
               ^~~ unused import

If I use the "remove unused import" assist, I end up with

use foo::bar::{quux};
              ^~~~~^ remove unnecessary braces

So I have to trigger another assist immediately after removing the unused import, which is kinda silly.

It would be great if the unused import assist was smart enough to remove unnecessary braces here.

sadderchris avatar Sep 23 '22 23:09 sadderchris

I can't check right now, but the first suggestion and fix are probably coming from rustc, not RA.

And you don't need to invoke the second one. If you have fornat on save enabled, rustfmt with remove the extra braces.

lnicola avatar Sep 24 '22 03:09 lnicola