Added MIR const-prop diff tests to show why some assertions now fail at compile-time
This commit is contained in:
parent
072649ec5d
commit
e2ab2758f2
7 changed files with 421 additions and 0 deletions
6
src/test/mir-opt/const_prop/bad_op_div_by_zero.rs
Normal file
6
src/test/mir-opt/const_prop/bad_op_div_by_zero.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// EMIT_MIR rustc.main.ConstProp.diff
|
||||
#[allow(unconditional_panic)]
|
||||
fn main() {
|
||||
let y = 0;
|
||||
let _z = 1 / y;
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
- // MIR for `main` before ConstProp
|
||||
+ // MIR for `main` after ConstProp
|
||||
|
||||
fn main() -> () {
|
||||
let mut _0: (); // return place in scope 0 at $DIR/bad_op_div_by_zero.rs:3:11: 3:11
|
||||
let _1: i32; // in scope 0 at $DIR/bad_op_div_by_zero.rs:4:9: 4:10
|
||||
let mut _3: i32; // in scope 0 at $DIR/bad_op_div_by_zero.rs:5:18: 5:19
|
||||
let mut _4: bool; // in scope 0 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
let mut _5: bool; // in scope 0 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
let mut _6: bool; // in scope 0 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
let mut _7: bool; // in scope 0 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
scope 1 {
|
||||
debug y => _1; // in scope 1 at $DIR/bad_op_div_by_zero.rs:4:9: 4:10
|
||||
let _2: i32; // in scope 1 at $DIR/bad_op_div_by_zero.rs:5:9: 5:11
|
||||
scope 2 {
|
||||
debug _z => _2; // in scope 2 at $DIR/bad_op_div_by_zero.rs:5:9: 5:11
|
||||
}
|
||||
}
|
||||
|
||||
bb0: {
|
||||
StorageLive(_1); // scope 0 at $DIR/bad_op_div_by_zero.rs:4:9: 4:10
|
||||
_1 = const 0i32; // scope 0 at $DIR/bad_op_div_by_zero.rs:4:13: 4:14
|
||||
// ty::Const
|
||||
// + ty: i32
|
||||
// + val: Value(Scalar(0x00000000))
|
||||
// mir::Constant
|
||||
// + span: $DIR/bad_op_div_by_zero.rs:4:13: 4:14
|
||||
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
|
||||
StorageLive(_2); // scope 1 at $DIR/bad_op_div_by_zero.rs:5:9: 5:11
|
||||
StorageLive(_3); // scope 1 at $DIR/bad_op_div_by_zero.rs:5:18: 5:19
|
||||
- _3 = _1; // scope 1 at $DIR/bad_op_div_by_zero.rs:5:18: 5:19
|
||||
- _4 = Eq(_3, const 0i32); // scope 1 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
+ _3 = const 0i32; // scope 1 at $DIR/bad_op_div_by_zero.rs:5:18: 5:19
|
||||
// ty::Const
|
||||
// + ty: i32
|
||||
// + val: Value(Scalar(0x00000000))
|
||||
// mir::Constant
|
||||
- // + span: $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
+ // + span: $DIR/bad_op_div_by_zero.rs:5:18: 5:19
|
||||
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
|
||||
+ _4 = const true; // scope 1 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
+ // ty::Const
|
||||
+ // + ty: bool
|
||||
+ // + val: Value(Scalar(0x01))
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
+ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
|
||||
assert(!move _4, "attempt to divide by zero") -> bb1; // scope 1 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
}
|
||||
|
||||
bb1: {
|
||||
- _5 = Eq(_3, const -1i32); // scope 1 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
+ _5 = const false; // scope 1 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
// ty::Const
|
||||
- // + ty: i32
|
||||
- // + val: Value(Scalar(0xffffffff))
|
||||
+ // + ty: bool
|
||||
+ // + val: Value(Scalar(0x00))
|
||||
// mir::Constant
|
||||
// + span: $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
- // + literal: Const { ty: i32, val: Value(Scalar(0xffffffff)) }
|
||||
- _6 = Eq(const 1i32, const std::i32::MIN); // scope 1 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
+ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
|
||||
+ _6 = const false; // scope 1 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
// ty::Const
|
||||
- // + ty: i32
|
||||
- // + val: Value(Scalar(0x00000001))
|
||||
+ // + ty: bool
|
||||
+ // + val: Value(Scalar(0x00))
|
||||
// mir::Constant
|
||||
- // + span: $DIR/bad_op_div_by_zero.rs:5:14: 5:15
|
||||
- // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
|
||||
+ // + span: $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
+ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
|
||||
+ _7 = const false; // scope 1 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
// ty::Const
|
||||
- // + ty: i32
|
||||
- // + val: Value(Scalar(0x80000000))
|
||||
+ // + ty: bool
|
||||
+ // + val: Value(Scalar(0x00))
|
||||
// mir::Constant
|
||||
// + span: $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
- // + literal: Const { ty: i32, val: Value(Scalar(0x80000000)) }
|
||||
- _7 = BitAnd(move _5, move _6); // scope 1 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
- assert(!move _7, "attempt to divide with overflow") -> bb2; // scope 1 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
+ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
|
||||
+ assert(!const false, "attempt to divide with overflow") -> bb2; // scope 1 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
+ // ty::Const
|
||||
+ // + ty: bool
|
||||
+ // + val: Value(Scalar(0x00))
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
+ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
|
||||
}
|
||||
|
||||
bb2: {
|
||||
_2 = Div(const 1i32, move _3); // scope 1 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
|
||||
// ty::Const
|
||||
// + ty: i32
|
||||
// + val: Value(Scalar(0x00000001))
|
||||
// mir::Constant
|
||||
// + span: $DIR/bad_op_div_by_zero.rs:5:14: 5:15
|
||||
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
|
||||
StorageDead(_3); // scope 1 at $DIR/bad_op_div_by_zero.rs:5:18: 5:19
|
||||
_0 = const (); // scope 0 at $DIR/bad_op_div_by_zero.rs:3:11: 6:2
|
||||
// ty::Const
|
||||
// + ty: ()
|
||||
// + val: Value(Scalar(<ZST>))
|
||||
// mir::Constant
|
||||
// + span: $DIR/bad_op_div_by_zero.rs:3:11: 6:2
|
||||
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
|
||||
StorageDead(_2); // scope 1 at $DIR/bad_op_div_by_zero.rs:6:1: 6:2
|
||||
StorageDead(_1); // scope 0 at $DIR/bad_op_div_by_zero.rs:6:1: 6:2
|
||||
return; // scope 0 at $DIR/bad_op_div_by_zero.rs:6:2: 6:2
|
||||
}
|
||||
}
|
||||
|
||||
6
src/test/mir-opt/const_prop/bad_op_mod_by_zero.rs
Normal file
6
src/test/mir-opt/const_prop/bad_op_mod_by_zero.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// EMIT_MIR rustc.main.ConstProp.diff
|
||||
#[allow(unconditional_panic)]
|
||||
fn main() {
|
||||
let y = 0;
|
||||
let _z = 1 % y;
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
- // MIR for `main` before ConstProp
|
||||
+ // MIR for `main` after ConstProp
|
||||
|
||||
fn main() -> () {
|
||||
let mut _0: (); // return place in scope 0 at $DIR/bad_op_mod_by_zero.rs:3:11: 3:11
|
||||
let _1: i32; // in scope 0 at $DIR/bad_op_mod_by_zero.rs:4:9: 4:10
|
||||
let mut _3: i32; // in scope 0 at $DIR/bad_op_mod_by_zero.rs:5:18: 5:19
|
||||
let mut _4: bool; // in scope 0 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
let mut _5: bool; // in scope 0 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
let mut _6: bool; // in scope 0 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
let mut _7: bool; // in scope 0 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
scope 1 {
|
||||
debug y => _1; // in scope 1 at $DIR/bad_op_mod_by_zero.rs:4:9: 4:10
|
||||
let _2: i32; // in scope 1 at $DIR/bad_op_mod_by_zero.rs:5:9: 5:11
|
||||
scope 2 {
|
||||
debug _z => _2; // in scope 2 at $DIR/bad_op_mod_by_zero.rs:5:9: 5:11
|
||||
}
|
||||
}
|
||||
|
||||
bb0: {
|
||||
StorageLive(_1); // scope 0 at $DIR/bad_op_mod_by_zero.rs:4:9: 4:10
|
||||
_1 = const 0i32; // scope 0 at $DIR/bad_op_mod_by_zero.rs:4:13: 4:14
|
||||
// ty::Const
|
||||
// + ty: i32
|
||||
// + val: Value(Scalar(0x00000000))
|
||||
// mir::Constant
|
||||
// + span: $DIR/bad_op_mod_by_zero.rs:4:13: 4:14
|
||||
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
|
||||
StorageLive(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:9: 5:11
|
||||
StorageLive(_3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:18: 5:19
|
||||
- _3 = _1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:18: 5:19
|
||||
- _4 = Eq(_3, const 0i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
+ _3 = const 0i32; // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:18: 5:19
|
||||
// ty::Const
|
||||
// + ty: i32
|
||||
// + val: Value(Scalar(0x00000000))
|
||||
// mir::Constant
|
||||
- // + span: $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
+ // + span: $DIR/bad_op_mod_by_zero.rs:5:18: 5:19
|
||||
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
|
||||
+ _4 = const true; // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
+ // ty::Const
|
||||
+ // + ty: bool
|
||||
+ // + val: Value(Scalar(0x01))
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
+ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) }
|
||||
assert(!move _4, "attempt to calculate the remainder with a divisor of zero") -> bb1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
}
|
||||
|
||||
bb1: {
|
||||
- _5 = Eq(_3, const -1i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
+ _5 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
// ty::Const
|
||||
- // + ty: i32
|
||||
- // + val: Value(Scalar(0xffffffff))
|
||||
+ // + ty: bool
|
||||
+ // + val: Value(Scalar(0x00))
|
||||
// mir::Constant
|
||||
// + span: $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
- // + literal: Const { ty: i32, val: Value(Scalar(0xffffffff)) }
|
||||
- _6 = Eq(const 1i32, const std::i32::MIN); // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
+ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
|
||||
+ _6 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
// ty::Const
|
||||
- // + ty: i32
|
||||
- // + val: Value(Scalar(0x00000001))
|
||||
+ // + ty: bool
|
||||
+ // + val: Value(Scalar(0x00))
|
||||
// mir::Constant
|
||||
- // + span: $DIR/bad_op_mod_by_zero.rs:5:14: 5:15
|
||||
- // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
|
||||
+ // + span: $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
+ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
|
||||
+ _7 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
// ty::Const
|
||||
- // + ty: i32
|
||||
- // + val: Value(Scalar(0x80000000))
|
||||
+ // + ty: bool
|
||||
+ // + val: Value(Scalar(0x00))
|
||||
// mir::Constant
|
||||
// + span: $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
- // + literal: Const { ty: i32, val: Value(Scalar(0x80000000)) }
|
||||
- _7 = BitAnd(move _5, move _6); // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
- assert(!move _7, "attempt to calculate the remainder with overflow") -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
+ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
|
||||
+ assert(!const false, "attempt to calculate the remainder with overflow") -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
+ // ty::Const
|
||||
+ // + ty: bool
|
||||
+ // + val: Value(Scalar(0x00))
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
+ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
|
||||
}
|
||||
|
||||
bb2: {
|
||||
_2 = Rem(const 1i32, move _3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
|
||||
// ty::Const
|
||||
// + ty: i32
|
||||
// + val: Value(Scalar(0x00000001))
|
||||
// mir::Constant
|
||||
// + span: $DIR/bad_op_mod_by_zero.rs:5:14: 5:15
|
||||
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
|
||||
StorageDead(_3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:18: 5:19
|
||||
_0 = const (); // scope 0 at $DIR/bad_op_mod_by_zero.rs:3:11: 6:2
|
||||
// ty::Const
|
||||
// + ty: ()
|
||||
// + val: Value(Scalar(<ZST>))
|
||||
// mir::Constant
|
||||
// + span: $DIR/bad_op_mod_by_zero.rs:3:11: 6:2
|
||||
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
|
||||
StorageDead(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:6:1: 6:2
|
||||
StorageDead(_1); // scope 0 at $DIR/bad_op_mod_by_zero.rs:6:1: 6:2
|
||||
return; // scope 0 at $DIR/bad_op_mod_by_zero.rs:6:2: 6:2
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
// EMIT_MIR_FOR_EACH_BIT_WIDTH
|
||||
// EMIT_MIR rustc.main.ConstProp.diff
|
||||
#[allow(unconditional_panic)]
|
||||
fn main() {
|
||||
let a: *const [_] = &[1, 2, 3];
|
||||
unsafe {
|
||||
let _b = (*a)[3];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
- // MIR for `main` before ConstProp
|
||||
+ // MIR for `main` after ConstProp
|
||||
|
||||
fn main() -> () {
|
||||
let mut _0: (); // return place in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:4:11: 4:11
|
||||
let _1: *const [i32] as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:9: 5:10
|
||||
let mut _2: *const [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
let _3: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
let _4: [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:26: 5:35
|
||||
let _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:23: 7:24
|
||||
let mut _7: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
let mut _8: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
let mut _9: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
scope 1 {
|
||||
debug a => _1; // in scope 1 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:9: 5:10
|
||||
scope 2 {
|
||||
let _5: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:13: 7:15
|
||||
scope 3 {
|
||||
debug _b => _5; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:13: 7:15
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bb0: {
|
||||
StorageLive(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:9: 5:10
|
||||
StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
StorageLive(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
_9 = const main::promoted[0]; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
// ty::Const
|
||||
// + ty: &[i32; 3]
|
||||
// + val: Unevaluated(DefId(0:3 ~ bad_op_unsafe_oob_for_slices[317d]::main[0]), [], Some(promoted[0]))
|
||||
// mir::Constant
|
||||
// + span: $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
// + literal: Const { ty: &[i32; 3], val: Unevaluated(DefId(0:3 ~ bad_op_unsafe_oob_for_slices[317d]::main[0]), [], Some(promoted[0])) }
|
||||
_3 = _9; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
_2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
_1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
StorageDead(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:34: 5:35
|
||||
StorageDead(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:35: 5:36
|
||||
StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:13: 7:15
|
||||
StorageLive(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:23: 7:24
|
||||
_6 = const 3usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:23: 7:24
|
||||
// ty::Const
|
||||
// + ty: usize
|
||||
// + val: Value(Scalar(0x00000003))
|
||||
// mir::Constant
|
||||
// + span: $DIR/bad_op_unsafe_oob_for_slices.rs:7:23: 7:24
|
||||
// + literal: Const { ty: usize, val: Value(Scalar(0x00000003)) }
|
||||
- _7 = Len((*_1)); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
- _8 = Lt(_6, _7); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
+ _7 = const 3usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
+ // ty::Const
|
||||
+ // + ty: usize
|
||||
+ // + val: Value(Scalar(0x00000003))
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
+ // + literal: Const { ty: usize, val: Value(Scalar(0x00000003)) }
|
||||
+ _8 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
+ // ty::Const
|
||||
+ // + ty: bool
|
||||
+ // + val: Value(Scalar(0x00))
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
+ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
|
||||
assert(move _8, "index out of bounds: the len is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
}
|
||||
|
||||
bb1: {
|
||||
_5 = (*_1)[_6]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
StorageDead(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:25: 7:26
|
||||
_0 = const (); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:6:5: 8:6
|
||||
// ty::Const
|
||||
// + ty: ()
|
||||
// + val: Value(Scalar(<ZST>))
|
||||
// mir::Constant
|
||||
// + span: $DIR/bad_op_unsafe_oob_for_slices.rs:6:5: 8:6
|
||||
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
|
||||
StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:8:5: 8:6
|
||||
StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:9:1: 9:2
|
||||
return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:9:2: 9:2
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
- // MIR for `main` before ConstProp
|
||||
+ // MIR for `main` after ConstProp
|
||||
|
||||
fn main() -> () {
|
||||
let mut _0: (); // return place in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:4:11: 4:11
|
||||
let _1: *const [i32] as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:9: 5:10
|
||||
let mut _2: *const [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
let _3: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
let _4: [i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:26: 5:35
|
||||
let _6: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:23: 7:24
|
||||
let mut _7: usize; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
let mut _8: bool; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
let mut _9: &[i32; 3]; // in scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
scope 1 {
|
||||
debug a => _1; // in scope 1 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:9: 5:10
|
||||
scope 2 {
|
||||
let _5: i32; // in scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:13: 7:15
|
||||
scope 3 {
|
||||
debug _b => _5; // in scope 3 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:13: 7:15
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bb0: {
|
||||
StorageLive(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:9: 5:10
|
||||
StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
StorageLive(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
_9 = const main::promoted[0]; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
// ty::Const
|
||||
// + ty: &[i32; 3]
|
||||
// + val: Unevaluated(DefId(0:3 ~ bad_op_unsafe_oob_for_slices[317d]::main[0]), [], Some(promoted[0]))
|
||||
// mir::Constant
|
||||
// + span: $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
// + literal: Const { ty: &[i32; 3], val: Unevaluated(DefId(0:3 ~ bad_op_unsafe_oob_for_slices[317d]::main[0]), [], Some(promoted[0])) }
|
||||
_3 = _9; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
_2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
_1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35
|
||||
StorageDead(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:34: 5:35
|
||||
StorageDead(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:5:35: 5:36
|
||||
StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:13: 7:15
|
||||
StorageLive(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:23: 7:24
|
||||
_6 = const 3usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:23: 7:24
|
||||
// ty::Const
|
||||
// + ty: usize
|
||||
// + val: Value(Scalar(0x0000000000000003))
|
||||
// mir::Constant
|
||||
// + span: $DIR/bad_op_unsafe_oob_for_slices.rs:7:23: 7:24
|
||||
// + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000003)) }
|
||||
- _7 = Len((*_1)); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
- _8 = Lt(_6, _7); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
+ _7 = const 3usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
+ // ty::Const
|
||||
+ // + ty: usize
|
||||
+ // + val: Value(Scalar(0x0000000000000003))
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
+ // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000003)) }
|
||||
+ _8 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
+ // ty::Const
|
||||
+ // + ty: bool
|
||||
+ // + val: Value(Scalar(0x00))
|
||||
+ // mir::Constant
|
||||
+ // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
+ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) }
|
||||
assert(move _8, "index out of bounds: the len is {} but the index is {}", move _7, _6) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
}
|
||||
|
||||
bb1: {
|
||||
_5 = (*_1)[_6]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
|
||||
StorageDead(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:25: 7:26
|
||||
_0 = const (); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:6:5: 8:6
|
||||
// ty::Const
|
||||
// + ty: ()
|
||||
// + val: Value(Scalar(<ZST>))
|
||||
// mir::Constant
|
||||
// + span: $DIR/bad_op_unsafe_oob_for_slices.rs:6:5: 8:6
|
||||
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
|
||||
StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:8:5: 8:6
|
||||
StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:9:1: 9:2
|
||||
return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:9:2: 9:2
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue