forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#119402 - est31:fix_if_guard_unused, r=compiler-errors Also walk bindings created by if-let guards This change makes the `unused_variables` lint pick up unused bindings created by if-let guards. Fixes rust-lang#119383
- Loading branch information
Showing
3 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![feature(if_let_guard)] | ||
#![deny(unused_variables)] | ||
|
||
fn main() { | ||
match () { | ||
() if let Some(b) = Some(()) => {} //~ ERROR unused variable: `b` | ||
_ => {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error: unused variable: `b` | ||
--> $DIR/issue-119383.rs:6:24 | ||
| | ||
LL | () if let Some(b) = Some(()) => {} | ||
| ^ help: if this is intentional, prefix it with an underscore: `_b` | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/issue-119383.rs:2:9 | ||
| | ||
LL | #![deny(unused_variables)] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|