Bless back-compat breakages
This PR BREAKS CODE THAT WAS ACCEPTED ON STABLE. It's arguably a bug that this was accepted in the first place, but here we are. See #62272 for more info.
This commit is contained in:
parent
3ce8ca45d6
commit
281e898ecf
@ -1,5 +1,6 @@
|
||||
fn main() {
|
||||
[(); { &loop { break } as *const _ as usize } ];
|
||||
//~^ ERROR casting pointers to integers in constants is unstable
|
||||
//~| ERROR `loop` is not allowed in a `const`
|
||||
//~| ERROR evaluation of constant value failed
|
||||
}
|
||||
|
@ -1,3 +1,9 @@
|
||||
error[E0744]: `loop` is not allowed in a `const`
|
||||
--> $DIR/issue-52442.rs:2:14
|
||||
|
|
||||
LL | [(); { &loop { break } as *const _ as usize } ];
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error[E0658]: casting pointers to integers in constants is unstable
|
||||
--> $DIR/issue-52442.rs:2:13
|
||||
|
|
||||
@ -13,7 +19,7 @@ error[E0080]: evaluation of constant value failed
|
||||
LL | [(); { &loop { break } as *const _ as usize } ];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0080, E0658.
|
||||
Some errors have detailed explanations: E0080, E0658, E0744.
|
||||
For more information about an error, try `rustc --explain E0080`.
|
||||
|
@ -1,9 +1,11 @@
|
||||
// run-pass
|
||||
// `loop`s unconditionally-broken-from used to be allowed in constants, but are now forbidden by
|
||||
// the HIR const-checker.
|
||||
//
|
||||
// See https://github.com/rust-lang/rust/pull/66170 and
|
||||
// https://github.com/rust-lang/rust/issues/62272.
|
||||
|
||||
// Tests that `loop`s unconditionally-broken-from are allowed in constants.
|
||||
|
||||
const FOO: () = loop { break; };
|
||||
const FOO: () = loop { break; }; //~ ERROR `loop` is not allowed in a `const`
|
||||
|
||||
fn main() {
|
||||
[FOO; { let x; loop { x = 5; break; } x }];
|
||||
[FOO; { let x; loop { x = 5; break; } x }]; //~ ERROR `loop` is not allowed in a `const`
|
||||
}
|
||||
|
15
src/test/ui/consts/const-eval/issue-62272.stderr
Normal file
15
src/test/ui/consts/const-eval/issue-62272.stderr
Normal file
@ -0,0 +1,15 @@
|
||||
error[E0744]: `loop` is not allowed in a `const`
|
||||
--> $DIR/issue-62272.rs:7:17
|
||||
|
|
||||
LL | const FOO: () = loop { break; };
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0744]: `loop` is not allowed in a `const`
|
||||
--> $DIR/issue-62272.rs:10:20
|
||||
|
|
||||
LL | [FOO; { let x; loop { x = 5; break; } x }];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0744`.
|
@ -1,10 +1,12 @@
|
||||
// build-pass
|
||||
|
||||
// Using labeled break in a while loop has caused an illegal instruction being
|
||||
// generated, and an ICE later.
|
||||
//
|
||||
// See https://github.com/rust-lang/rust/issues/51350 for more information.
|
||||
//
|
||||
// It is now forbidden by the HIR const-checker.
|
||||
//
|
||||
// See https://github.com/rust-lang/rust/pull/66170.
|
||||
|
||||
const CRASH: () = 'a: while break 'a {};
|
||||
const CRASH: () = 'a: while break 'a {}; //~ ERROR `while` is not allowed in a `const`
|
||||
|
||||
fn main() {}
|
||||
|
9
src/test/ui/consts/const-labeled-break.stderr
Normal file
9
src/test/ui/consts/const-labeled-break.stderr
Normal file
@ -0,0 +1,9 @@
|
||||
error[E0744]: `while` is not allowed in a `const`
|
||||
--> $DIR/const-labeled-break.rs:10:19
|
||||
|
|
||||
LL | const CRASH: () = 'a: while break 'a {};
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0744`.
|
Loading…
x
Reference in New Issue
Block a user