]> git.proxmox.com Git - rustc.git/blob - src/test/ui/suggestions/field-access.fixed
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / suggestions / field-access.fixed
1 // run-rustfix
2 #![allow(dead_code)]
3
4 struct A {
5 b: B,
6 }
7
8 enum B {
9 Fst,
10 Snd,
11 }
12
13 union Foo {
14 bar: u32,
15 qux: f32,
16 }
17
18 fn main() {
19 let a = A { b: B::Fst };
20 if let B::Fst = a.b {}; //~ ERROR mismatched types [E0308]
21 //~^ HELP you might have meant to use field `b` whose type is `B`
22 match a.b {
23 //~^ HELP you might have meant to use field `b` whose type is `B`
24 //~| HELP you might have meant to use field `b` whose type is `B`
25 B::Fst => (), //~ ERROR mismatched types [E0308]
26 B::Snd => (), //~ ERROR mismatched types [E0308]
27 }
28
29 let foo = Foo { bar: 42 };
30 match unsafe { foo.bar } {
31 //~^ HELP you might have meant to use field `bar` whose type is `u32`
32 1u32 => (), //~ ERROR mismatched types [E0308]
33 _ => (),
34 }
35 }