Add regression test for break inside const items

This commit is contained in:
Oli Scherer 2025-05-30 16:17:48 +00:00
parent 8a407a8284
commit b73bf3c0b5
2 changed files with 19 additions and 1 deletions

View file

@ -23,3 +23,9 @@ fn main() {
}
}
}
const FOO: () = break;
//~^ ERROR: `break` outside of a loop or labeled block
static BAR: () = break;
//~^ ERROR: `break` outside of a loop or labeled block

View file

@ -10,6 +10,18 @@ error[E0268]: `break` outside of a loop or labeled block
LL | break;
| ^^^^^ cannot `break` outside of a loop or labeled block
error[E0268]: `break` outside of a loop or labeled block
--> $DIR/break-inside-inline-const-issue-128604.rs:27:17
|
LL | const FOO: () = break;
| ^^^^^ cannot `break` outside of a loop or labeled block
error[E0268]: `break` outside of a loop or labeled block
--> $DIR/break-inside-inline-const-issue-128604.rs:30:18
|
LL | static BAR: () = break;
| ^^^^^ cannot `break` outside of a loop or labeled block
error[E0268]: `break` outside of a loop or labeled block
--> $DIR/break-inside-inline-const-issue-128604.rs:2:21
|
@ -34,6 +46,6 @@ LL |
LL ~ break 'block;
|
error: aborting due to 4 previous errors
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0268`.