forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#63227 - jakubadamw:issue-63151, r=estebank
dead_code: Properly inspect fields in struct patterns with type relative paths Closes rust-lang#63151.
- Loading branch information
Showing
2 changed files
with
29 additions
and
2 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
26 changes: 26 additions & 0 deletions
26
src/test/ui/type-alias-enum-variants/issue-63151-dead-code-lint-fields-in-patterns.rs
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,26 @@ | ||
// check-pass | ||
|
||
// Regression test for the issue #63151: | ||
// Spurious unused field warning when matching variants under a `Self` scope | ||
// | ||
// This test checks that the `dead_code` lint properly inspects fields | ||
// in struct patterns that use a type relative path. | ||
|
||
#![deny(dead_code)] | ||
|
||
enum Enum { | ||
Variant { field: usize } | ||
} | ||
|
||
impl Enum { | ||
fn read_field(self) -> usize { | ||
match self { | ||
Self::Variant { field } => field | ||
} | ||
} | ||
} | ||
|
||
fn main() { | ||
let e = Enum::Variant { field: 42 }; | ||
println!("{}", e.read_field()); | ||
} |