Skip to content

Overly verbose suggestion display for trailing whitespace changes #140750

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

Open
Jarcho opened this issue May 7, 2025 · 0 comments
Open

Overly verbose suggestion display for trailing whitespace changes #140750

Jarcho opened this issue May 7, 2025 · 0 comments
Labels
C-bug Category: This is a bug. D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged.

Comments

@Jarcho
Copy link
Contributor

Jarcho commented May 7, 2025

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

@Jarcho Jarcho added C-bug Category: This is a bug. D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. labels May 7, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged.
Projects
None yet
Development

No branches or pull requests

2 participants