rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
13.62k stars 1.49k forks source link

quick fix only applies one half of the proposed fix from clippy, wont compile anymore after doing the quick fix #17163

Closed antonilol closed 1 week ago

antonilol commented 2 weeks ago

rust-analyzer version: rust-analyzer version: 0.4.1939-standalone

rustc version: rustc 1.77.0 (aedd173a2 2024-03-17)

editor or extension: code OSS (open core of vscode)

relevant settings: i use cargo clippy instead of cargo check, to get clippy suggestions in the editor, this is relevant for reproducing this

code snippet to reproduce:

fn main() {
    let a;
    let b = 0;
    a = b;
    let _ = a;
}

apply one of the the two parts from the suggested quick fix

this is not a clippy bug, auto-fixing it with clippy will apply both parts

roife commented 1 week ago

~Possibly related to rust-lang/rust#53934. Currently, the JSON from the compiler (as well as Clippy) is unable to differentiate between 'single diagnostics containing multi-spans' and 'multiple mutually exclusive diagnostics'. Consequently, r-a is also unable to distinguish them.~

~Perhaps we should wait for the upstream to fix it first.~

roife commented 1 week ago

Oops, after reviewing the implementation of needless_late_init in Clippy, I noticed that multiple fixes weren't combined together. Thus, it appears to be an issue with Clippy's implementation rather than with the JSON output. Perhaps we should consider fix it in Clippy.

roife commented 1 week ago

I believe https://github.com/rust-lang/rust-clippy/pull/12777 has fixed it.