-
Notifications
You must be signed in to change notification settings - Fork 14k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Given the following code:
fn foo(x: u32) -> u32 {
let a = 100;
let b = 200;
let c = 300;
match x {
c => 3,
b => 2,
a => 1,
_ => 0
}
}we currently emit:
warning: unreachable pattern
--> <source>:8:7
|
7 | c => 3,
| - matches any value
8 | b => 2,
| ^ unreachable pattern
|
= note: `#[warn(unreachable_patterns)]` on by defaultHowever, in this case, the developer was likely confused and thought they were matching on the value of c, not creating a binding of with name c. We should emit something more similar to:
warning: match arm binding shadows local binding
--> <source>:8:7
|
7 | c => 3,
| ^
= note: shadows local binding `c` declared at <source>:4:7
= note: `#[warn(arm_binding_shadows_local)]` on by defaultTiraelSedai, Programistich, EightM and VCasecnikovs
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.