forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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 rust-lang#89974 - est31:let_else_if_error, r=nagisa
Nicer error message if the user attempts to do let...else if Gives a nice "conditional `else if` is not supported for `let...else`" error when encountering a `let...else if` pattern, as suggested in the [let...else tracking issue](rust-lang#87335 (comment)).
- Loading branch information
Showing
3 changed files
with
44 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#![feature(let_else)] | ||
|
||
fn main() { | ||
let Some(_) = Some(()) else if true { | ||
//~^ ERROR conditional `else if` is not supported for `let...else` | ||
return; | ||
} else { | ||
return; | ||
}; | ||
} |
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,18 @@ | ||
error: conditional `else if` is not supported for `let...else` | ||
--> $DIR/let-else-if.rs:4:33 | ||
| | ||
LL | let Some(_) = Some(()) else if true { | ||
| ^^ expected `{` | ||
| | ||
help: try placing this code inside a block | ||
| | ||
LL ~ let Some(_) = Some(()) else { if true { | ||
LL + | ||
LL + return; | ||
LL + } else { | ||
LL + return; | ||
LL ~ } }; | ||
| | ||
|
||
error: aborting due to previous error | ||
|