-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #121146 - compiler-errors:ignore-diverging-arms, r=es…
…tebank Only point out non-diverging arms for match suggestions Fixes #121144 There is no reason to point at diverging arms, which will always coerce to whatever is the match block's evaluated type. This also removes the suggestion from #106601, since as I pointed out in #72634 (comment) the added suggestion is not firing in the right cases, but instead only when one of the match arms already *actually* evaluates to `()`. r? estebank
- Loading branch information
Showing
9 changed files
with
69 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
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 `()` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters