5724dad82e
Lone breaks outside of loops create errors in the loop check pass but as they are not fatal, compilation continues. MIR building code assumes all HIR break statements to point to valid locations and fires ICEs if this assumption is violated. In normal compilation, this causes no issues, as code apparently prevents MIR from being built if errors are present. However, before that, typecheck runs and with it MIR const eval. Here we operate differently from normal compilation: it doesn't check for any errors except for type checker ones and then directly builds the MIR. This constellation causes an ICE-on-error if bogus break statements are being put into array length expressions. This commit fixes this ICE by letting typecheck fail if bogus break statements are encountered. This way, MIR const eval fails cleanly with a type check error. Fixes #50576 Fixes #50581
10 lines
286 B
Plaintext
10 lines
286 B
Plaintext
error[E0268]: `break` outside of loop
|
|
--> $DIR/issue-50581.rs:12:14
|
|
|
|
|
LL | |_: [u8; break]| (); //~ ERROR [E0268]
|
|
| ^^^^^ cannot break outside of a loop
|
|
|
|
error: aborting due to previous error
|
|
|
|
For more information about this error, try `rustc --explain E0268`.
|