forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nicer error message if the user attempts to do let...else if
- 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 | ||
|