Rollup merge of #118010 - gurry:117821-ice-no-type-for-local-var, r=compiler-errors
Typeck break expr even if break is illegal Fixes #117821 We were returning immediately when encountering an illegal break. However, this caused problems later when the expr that the break was returning was evaluated during writeback. So now we don't return and instead simply set tainted by error. This lets typeck of break expr to occur even though we've encountered an illegal break.
This commit is contained in:
commit
1936e2c938
3 changed files with 34 additions and 10 deletions
|
|
@ -17,4 +17,10 @@ fn main() {
|
|||
};
|
||||
51
|
||||
}];
|
||||
|
||||
while true {
|
||||
break (|| { //~ ERROR `break` with value from a `while` loop
|
||||
let local = 9;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,21 @@ help: use `break` on its own without a value inside this `while` loop
|
|||
LL | break;
|
||||
| ~~~~~
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0571]: `break` with value from a `while` loop
|
||||
--> $DIR/issue-114529-illegal-break-with-value.rs:22:9
|
||||
|
|
||||
LL | while true {
|
||||
| ---------- you can't `break` with a value in a `while` loop
|
||||
LL | / break (|| {
|
||||
LL | | let local = 9;
|
||||
LL | | });
|
||||
| |__________^ can only break with a value inside `loop` or breakable block
|
||||
|
|
||||
help: use `break` on its own without a value inside this `while` loop
|
||||
|
|
||||
LL | break;
|
||||
| ~~~~~
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0571`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue