Skip to content

Commit 74d53ab

Browse files
committed
Require -Zmir-opt-level >= 3 for now
1 parent 2e034dc commit 74d53ab

File tree

5 files changed

+8
-22
lines changed

5 files changed

+8
-22
lines changed

compiler/rustc_mir_transform/src/dataflow_const_prop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct DataflowConstProp;
2121

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

2727
#[instrument(skip_all level = "debug")]

src/test/ui/const-ptr/forbidden_slices.64bit.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ LL | pub static R4: &[u8] = unsafe {
164164
|
165165
= 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.
166166
= note: the raw bytes of the constant (size: 16, align: 8) {
167-
╾──────ALLOC_ID───────╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
167+
╾──────ALLOC_ID───────╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
168168
}
169169

170170
error[E0080]: it is undefined behavior to use this value

src/test/ui/consts/const-eval/issue-50814.rs

-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ struct Sum<A, B>(A, B);
1414
impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A, B> {
1515
const MAX: u8 = A::MAX + B::MAX;
1616
//~^ ERROR evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
17-
//~| ERROR evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
1817
}
1918

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

2624
fn main() {

src/test/ui/consts/const-eval/issue-50814.stderr

+3-15
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,18 @@ error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
44
LL | const MAX: u8 = A::MAX + B::MAX;
55
| ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow
66

7-
error[E0080]: evaluation of `foo::<T>` failed
8-
--> $DIR/issue-50814.rs:21:6
9-
|
10-
LL | &Sum::<U8, U8>::MAX
11-
| ^^^^^^^^^^^^^^^^^^ referenced constant has errors
12-
13-
error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
14-
--> $DIR/issue-50814.rs:15:21
15-
|
16-
LL | const MAX: u8 = A::MAX + B::MAX;
17-
| ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow
18-
197
error[E0080]: evaluation of `foo::<i32>` failed
20-
--> $DIR/issue-50814.rs:21:6
8+
--> $DIR/issue-50814.rs:20:6
219
|
2210
LL | &Sum::<U8, U8>::MAX
2311
| ^^^^^^^^^^^^^^^^^^ referenced constant has errors
2412

2513
note: the above error was encountered while instantiating `fn foo::<i32>`
26-
--> $DIR/issue-50814.rs:27:5
14+
--> $DIR/issue-50814.rs:25:5
2715
|
2816
LL | foo(0);
2917
| ^^^^^^
3018

31-
error: aborting due to 4 previous errors
19+
error: aborting due to 2 previous errors
3220

3321
For more information about this error, try `rustc --explain E0080`.

src/test/ui/consts/offset_from_ub.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ error[E0080]: evaluation of constant value failed
4040
--> $DIR/offset_from_ub.rs:53:14
4141
|
4242
LL | unsafe { ptr_offset_from(end_ptr, start_ptr) }
43-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc18 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds
43+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc17 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds
4444

4545
error[E0080]: evaluation of constant value failed
4646
--> $DIR/offset_from_ub.rs:62:14
4747
|
4848
LL | unsafe { ptr_offset_from(start_ptr, end_ptr) }
49-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc21 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds
49+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc20 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds
5050

5151
error[E0080]: evaluation of constant value failed
5252
--> $DIR/offset_from_ub.rs:70:14
5353
|
5454
LL | unsafe { ptr_offset_from(end_ptr, end_ptr) }
55-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc24 has size 4, so pointer at offset 10 is out-of-bounds
55+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc23 has size 4, so pointer at offset 10 is out-of-bounds
5656

5757
error[E0080]: evaluation of constant value failed
5858
--> $DIR/offset_from_ub.rs:79:14

0 commit comments

Comments
 (0)