Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
recover from for-else and while-else
- Loading branch information
Showing
20 changed files
with
218 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
fn main() { | ||
for _ in 0..1 { | ||
//~^ NOTE `else` is attached to this loop | ||
} else { | ||
//~^ ERROR `for...else` loops are not supported | ||
//~| NOTE consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run | ||
} | ||
} |
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 @@ | ||
error: `for...else` loops are not supported | ||
--> $DIR/for-else-err.rs:4:7 | ||
| | ||
LL | for _ in 0..1 { | ||
| --- `else` is attached to this loop | ||
LL | | ||
LL | } else { | ||
| _______^ | ||
LL | | | ||
LL | | | ||
LL | | } | ||
| |_____^ | ||
| | ||
= note: consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run | ||
|
||
error: aborting due to previous error | ||
|
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,8 @@ | ||
fn main() { | ||
let _ = for _ in 0..1 { | ||
//~^ NOTE `else` is attached to this loop | ||
} else { | ||
//~^ ERROR `for...else` loops are not supported | ||
//~| NOTE consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run | ||
}; | ||
} |
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 @@ | ||
error: `for...else` loops are not supported | ||
--> $DIR/for-else-let-else-err.rs:4:7 | ||
| | ||
LL | let _ = for _ in 0..1 { | ||
| --- `else` is attached to this loop | ||
LL | | ||
LL | } else { | ||
| _______^ | ||
LL | | | ||
LL | | | ||
LL | | }; | ||
| |_____^ | ||
| | ||
= note: consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run | ||
|
||
error: aborting due to previous error | ||
|
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,10 @@ | ||
fn main() { | ||
let Some(1) = loop { | ||
//~^ NOTE `else` is attached to this loop | ||
break Some(1) | ||
} else { | ||
//~^ ERROR `loop...else` loops are not supported | ||
//~| NOTE consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run | ||
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: `loop...else` loops are not supported | ||
--> $DIR/loop-else-break-with-value.rs:5:7 | ||
| | ||
LL | let Some(1) = loop { | ||
| ---- `else` is attached to this loop | ||
... | ||
LL | } else { | ||
| _______^ | ||
LL | | | ||
LL | | | ||
LL | | return; | ||
LL | | }; | ||
| |_____^ | ||
| | ||
= note: consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run | ||
|
||
error: aborting due to previous error | ||
|
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,8 @@ | ||
fn main() { | ||
loop { | ||
//~^ NOTE `else` is attached to this loop | ||
} else { | ||
//~^ ERROR `loop...else` loops are not supported | ||
//~| NOTE consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run | ||
} | ||
} |
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 @@ | ||
error: `loop...else` loops are not supported | ||
--> $DIR/loop-else-err.rs:4:7 | ||
| | ||
LL | loop { | ||
| ---- `else` is attached to this loop | ||
LL | | ||
LL | } else { | ||
| _______^ | ||
LL | | | ||
LL | | | ||
LL | | } | ||
| |_____^ | ||
| | ||
= note: consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run | ||
|
||
error: aborting due to previous error | ||
|
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,8 @@ | ||
fn main() { | ||
let _ = loop { | ||
//~^ NOTE `else` is attached to this loop | ||
} else { | ||
//~^ ERROR `loop...else` loops are not supported | ||
//~| NOTE consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run | ||
}; | ||
} |
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 @@ | ||
error: `loop...else` loops are not supported | ||
--> $DIR/loop-else-let-else-err.rs:4:7 | ||
| | ||
LL | let _ = loop { | ||
| ---- `else` is attached to this loop | ||
LL | | ||
LL | } else { | ||
| _______^ | ||
LL | | | ||
LL | | | ||
LL | | }; | ||
| |_____^ | ||
| | ||
= note: consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run | ||
|
||
error: aborting due to previous error | ||
|
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,8 @@ | ||
fn main() { | ||
while false { | ||
//~^ NOTE `else` is attached to this loop | ||
} else { | ||
//~^ ERROR `while...else` loops are not supported | ||
//~| NOTE consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run | ||
}; | ||
} |
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 @@ | ||
error: `while...else` loops are not supported | ||
--> $DIR/while-else-err.rs:4:7 | ||
| | ||
LL | while false { | ||
| ----- `else` is attached to this loop | ||
LL | | ||
LL | } else { | ||
| _______^ | ||
LL | | | ||
LL | | | ||
LL | | }; | ||
| |_____^ | ||
| | ||
= note: consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run | ||
|
||
error: aborting due to previous error | ||
|
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,8 @@ | ||
fn main() { | ||
let _ = while false { | ||
//~^ NOTE `else` is attached to this loop | ||
} else { | ||
//~^ ERROR `while...else` loops are not supported | ||
//~| NOTE consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run | ||
}; | ||
} |
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 @@ | ||
error: `while...else` loops are not supported | ||
--> $DIR/while-else-let-else-err.rs:4:7 | ||
| | ||
LL | let _ = while false { | ||
| ----- `else` is attached to this loop | ||
LL | | ||
LL | } else { | ||
| _______^ | ||
LL | | | ||
LL | | | ||
LL | | }; | ||
| |_____^ | ||
| | ||
= note: consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run | ||
|
||
error: aborting due to previous error | ||
|