rust-analyzer
rust-analyzer copied to clipboard
Single action applies multiple contradictory suggestions
rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)
> rust-analyzer --version
rust-analyzer 2024.02.12
rustc version: (eg. output of rustc -V)
> rustc -V
rustc 1.76.0 (07dca489a 2024-02-04) (Alpine Linux 1.76.0-r1)
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)
> env | grep CARGO_ && env | grep RUST
CARGO_HOME=/home/hugo/.local/state/cargo
RUSTUP_HOME=/home/hugo/.local/state/rustup
repository link (if public, optional): (eg. rust-analyzer)
https://git.sr.ht/~whynothugo/vdirsyncer-rs/tree/a7d2a80ae42b6f141ab60ea68c9e43120a24e84b/item/vdirsyncer/src/config.rs#L603
(you'd need to delete the import in line 8 for this issue to trigger)
code snippet to reproduce:
fn open_default_path() -> File {
todo!()
}
Note: you'll need to install another crate that provides a File type. Like tokio with the fs feature.
issue description
If a type is being used without being imported, rust-analyzer suggests importing one of the available implementations. A code action is exposed:
consider importing one of these items: use std::fs::File;\n, use tokio::fs::File;\n
By executing that code action, rust-analyzer imports both conflicting types.
possible solution
rust-analyzer should report a separate code action for each potential import.