summaryrefslogtreecommitdiffstats
path: root/src/test/ui/type-alias-enum-variants/issue-63151-dead-code-lint-fields-in-patterns.rs
blob: 66fb8dd0deaf425239ae33c23b00898586ac883e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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());
}