]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/field-access.rs
Rollup merge of #107632 - ameknite:issue-107622-fix, r=jyn514
[rust.git] / tests / ui / suggestions / field-access.rs
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 {}; //~ ERROR mismatched types [E0308]
21     //~^ HELP you might have meant to use field `b` whose type is `B`
22     match a {
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 foo {
31         //~^ HELP you might have meant to use field `bar` whose type is `u32`
32         1u32 => (), //~ ERROR mismatched types [E0308]
33         _ => (),
34     }
35 }