Skip to content

Commit a9abf6f

Browse files
committed
Add test for match expression
1 parent 9e4ed33 commit a9abf6f

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/test/ui/suggestions/field-access.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@ fn main() {
1212
if let B::Fst = a {};
1313
//~^ ERROR mismatched types [E0308]
1414
// note: you might have meant to use field `b` of type `B`
15+
match a {
16+
B::Fst => (),
17+
B::Snd => (),
18+
}
19+
//~^^^ ERROR mismatched types [E0308]
20+
// note: you might have meant to use field `b` of type `B`
21+
//~^^^^ ERROR mismatched types [E0308]
22+
// note: you might have meant to use field `b` of type `B`
1523
}

src/test/ui/suggestions/field-access.stderr

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,39 @@ help: you might have meant to use field `b` of type `B`
1414
LL | if let B::Fst = a.b {};
1515
| ^^^
1616

17-
error: aborting due to previous error
17+
error[E0308]: mismatched types
18+
--> $DIR/field-access.rs:16:9
19+
|
20+
LL | Fst,
21+
| --- unit variant defined here
22+
...
23+
LL | match a {
24+
| - this expression has type `A`
25+
LL | B::Fst => (),
26+
| ^^^^^^ expected struct `A`, found enum `B`
27+
|
28+
help: you might have meant to use field `b` of type `B`
29+
|
30+
LL | match a.b {
31+
| ^^^
32+
33+
error[E0308]: mismatched types
34+
--> $DIR/field-access.rs:17:9
35+
|
36+
LL | Snd,
37+
| --- unit variant defined here
38+
...
39+
LL | match a {
40+
| - this expression has type `A`
41+
LL | B::Fst => (),
42+
LL | B::Snd => (),
43+
| ^^^^^^ expected struct `A`, found enum `B`
44+
|
45+
help: you might have meant to use field `b` of type `B`
46+
|
47+
LL | match a.b {
48+
| ^^^
49+
50+
error: aborting due to 3 previous errors
1851

1952
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)