Require -Zmir-opt-level >= 3 for now

This commit is contained in:
Jannis Christopher Köhl 2022-11-12 15:24:23 +01:00
parent 2e034dc68c
commit 74d53ab912
5 changed files with 8 additions and 22 deletions

View File

@ -21,7 +21,7 @@ pub struct DataflowConstProp;
impl<'tcx> MirPass<'tcx> for DataflowConstProp { impl<'tcx> MirPass<'tcx> for DataflowConstProp {
fn is_enabled(&self, sess: &rustc_session::Session) -> bool { fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
sess.mir_opt_level() >= 1 sess.mir_opt_level() >= 3
} }
#[instrument(skip_all level = "debug")] #[instrument(skip_all level = "debug")]

View File

@ -164,7 +164,7 @@ LL | pub static R4: &[u8] = unsafe {
| |
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 16, align: 8) { = note: the raw bytes of the constant (size: 16, align: 8) {
╾──────ALLOC_ID───────╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ ╾──────ALLOC_ID───────╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
} }
error[E0080]: it is undefined behavior to use this value error[E0080]: it is undefined behavior to use this value

View File

@ -14,13 +14,11 @@ struct Sum<A, B>(A, B);
impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A, B> { impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A, B> {
const MAX: u8 = A::MAX + B::MAX; const MAX: u8 = A::MAX + B::MAX;
//~^ ERROR evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed //~^ ERROR evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
//~| ERROR evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
} }
fn foo<T>(_: T) -> &'static u8 { fn foo<T>(_: T) -> &'static u8 {
&Sum::<U8, U8>::MAX &Sum::<U8, U8>::MAX
//~^ ERROR evaluation of `foo::<i32>` failed [E0080] //~^ ERROR evaluation of `foo::<i32>` failed [E0080]
//~| ERROR evaluation of `foo::<T>` failed [E0080]
} }
fn main() { fn main() {

View File

@ -4,30 +4,18 @@ error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
LL | const MAX: u8 = A::MAX + B::MAX; LL | const MAX: u8 = A::MAX + B::MAX;
| ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow
error[E0080]: evaluation of `foo::<T>` failed
--> $DIR/issue-50814.rs:21:6
|
LL | &Sum::<U8, U8>::MAX
| ^^^^^^^^^^^^^^^^^^ referenced constant has errors
error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
--> $DIR/issue-50814.rs:15:21
|
LL | const MAX: u8 = A::MAX + B::MAX;
| ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow
error[E0080]: evaluation of `foo::<i32>` failed error[E0080]: evaluation of `foo::<i32>` failed
--> $DIR/issue-50814.rs:21:6 --> $DIR/issue-50814.rs:20:6
| |
LL | &Sum::<U8, U8>::MAX LL | &Sum::<U8, U8>::MAX
| ^^^^^^^^^^^^^^^^^^ referenced constant has errors | ^^^^^^^^^^^^^^^^^^ referenced constant has errors
note: the above error was encountered while instantiating `fn foo::<i32>` note: the above error was encountered while instantiating `fn foo::<i32>`
--> $DIR/issue-50814.rs:27:5 --> $DIR/issue-50814.rs:25:5
| |
LL | foo(0); LL | foo(0);
| ^^^^^^ | ^^^^^^
error: aborting due to 4 previous errors error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0080`. For more information about this error, try `rustc --explain E0080`.

View File

@ -40,19 +40,19 @@ error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:53:14 --> $DIR/offset_from_ub.rs:53:14
| |
LL | unsafe { ptr_offset_from(end_ptr, start_ptr) } LL | unsafe { ptr_offset_from(end_ptr, start_ptr) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc18 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc17 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds
error[E0080]: evaluation of constant value failed error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:62:14 --> $DIR/offset_from_ub.rs:62:14
| |
LL | unsafe { ptr_offset_from(start_ptr, end_ptr) } LL | unsafe { ptr_offset_from(start_ptr, end_ptr) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc21 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc20 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds
error[E0080]: evaluation of constant value failed error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:70:14 --> $DIR/offset_from_ub.rs:70:14
| |
LL | unsafe { ptr_offset_from(end_ptr, end_ptr) } LL | unsafe { ptr_offset_from(end_ptr, end_ptr) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc24 has size 4, so pointer at offset 10 is out-of-bounds | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc23 has size 4, so pointer at offset 10 is out-of-bounds
error[E0080]: evaluation of constant value failed error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:79:14 --> $DIR/offset_from_ub.rs:79:14