forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#82506 - estebank:unused_variable_lint, r=lcnr
Properly account for non-shorthand pattern field in unused variable lint Fix rust-lang#82488
- Loading branch information
Showing
4 changed files
with
56 additions
and
5 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,16 @@ | ||
// run-rustfix | ||
#![deny(unused_variables)] | ||
|
||
struct Point { | ||
x: u32, | ||
y: u32 | ||
} | ||
|
||
fn process_point(Point { x, y: _renamed }: Point) { | ||
//~^ ERROR unused variable: `renamed` | ||
let _ = x; | ||
} | ||
|
||
fn main() { | ||
process_point(Point { x: 0, y: 0 }); | ||
} |
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,16 @@ | ||
// run-rustfix | ||
#![deny(unused_variables)] | ||
|
||
struct Point { | ||
x: u32, | ||
y: u32 | ||
} | ||
|
||
fn process_point(Point { x, y: renamed }: Point) { | ||
//~^ ERROR unused variable: `renamed` | ||
let _ = x; | ||
} | ||
|
||
fn main() { | ||
process_point(Point { x: 0, y: 0 }); | ||
} |
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: `renamed` | ||
--> $DIR/unused_variables-issue-82488.rs:9:32 | ||
| | ||
LL | fn process_point(Point { x, y: renamed }: Point) { | ||
| ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_renamed` | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/unused_variables-issue-82488.rs:2:9 | ||
| | ||
LL | #![deny(unused_variables)] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|