Disable NormalizeArrayLen

This commit is contained in:
Jakob Degen 2022-12-19 17:38:18 -08:00
parent 01ef4b21dc
commit 4251289f27
5 changed files with 12 additions and 19 deletions

View File

@ -16,7 +16,8 @@ pub struct NormalizeArrayLen;
impl<'tcx> MirPass<'tcx> for NormalizeArrayLen {
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
sess.mir_opt_level() >= 4
// See #105929
sess.mir_opt_level() >= 4 && sess.opts.unstable_opts.unsound_mir_opts
}
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {

View File

@ -12,7 +12,6 @@
let mut _7: usize; // in scope 0 at $DIR/slice_len.rs:+1:5: +1:33
let mut _8: bool; // in scope 0 at $DIR/slice_len.rs:+1:5: +1:33
let mut _9: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:+1:6: +1:19
let mut _10: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:+1:6: +1:19
bb0: {
StorageLive(_1); // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
@ -25,16 +24,14 @@
// + literal: Const { ty: &[u32; 3], val: Unevaluated(main, [], Some(promoted[0])) }
_4 = _9; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19
_3 = _4; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19
StorageLive(_10); // scope 0 at $DIR/slice_len.rs:+1:6: +1:19
_10 = _3; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19
_2 = move _3 as &[u32] (Pointer(Unsize)); // scope 0 at $DIR/slice_len.rs:+1:6: +1:19
StorageDead(_3); // scope 0 at $DIR/slice_len.rs:+1:18: +1:19
StorageLive(_6); // scope 0 at $DIR/slice_len.rs:+1:31: +1:32
_6 = const 1_usize; // scope 0 at $DIR/slice_len.rs:+1:31: +1:32
_7 = const 3_usize; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
StorageDead(_10); // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
- _7 = Len((*_2)); // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
- _8 = Lt(_6, _7); // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
+ _7 = const 3_usize; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
+ _8 = const true; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> bb1; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
}

View File

@ -12,7 +12,6 @@
let mut _7: usize; // in scope 0 at $DIR/slice_len.rs:+1:5: +1:33
let mut _8: bool; // in scope 0 at $DIR/slice_len.rs:+1:5: +1:33
let mut _9: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:+1:6: +1:19
let mut _10: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:+1:6: +1:19
bb0: {
StorageLive(_1); // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
@ -25,16 +24,14 @@
// + literal: Const { ty: &[u32; 3], val: Unevaluated(main, [], Some(promoted[0])) }
_4 = _9; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19
_3 = _4; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19
StorageLive(_10); // scope 0 at $DIR/slice_len.rs:+1:6: +1:19
_10 = _3; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19
_2 = move _3 as &[u32] (Pointer(Unsize)); // scope 0 at $DIR/slice_len.rs:+1:6: +1:19
StorageDead(_3); // scope 0 at $DIR/slice_len.rs:+1:18: +1:19
StorageLive(_6); // scope 0 at $DIR/slice_len.rs:+1:31: +1:32
_6 = const 1_usize; // scope 0 at $DIR/slice_len.rs:+1:31: +1:32
_7 = const 3_usize; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
StorageDead(_10); // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
- _7 = Len((*_2)); // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
- _8 = Lt(_6, _7); // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
+ _7 = const 3_usize; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
+ _8 = const true; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> bb1; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33
}

View File

@ -22,7 +22,6 @@
let mut _20: *const T; // in scope 0 at $DIR/issue_76432.rs:+3:70: +3:84
let mut _21: *const T; // in scope 0 at $DIR/issue_76432.rs:+3:70: +3:84
let mut _22: !; // in scope 0 at $SRC_DIR/core/src/panic.rs:LL:COL
let mut _23: &[T; 3]; // in scope 0 at $DIR/issue_76432.rs:+1:19: +1:29
scope 1 {
debug v => _2; // in scope 1 at $DIR/issue_76432.rs:+1:9: +1:10
let _13: &T; // in scope 1 at $DIR/issue_76432.rs:+3:10: +3:16
@ -52,17 +51,16 @@
StorageDead(_6); // scope 0 at $DIR/issue_76432.rs:+1:28: +1:29
_4 = &_5; // scope 0 at $DIR/issue_76432.rs:+1:19: +1:29
_3 = _4; // scope 0 at $DIR/issue_76432.rs:+1:19: +1:29
StorageLive(_23); // scope 0 at $DIR/issue_76432.rs:+1:19: +1:29
_23 = _3; // scope 0 at $DIR/issue_76432.rs:+1:19: +1:29
_2 = move _3 as &[T] (Pointer(Unsize)); // scope 0 at $DIR/issue_76432.rs:+1:19: +1:29
StorageDead(_3); // scope 0 at $DIR/issue_76432.rs:+1:28: +1:29
StorageDead(_4); // scope 0 at $DIR/issue_76432.rs:+1:29: +1:30
StorageLive(_9); // scope 1 at $DIR/issue_76432.rs:+2:5: +5:6
_10 = const 3_usize; // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33
StorageDead(_23); // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33
_10 = Len((*_2)); // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33
_11 = const 3_usize; // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33
_12 = const true; // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33
goto -> bb2; // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33
- _12 = Eq(move _10, const 3_usize); // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33
- switchInt(move _12) -> [0: bb1, otherwise: bb2]; // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33
+ nop; // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33
+ switchInt(move _10) -> [3: bb2, otherwise: bb1]; // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33
}
bb1: {

View File

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=4
// compile-flags: -Z mir-opt-level=4 -Zunsound-mir-opts
// EMIT_MIR lower_array_len_e2e.array_bound.PreCodegen.after.mir
pub fn array_bound<const N: usize>(index: usize, slice: &[u8; N]) -> u8 {