-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ICE for while loop with assignment condition with LHS place expr
- Loading branch information
Showing
5 changed files
with
47 additions
and
4 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
9 changes: 9 additions & 0 deletions
9
tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.rs
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,9 @@ | ||
// Previously, the while loop with an assignment statement (mistakenly) as the condition | ||
// which has a place expr as the LHS would trigger an ICE in typeck. | ||
// Reduced from https://github.com/rust-lang/rust/issues/112385. | ||
|
||
fn main() { | ||
let foo = Some(()); | ||
while Some(foo) = None {} | ||
//~^ ERROR mismatched types | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.stderr
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,14 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/issue-112385-while-assign-lhs-place-expr-ice.rs:7:11 | ||
| | ||
LL | while Some(foo) = None {} | ||
| ^^^^^^^^^^^^^^^^ expected `bool`, found `()` | ||
| | ||
help: consider adding `let` | ||
| | ||
LL | while let Some(foo) = None {} | ||
| +++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |