diff options
| author | Michael Goulet <michael@errs.io> | 2024-02-15 14:34:42 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-02-15 15:44:46 +0000 |
| commit | c763f833d14d31fbe63e0b26370a23a51b4f11c5 (patch) | |
| tree | 98ebb10b438005f9e8d6c847f74eacdba3b17504 /tests | |
| parent | fa9f77ff35b4b63ed0cef9a9642c8f881b33f14f (diff) | |
| download | rust-c763f833d14d31fbe63e0b26370a23a51b4f11c5.tar.gz rust-c763f833d14d31fbe63e0b26370a23a51b4f11c5.zip | |
Only point out non-diverging arms for match suggestions
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/match/dont-highlight-diverging-arms.rs | 17 | ||||
| -rw-r--r-- | tests/ui/match/dont-highlight-diverging-arms.stderr | 25 | ||||
| -rw-r--r-- | tests/ui/match/match-arm-resolving-to-never.stderr | 5 |
3 files changed, 46 insertions, 1 deletions
diff --git a/tests/ui/match/dont-highlight-diverging-arms.rs b/tests/ui/match/dont-highlight-diverging-arms.rs new file mode 100644 index 00000000000..dc3b4ca9caa --- /dev/null +++ b/tests/ui/match/dont-highlight-diverging-arms.rs @@ -0,0 +1,17 @@ +fn main() { + let m = 42u32; + + let value = 'out: { + match m { + 1 => break 'out Some(1u16), + 2 => Some(2u16), + 3 => break 'out Some(3u16), + 4 => break 'out Some(4u16), + 5 => break 'out Some(5u16), + _ => {} + //~^ ERROR `match` arms have incompatible types + } + + None + }; +} \ No newline at end of file diff --git a/tests/ui/match/dont-highlight-diverging-arms.stderr b/tests/ui/match/dont-highlight-diverging-arms.stderr new file mode 100644 index 00000000000..886c1af13fa --- /dev/null +++ b/tests/ui/match/dont-highlight-diverging-arms.stderr @@ -0,0 +1,25 @@ +error[E0308]: `match` arms have incompatible types + --> $DIR/dont-highlight-diverging-arms.rs:11:18 + | +LL | / match m { +LL | | 1 => break 'out Some(1u16), +LL | | 2 => Some(2u16), + | | ---------- this is found to be of type `Option<u16>` +LL | | 3 => break 'out Some(3u16), +... | +LL | | _ => {} + | | ^^ expected `Option<u16>`, found `()` +LL | | +LL | | } + | |_________- `match` arms have incompatible types + | + = note: expected enum `Option<u16>` + found unit type `()` +help: consider using a semicolon here, but this will discard any values in the match arms + | +LL | }; + | + + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/match/match-arm-resolving-to-never.stderr b/tests/ui/match/match-arm-resolving-to-never.stderr index 6cbdf03d4c2..fd0c8708b8c 100644 --- a/tests/ui/match/match-arm-resolving-to-never.stderr +++ b/tests/ui/match/match-arm-resolving-to-never.stderr @@ -3,11 +3,14 @@ error[E0308]: `match` arms have incompatible types | LL | / match E::F { LL | | E::A => 1, + | | - this is found to be of type `{integer}` LL | | E::B => 2, + | | - this is found to be of type `{integer}` LL | | E::C => 3, + | | - this is found to be of type `{integer}` LL | | E::D => 4, + | | - this is found to be of type `{integer}` LL | | E::E => unimplemented!(""), - | | ------------------ this and all prior arms are found to be of type `{integer}` LL | | E::F => "", | | ^^ expected integer, found `&str` LL | | }; |
