-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
let-else: add test for linting unused variables in the first place
+ remove actual unused vars from some other tests to be less distracting
- Loading branch information
1 parent
07539b8
commit d549ede
Showing
5 changed files
with
24 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
// check-pass | ||
// issue #89807 | ||
|
||
#![feature(let_else)] | ||
|
||
#[deny(unused_variables)] | ||
|
||
fn main() { | ||
let value = Some(String::new()); | ||
let value = Some(5); | ||
#[allow(unused)] | ||
let banana = 1; | ||
#[allow(unused)] | ||
let Some(chaenomeles) = value else { return }; // OK | ||
let Some(unused) = value else { return }; | ||
//~^ ERROR unused variable: `unused` | ||
} |
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: `unused` | ||
--> $DIR/let-else-allow-unused.rs:13:14 | ||
| | ||
LL | let Some(unused) = value else { return }; | ||
| ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused` | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/let-else-allow-unused.rs:5:8 | ||
| | ||
LL | #[deny(unused_variables)] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
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
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