Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
antonilol opened this issue Apr 30, 2024 · 8 comments
Labels
A-diagnostics diagnostics / error reporting C-bug Category: bug

Comments

@antonilol
Copy link

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

@antonilol antonilol added the C-bug Category: bug label Apr 30, 2024
@lnicola lnicola added the A-diagnostics diagnostics / error reporting label Apr 30, 2024
@roife
Copy link
Member

roife commented May 7, 2024

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
Copy link
Member

roife commented May 7, 2024

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.

bors added a commit to rust-lang/rust-clippy that referenced this issue May 8, 2024
fix: merge multiple suggestions into a single multi-span suggestion in `needless_late_init`

See rust-lang/rust-analyzer#17163 (comment).

Currently, the fix for `needless_late_init` would modify multiple parts in the file. However, these modifications are exported as separate suggestions instead of a unified 'multi-part suggestion'.

Consequently, rust-analyzer is unable to perform the fix correctly when applying suggestions automatically, as only one suggestion is processed at a time. This PR addresses this issue by merge all modifications into a single multi-part suggestion.

changelog: [`needless_late_init`]: merge multiple fixes into a single multi-span fix.
@roife
Copy link
Member

roife commented May 8, 2024

I believe rust-lang/rust-clippy#12777 has fixed it.

@Veykril Veykril closed this as completed May 9, 2024
@antonilol
Copy link
Author

i can't confirm this has been fixed, but there could be an error in my setup

$ cargo clippy --version
clippy 0.1.80 (791adf7 2024-05-21)

my default is stable, but i have a rust-toolchain.toml that sets it to nightly

the quick fix menu also only shows one of the two parts:
image

@roife
Copy link
Member

roife commented May 22, 2024

the quick fix menu also only shows one of the two parts:

The PR has been merged into Clippy, but it hasn't been merged upstream yet.

@antonilol
Copy link
Author

The PR has been merged into Clippy, but it hasn't been merged upstream yet.

oh ok, is there a use to clippy nightly releases then?

@Veykril
Copy link
Member

Veykril commented May 22, 2024

The clippy component in the rustup toolchain is whatever was synced back into rust-lang/rust last. They don't do it every day.

@antonilol
Copy link
Author

oh right i see, thanks for clarifying, i found this merge there, which includes the pr that closed this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics diagnostics / error reporting C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

4 participants