Rollup merge of #63227 - jakubadamw:issue-63151, r=estebank

dead_code: Properly inspect fields in struct patterns with type relative paths

Closes #63151.
This commit is contained in:
Mazdak Farrokhzad 2019-08-03 13:12:02 +02:00 committed by GitHub
commit 2fd9548039
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 2 deletions

View file

@ -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());
}