Add test for match expression

This commit is contained in:
Hirochika Matsumoto 2021-01-29 16:28:53 +09:00
parent 9e4ed337c7
commit a9abf6f086
2 changed files with 42 additions and 1 deletions

View File

@ -12,4 +12,12 @@ fn main() {
if let B::Fst = a {};
//~^ ERROR mismatched types [E0308]
// note: you might have meant to use field `b` of type `B`
match a {
B::Fst => (),
B::Snd => (),
}
//~^^^ ERROR mismatched types [E0308]
// note: you might have meant to use field `b` of type `B`
//~^^^^ ERROR mismatched types [E0308]
// note: you might have meant to use field `b` of type `B`
}

View File

@ -14,6 +14,39 @@ help: you might have meant to use field `b` of type `B`
LL | if let B::Fst = a.b {};
| ^^^
error: aborting due to previous error
error[E0308]: mismatched types
--> $DIR/field-access.rs:16:9
|
LL | Fst,
| --- unit variant defined here
...
LL | match a {
| - this expression has type `A`
LL | B::Fst => (),
| ^^^^^^ expected struct `A`, found enum `B`
|
help: you might have meant to use field `b` of type `B`
|
LL | match a.b {
| ^^^
error[E0308]: mismatched types
--> $DIR/field-access.rs:17:9
|
LL | Snd,
| --- unit variant defined here
...
LL | match a {
| - this expression has type `A`
LL | B::Fst => (),
LL | B::Snd => (),
| ^^^^^^ expected struct `A`, found enum `B`
|
help: you might have meant to use field `b` of type `B`
|
LL | match a.b {
| ^^^
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0308`.