rust-lang / rust-lang/rust-analyzer
Quick fix... has weird behavior for fixing individual clippy issues
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
rust-analyzer version: v0.3.1410
rustc version: rustc 1.67.1 (d5a82bbd2 2023-02-07)
I'm using the "Quick Fix..." option on individual clippy warnings. Some of it works fine, some of it are not doing anything, some of it works weirdly and produces code that does not compile.
Weird results:
non_upper_case_globals
Chosing "rename to PI" - works as expected.
Chosing "convert the identifier to upper case: PI" - creates non-compiling code as the usages of the identifier are not changed to upper case.
unneeded return
Chosing "remove return: 5" - results in compile error:
fn bar() -> i32 {
...
5;
}
This is a compile error as 5 is not returned because of the semicolon.
Chosing "remove this semicolon" - results in this:
fn bar() -> i32 {
// other code removed from here ...
return 5
}
this compiles but is still a warning. At least applying remove return on it will result in correct code.
used assert_eq! with a literal bool
#[test]
fn test_counting() {
assert_eq!(getResult() == 5, true);
}
Choosing "replace it with: assert!(..)" - results in non compiling code:
#[test]
fn test_counting() {
assert!(..);
}
Note that the .. is not a placeholder but it got added to the code literally.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the individual Clippy Quick Fix actions described for non_upper_case_globals, unneeded return, and assert_eq! with a literal bool using the reported rust-analyzer and rustc versions. Compare the generated code with the examples and verify that each selected fix compiles and removes the warning without literal placeholders or unchanged usages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100