No way to massively remove unused imports
See original GitHub issueEnvironment
- IntelliJ Rust plugin version: 0.4.171.4656-213
- Rust toolchain version: 1.63.0-nightly (420c970cb 2022-06-09) x86_64-pc-windows-msvc
- IDE name and version: CLion 2021.3.4 (CL-213.7172.20)
- Operating system: Windows 10 10.0
- Macro expansion engine: new
- Name resolution engine: new
- Additional experimental features: org.rust.macros.proc
Problem description
At the active development phase that’s very frustration to have a lot of “unused import” warnings. And as I see, It’s IDE level inspection works fairly well. Why do not allow user to remove them all by one hotkey? For example by “Optimize imports”.
Or this feature:
It explicitly should do what I need, but it does nothing (I mean option to fix all in file).
Ok, I’ve googled a lot of discussions that “unused imports” inspection is unreliable because has false-positives, but why do not allow this as an experimental feature? I’m ok to fix rare false-positives manually.
So I’m creating new issue as suggested here
org.rust.macros.proc
toggle doesn’t make any difference.
Steps to reproduce
- Create fresh binary executable project with following code
use std::borrow::Borrow;
use std::ops::Div;
fn main() {
println!("Hello, world!");
}
- Optimize imports with
Ctrl+Alt+O
(unused imports left) - Try to remove them with the
Alt+Enter/External linter: remove whole item
- it works (for a single item) - Try to apply fix to whole file with
Alt+Enter/External linter: remove whole item/Fix all 'Annotator' problems in file
- it does nothing
(Language & Frameworks/Rust/External Linters/External Linter
is default - “Cargo Check”)
Issue Analytics
- State:
- Created a year ago
- Reactions:6
- Comments:9 (3 by maintainers)
@kkolyan this is very strange. Which version of the plugin are you using? Could you please attach your
idea.log
? Could you also try to disable “Enable inspection only if procedural macros are enabled” option in intention settings?By the way it is reported by
cargo clippy
external linter, not by our builtin annotator. Import will be fully grayed out when reported by our annotator:After enabling the experimental features and disabling “Enable inspection only if procedural macros are enabled”, all works, but only in some cases.
For some reason, this doesn’t work:
But this does: