mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 20:23:59 +00:00
Add test for match expression
This commit is contained in:
parent
9e4ed337c7
commit
a9abf6f086
@ -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`
|
||||
}
|
||||
|
@ -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`.
|
||||
|
Loading…
Reference in New Issue
Block a user