Skip to content

Commit

Permalink
Require -Zmir-opt-level >= 3 for now
Browse files Browse the repository at this point in the history
  • Loading branch information
jachris committed Nov 12, 2022
1 parent 2e034dc commit 74d53ab
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 22 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/dataflow_const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct DataflowConstProp;

impl<'tcx> MirPass<'tcx> for DataflowConstProp {
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
sess.mir_opt_level() >= 1
sess.mir_opt_level() >= 3
}

#[instrument(skip_all level = "debug")]
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/const-ptr/forbidden_slices.64bit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/consts/const-eval/issue-50814.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ struct Sum<A, B>(A, B);
impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A, B> {
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
}

fn foo<T>(_: T) -> &'static u8 {
&Sum::<U8, U8>::MAX
//~^ ERROR evaluation of `foo::<i32>` failed [E0080]
//~| ERROR evaluation of `foo::<T>` failed [E0080]
}

fn main() {
Expand Down
18 changes: 3 additions & 15 deletions src/test/ui/consts/const-eval/issue-50814.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,18 @@ error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
LL | const MAX: u8 = A::MAX + B::MAX;
| ^^^^^^^^^^^^^^^ 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
--> $DIR/issue-50814.rs:21:6
--> $DIR/issue-50814.rs:20:6
|
LL | &Sum::<U8, U8>::MAX
| ^^^^^^^^^^^^^^^^^^ referenced constant has errors

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);
| ^^^^^^

error: aborting due to 4 previous errors
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0080`.
6 changes: 3 additions & 3 deletions src/test/ui/consts/offset_from_ub.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:53:14
|
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
--> $DIR/offset_from_ub.rs:62:14
|
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
--> $DIR/offset_from_ub.rs:70:14
|
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
--> $DIR/offset_from_ub.rs:79:14
Expand Down

0 comments on commit 74d53ab

Please sign in to comment.