-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Description
Let's say I wrote this critical piece of code:
fn main() {
let mut i = 42;
}
rustc gives me the following output:
warning: unused variable: `i`
--> src/main.rs:2:9
|
2 | let mut i = 42;
| ^^^^^ help: consider using `_i` instead
|
= note: #[warn(unused_variables)] on by default
warning: variable does not need to be mutable
--> src/main.rs:2:9
|
2 | let mut i = 42;
| ----^
| |
| help: remove this `mut`
|
= note: #[warn(unused_mut)] on by default
Which is correct -- except for one little detail. Which is crucial, if you are not just any developer but actually rustfix.
You see, the mut
in mut i
is highlighted, but the replacement is just for the binding name, not the mutability. (Why not the mutability? Because the mutability is covered by the next lint we trigger, unused_mut
.) And rustfix will rightfully complain if we try to replace parts of the code that we have already replaced.
tl;dr We need to change the span in unused_variables
to only cover the i
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.