diff options
| author | Hirochika Matsumoto <matsujika@gmail.com> | 2021-01-29 16:28:53 +0900 |
|---|---|---|
| committer | Hirochika Matsumoto <matsujika@gmail.com> | 2021-01-29 16:28:53 +0900 |
| commit | a9abf6f08663dce7b69cac826ca943149a6b093b (patch) | |
| tree | 5455636cd8414b8ddc686dc39bcbdb2347cca7df | |
| parent | 9e4ed337c783fab801d8a2e37feb58974205cfa3 (diff) | |
| download | rust-a9abf6f08663dce7b69cac826ca943149a6b093b.tar.gz rust-a9abf6f08663dce7b69cac826ca943149a6b093b.zip | |
Add test for match expression
| -rw-r--r-- | src/test/ui/suggestions/field-access.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/suggestions/field-access.stderr | 35 |
2 files changed, 42 insertions, 1 deletions
diff --git a/src/test/ui/suggestions/field-access.rs b/src/test/ui/suggestions/field-access.rs index 822f66f2a47..7bf621c21d3 100644 --- a/src/test/ui/suggestions/field-access.rs +++ b/src/test/ui/suggestions/field-access.rs @@ -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` } diff --git a/src/test/ui/suggestions/field-access.stderr b/src/test/ui/suggestions/field-access.stderr index 58bc6d3f2da..a377f8f4dea 100644 --- a/src/test/ui/suggestions/field-access.stderr +++ b/src/test/ui/suggestions/field-access.stderr @@ -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`. |
