]> git.lizzy.rs Git - rust.git/blob - tests/ui/type-alias-enum-variants/issue-63151-dead-code-lint-fields-in-patterns.rs
Rollup merge of #107306 - compiler-errors:correct-sugg-for-closure-arg-needs-borrow...
[rust.git] / tests / ui / type-alias-enum-variants / issue-63151-dead-code-lint-fields-in-patterns.rs
1 // check-pass
2
3 // Regression test for the issue #63151:
4 // Spurious unused field warning when matching variants under a `Self` scope
5 //
6 // This test checks that the `dead_code` lint properly inspects fields
7 // in struct patterns that use a type relative path.
8
9 #![deny(dead_code)]
10
11 enum Enum {
12     Variant { field: usize }
13 }
14
15 impl Enum {
16     fn read_field(self) -> usize {
17         match self {
18             Self::Variant { field } => field
19         }
20     }
21 }
22
23 fn main() {
24     let e = Enum::Variant { field: 42 };
25     println!("{}", e.read_field());
26 }