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

Improve redundant_locals help message #11628

Merged
merged 1 commit into from Oct 6, 2023
Merged

Conversation

koka831
Copy link
Contributor

@koka831 koka831 commented Oct 6, 2023

Fixes #11625

AFAIK, span_lint_and_help points the beginning of spans when we pass multiple spans to the second argument, so This PR I also modified its help span and its message.

lint result of the given example in the issue will be:

error: redundant redefinition of a binding `apple`
 --> src/main.rs:5:5
  |
5 |     let apple = apple;
  |     ^^^^^^^^^^^^^^^^^^
  |
help: `apple` is initially defined here
 --> src/main.rs:4:9
  |
4 |     let apple = 42;
  |         ^^^^^
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_locals

I hope that this change might help reduce user confusion, but I'd appreciate alternative suggestions:)

changelog: [redundant_locals]: Now points at the rebinding of the variable

@rustbot
Copy link
Collaborator

rustbot commented Oct 6, 2023

r? @Jarcho

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Oct 6, 2023
@blyxyas
Copy link
Member

blyxyas commented Oct 6, 2023

You can use "Fixes #[issue number]" instead of "Addresses [URL]" to automatically close the original issue. (Documentation)

Copy link
Member

@blyxyas blyxyas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smart implementation, thanks for addressing this issue ❤️!

@blyxyas
Copy link
Member

blyxyas commented Oct 6, 2023

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 6, 2023

📌 Commit 48d2770 has been approved by blyxyas

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Oct 6, 2023

⌛ Testing commit 48d2770 with merge 7217c0f...

@bors
Copy link
Collaborator

bors commented Oct 6, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: blyxyas
Pushing 7217c0f to master...

@bors bors merged commit 7217c0f into rust-lang:master Oct 6, 2023
5 checks passed
@koka831 koka831 deleted the fix/11625 branch October 6, 2023 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Primary span for clippy::redundant-locals points at the initial def, not the rebinding
5 participants