]> git.lizzy.rs Git - rust.git/blob - src/test/ui/pattern/usefulness/issue-57472.rs
Rollup merge of #79293 - Havvy:test-eval-order-compound-assign, r=Mark-Simulacrum
[rust.git] / src / test / ui / pattern / usefulness / issue-57472.rs
1 #![crate_type="lib"]
2 #![deny(unreachable_patterns)]
3
4 mod test_struct {
5     // Test the exact copy of the minimal example
6     // posted in the issue.
7     pub struct Punned {
8         foo: [u8; 1],
9         bar: [u8; 1],
10     }
11
12     pub fn test(punned: Punned) {
13         match punned {
14             Punned { foo: [_], .. } => println!("foo"),
15             Punned { bar: [_], .. } => println!("bar"),
16             //~^ ERROR unreachable pattern [unreachable_patterns]
17         }
18     }
19 }
20
21 mod test_union {
22     // Test the same thing using a union.
23     pub union Punned {
24         foo: [u8; 1],
25         bar: [u8; 1],
26     }
27
28     pub fn test(punned: Punned) {
29         match punned {
30             Punned { foo: [_] } => println!("foo"),
31             Punned { bar: [_] } => println!("bar"),
32             //~^ ERROR unreachable pattern [unreachable_patterns]
33         }
34     }
35 }