Overly verbose suggestion display for trailing whitespace changes
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
When a suggestion removes a line the diff suggests removing and re-adding the previous line. We do these kinds of suggestions a fair bit in clippy to make --fix actually remove the line.
e.g. in needless_return the code:
fn main() {
if true {
println!("foo");
return;
} else {
println!("bar");
}
}
Gives the suggestion:
--> src/main.rs:3:25
|
3 | println!("foo");
| _________________________^
4 | | return;
| |______________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
= note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
|
3 - println!("foo");
4 - return;
3 + println!("foo");
|
This suggests to remove and re-add println!("foo"); rather than just remove the return line. The lint span spanning multiple lines is entirely on clippy, but the suggestion display can't be fixed by us.
cc rust-lang/rust-clippy#14750
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 needless_return example and inspect the compiler's suggestion-display path, using the linked rust-clippy#14750 context to understand the multi-line span. Done means the displayed suggestion removes only return instead of removing and re-adding the unchanged println!("foo"); line.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100