Skip to content

Commit 5c581d0

Browse files
committed
Convert Operand::Move to Operand::Copy
1 parent ed97493 commit 5c581d0

File tree

142 files changed

+642
-593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+642
-593
lines changed

compiler/rustc_mir_transform/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ mod instcombine;
7474
mod lower_intrinsics;
7575
mod lower_slice_len;
7676
mod match_branches;
77+
mod move_to_copy;
7778
mod multiple_return_terminators;
7879
mod normalize_array_len;
7980
mod nrvo;
@@ -557,6 +558,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
557558
&normalize_array_len::NormalizeArrayLen, // has to run after `slice::len` lowering
558559
&unreachable_prop::UnreachablePropagation,
559560
&uninhabited_enum_branching::UninhabitedEnumBranching,
561+
&move_to_copy::MoveToCopy,
560562
&o1(simplify::SimplifyCfg::new("after-uninhabited-enum-branching")),
561563
&inline::Inline,
562564
&remove_storage_markers::RemoveStorageMarkers,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
use crate::MirPass;
2+
use rustc_middle::mir::visit::MutVisitor;
3+
use rustc_middle::mir::*;
4+
use rustc_middle::ty::{FnDef, TyCtxt};
5+
6+
/// Within-block replacement empowers ConstProp, DataflowConstProp, and DestProp. (based on looking
7+
/// at the tests)
8+
///
9+
/// SwitchInt replacement causes some basic blocks which only contain a goto to be deleted. (based
10+
/// on looking at core and alloc)
11+
/// It also makes EarlyOtherwiseBranch much more effective, but that pass is currently marked as
12+
/// unsound so this effect is not useful yet.
13+
///
14+
/// At time of writing, Assert replacement has no effect. Most likely we don't often need the
15+
/// asserted predicate for anything else, and aren't smart enough to optimize into a form that
16+
/// could use it anyway.
17+
///
18+
/// Enabling this pass for Call arguments breaks the moved-from local reuse optimization that
19+
/// Inline does, so without DestinationPropagation, modifying call arguments is just a regression.
20+
/// Except for calls to intrinsics, because those cannot be inlined.
21+
pub struct MoveToCopy;
22+
23+
impl<'tcx> MirPass<'tcx> for MoveToCopy {
24+
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
25+
let mut visitor = MoveToCopyVisitor { tcx };
26+
let mut call_visitor = MoveToCopyCallVisitor { tcx, local_decls: &body.local_decls };
27+
for (block, block_data) in body.basic_blocks.as_mut().iter_enumerated_mut() {
28+
for (statement_index, statement) in block_data.statements.iter_mut().enumerate() {
29+
visitor.visit_statement(statement, Location { block, statement_index });
30+
}
31+
let Some(terminator) = &mut block_data.terminator else {
32+
continue;
33+
};
34+
match &terminator.kind {
35+
TerminatorKind::SwitchInt { .. } | TerminatorKind::Assert { .. } => {
36+
visitor.visit_terminator(
37+
terminator,
38+
Location { block, statement_index: block_data.statements.len() },
39+
);
40+
}
41+
TerminatorKind::Call { func, .. } => {
42+
let func_ty = func.ty(call_visitor.local_decls, tcx);
43+
let is_intrinsic = if let FnDef(def_id, _) = *func_ty.kind() {
44+
tcx.is_intrinsic(def_id)
45+
} else {
46+
false
47+
};
48+
if is_intrinsic || tcx.sess.mir_opt_level() >= 3 {
49+
call_visitor.visit_terminator(
50+
terminator,
51+
Location { block, statement_index: block_data.statements.len() },
52+
);
53+
}
54+
}
55+
_ => {}
56+
}
57+
}
58+
}
59+
}
60+
61+
struct MoveToCopyCallVisitor<'a, 'tcx> {
62+
tcx: TyCtxt<'tcx>,
63+
local_decls: &'a LocalDecls<'tcx>,
64+
}
65+
66+
impl<'a, 'tcx> MutVisitor<'tcx> for MoveToCopyCallVisitor<'a, 'tcx> {
67+
fn tcx(&self) -> TyCtxt<'tcx> {
68+
self.tcx
69+
}
70+
71+
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, location: Location) {
72+
if let Operand::Move(place) = operand {
73+
let ty = place.ty(self.local_decls, self.tcx).ty;
74+
if ty.is_numeric() || ty.is_bool() || ty.is_char() {
75+
*operand = Operand::Copy(*place);
76+
}
77+
}
78+
self.super_operand(operand, location);
79+
}
80+
}
81+
82+
struct MoveToCopyVisitor<'tcx> {
83+
tcx: TyCtxt<'tcx>,
84+
}
85+
86+
impl<'tcx> MutVisitor<'tcx> for MoveToCopyVisitor<'tcx> {
87+
fn tcx(&self) -> TyCtxt<'tcx> {
88+
self.tcx
89+
}
90+
91+
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, location: Location) {
92+
if let Operand::Move(place) = operand {
93+
*operand = Operand::Copy(*place);
94+
}
95+
self.super_operand(operand, location);
96+
}
97+
}

src/test/mir-opt/76803_regression.encode.SimplifyBranchSame.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
bb0: {
1010
_2 = discriminant(_1); // scope 0 at $DIR/76803_regression.rs:+1:11: +1:12
11-
switchInt(move _2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/76803_regression.rs:+1:5: +1:12
11+
switchInt(_2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/76803_regression.rs:+1:5: +1:12
1212
}
1313

1414
bb1: {
15-
_0 = move _1; // scope 0 at $DIR/76803_regression.rs:+3:14: +3:15
15+
_0 = _1; // scope 0 at $DIR/76803_regression.rs:+3:14: +3:15
1616
goto -> bb3; // scope 0 at $DIR/76803_regression.rs:+3:14: +3:15
1717
}
1818

src/test/mir-opt/bool_compare.opt1.InstCombine.diff

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
StorageLive(_2); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:17
1212
StorageLive(_3); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:9
1313
_3 = _1; // scope 0 at $DIR/bool_compare.rs:+1:8: +1:9
14-
- _2 = Ne(move _3, const true); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:17
15-
+ _2 = Not(move _3); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:17
14+
- _2 = Ne(_3, const true); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:17
15+
+ _2 = Not(_3); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:17
1616
StorageDead(_3); // scope 0 at $DIR/bool_compare.rs:+1:16: +1:17
17-
switchInt(move _2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/bool_compare.rs:+1:8: +1:17
17+
switchInt(_2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/bool_compare.rs:+1:8: +1:17
1818
}
1919

2020
bb1: {

src/test/mir-opt/bool_compare.opt2.InstCombine.diff

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
StorageLive(_2); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:17
1212
StorageLive(_3); // scope 0 at $DIR/bool_compare.rs:+1:16: +1:17
1313
_3 = _1; // scope 0 at $DIR/bool_compare.rs:+1:16: +1:17
14-
- _2 = Ne(const true, move _3); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:17
15-
+ _2 = Not(move _3); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:17
14+
- _2 = Ne(const true, _3); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:17
15+
+ _2 = Not(_3); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:17
1616
StorageDead(_3); // scope 0 at $DIR/bool_compare.rs:+1:16: +1:17
17-
switchInt(move _2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/bool_compare.rs:+1:8: +1:17
17+
switchInt(_2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/bool_compare.rs:+1:8: +1:17
1818
}
1919

2020
bb1: {

src/test/mir-opt/bool_compare.opt3.InstCombine.diff

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
StorageLive(_2); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:18
1212
StorageLive(_3); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:9
1313
_3 = _1; // scope 0 at $DIR/bool_compare.rs:+1:8: +1:9
14-
- _2 = Eq(move _3, const false); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:18
15-
+ _2 = Not(move _3); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:18
14+
- _2 = Eq(_3, const false); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:18
15+
+ _2 = Not(_3); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:18
1616
StorageDead(_3); // scope 0 at $DIR/bool_compare.rs:+1:17: +1:18
17-
switchInt(move _2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/bool_compare.rs:+1:8: +1:18
17+
switchInt(_2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/bool_compare.rs:+1:8: +1:18
1818
}
1919

2020
bb1: {

src/test/mir-opt/bool_compare.opt4.InstCombine.diff

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
StorageLive(_2); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:18
1212
StorageLive(_3); // scope 0 at $DIR/bool_compare.rs:+1:17: +1:18
1313
_3 = _1; // scope 0 at $DIR/bool_compare.rs:+1:17: +1:18
14-
- _2 = Eq(const false, move _3); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:18
15-
+ _2 = Not(move _3); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:18
14+
- _2 = Eq(const false, _3); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:18
15+
+ _2 = Not(_3); // scope 0 at $DIR/bool_compare.rs:+1:8: +1:18
1616
StorageDead(_3); // scope 0 at $DIR/bool_compare.rs:+1:17: +1:18
17-
switchInt(move _2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/bool_compare.rs:+1:8: +1:18
17+
switchInt(_2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/bool_compare.rs:+1:8: +1:18
1818
}
1919

2020
bb1: {

src/test/mir-opt/combine_array_len.norm2.InstCombine.diff

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
- _4 = Len(_1); // scope 0 at $DIR/combine_array_len.rs:+1:13: +1:17
3333
+ _4 = const 2_usize; // scope 0 at $DIR/combine_array_len.rs:+1:13: +1:17
3434
_5 = Lt(_3, _4); // scope 0 at $DIR/combine_array_len.rs:+1:13: +1:17
35-
assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/combine_array_len.rs:+1:13: +1:17
35+
assert(_5, "index out of bounds: the length is {} but the index is {}", _4, _3) -> bb1; // scope 0 at $DIR/combine_array_len.rs:+1:13: +1:17
3636
}
3737

3838
bb1: {
@@ -44,7 +44,7 @@
4444
- _8 = Len(_1); // scope 1 at $DIR/combine_array_len.rs:+2:13: +2:17
4545
+ _8 = const 2_usize; // scope 1 at $DIR/combine_array_len.rs:+2:13: +2:17
4646
_9 = Lt(_7, _8); // scope 1 at $DIR/combine_array_len.rs:+2:13: +2:17
47-
assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> bb2; // scope 1 at $DIR/combine_array_len.rs:+2:13: +2:17
47+
assert(_9, "index out of bounds: the length is {} but the index is {}", _8, _7) -> bb2; // scope 1 at $DIR/combine_array_len.rs:+2:13: +2:17
4848
}
4949

5050
bb2: {
@@ -55,18 +55,18 @@
5555
_11 = _2; // scope 2 at $DIR/combine_array_len.rs:+3:5: +3:6
5656
StorageLive(_12); // scope 2 at $DIR/combine_array_len.rs:+3:7: +3:8
5757
_12 = _2; // scope 2 at $DIR/combine_array_len.rs:+3:7: +3:8
58-
_10 = Mul(move _11, move _12); // scope 2 at $DIR/combine_array_len.rs:+3:5: +3:8
58+
_10 = Mul(_11, _12); // scope 2 at $DIR/combine_array_len.rs:+3:5: +3:8
5959
StorageDead(_12); // scope 2 at $DIR/combine_array_len.rs:+3:7: +3:8
6060
StorageDead(_11); // scope 2 at $DIR/combine_array_len.rs:+3:7: +3:8
6161
StorageLive(_13); // scope 2 at $DIR/combine_array_len.rs:+3:11: +3:14
6262
StorageLive(_14); // scope 2 at $DIR/combine_array_len.rs:+3:11: +3:12
6363
_14 = _6; // scope 2 at $DIR/combine_array_len.rs:+3:11: +3:12
6464
StorageLive(_15); // scope 2 at $DIR/combine_array_len.rs:+3:13: +3:14
6565
_15 = _6; // scope 2 at $DIR/combine_array_len.rs:+3:13: +3:14
66-
_13 = Mul(move _14, move _15); // scope 2 at $DIR/combine_array_len.rs:+3:11: +3:14
66+
_13 = Mul(_14, _15); // scope 2 at $DIR/combine_array_len.rs:+3:11: +3:14
6767
StorageDead(_15); // scope 2 at $DIR/combine_array_len.rs:+3:13: +3:14
6868
StorageDead(_14); // scope 2 at $DIR/combine_array_len.rs:+3:13: +3:14
69-
_0 = Add(move _10, move _13); // scope 2 at $DIR/combine_array_len.rs:+3:5: +3:14
69+
_0 = Add(_10, _13); // scope 2 at $DIR/combine_array_len.rs:+3:5: +3:14
7070
StorageDead(_13); // scope 2 at $DIR/combine_array_len.rs:+3:13: +3:14
7171
StorageDead(_10); // scope 2 at $DIR/combine_array_len.rs:+3:13: +3:14
7272
StorageDead(_6); // scope 1 at $DIR/combine_array_len.rs:+4:1: +4:2

src/test/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
bb3: {
6363
StorageDead(_9); // scope 0 at $DIR/combine_clone_of_primitives.rs:10:15: 10:16
6464
Deinit(_0); // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:10: +0:15
65-
(_0.0: T) = move _2; // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:10: +0:15
66-
(_0.1: u64) = move _5; // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:10: +0:15
67-
(_0.2: [f32; 3]) = move _8; // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:10: +0:15
65+
(_0.0: T) = _2; // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:10: +0:15
66+
(_0.1: u64) = _5; // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:10: +0:15
67+
(_0.2: [f32; 3]) = _8; // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:10: +0:15
6868
StorageDead(_8); // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:14: +0:15
6969
StorageDead(_5); // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:14: +0:15
7070
StorageDead(_2); // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:14: +0:15

src/test/mir-opt/const_goto.issue_77355_opt.ConstGoto.diff

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
bb0: {
1212
- StorageLive(_2); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
1313
- _3 = discriminant(_1); // scope 0 at $DIR/const_goto.rs:+1:17: +1:20
14-
- switchInt(move _3) -> [1: bb2, 2: bb2, otherwise: bb1]; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
14+
- switchInt(_3) -> [1: bb2, 2: bb2, otherwise: bb1]; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
1515
+ _2 = discriminant(_1); // scope 0 at $DIR/const_goto.rs:+1:17: +1:20
16-
+ switchInt(move _2) -> [1: bb2, 2: bb2, otherwise: bb1]; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
16+
+ switchInt(_2) -> [1: bb2, 2: bb2, otherwise: bb1]; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
1717
}
1818

1919
bb1: {
@@ -29,7 +29,7 @@
2929
- }
3030
-
3131
- bb3: {
32-
- switchInt(move _2) -> [0: bb5, otherwise: bb4]; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
32+
- switchInt(_2) -> [0: bb5, otherwise: bb4]; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
3333
- }
3434
-
3535
- bb4: {

src/test/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
- StorageLive(_5); // scope 0 at $DIR/const_goto_storage.rs:+2:21: +2:52
2424
- StorageLive(_6); // scope 0 at $DIR/const_goto_storage.rs:+2:24: +2:28
2525
- _6 = const true; // scope 0 at $DIR/const_goto_storage.rs:+2:24: +2:28
26-
- switchInt(move _6) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/const_goto_storage.rs:+2:24: +2:28
26+
- switchInt(_6) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/const_goto_storage.rs:+2:24: +2:28
2727
+ StorageLive(_2); // scope 0 at $DIR/const_goto_storage.rs:+2:24: +2:28
2828
+ _2 = const true; // scope 0 at $DIR/const_goto_storage.rs:+2:24: +2:28
29-
+ switchInt(move _2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/const_goto_storage.rs:+2:24: +2:28
29+
+ switchInt(_2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/const_goto_storage.rs:+2:24: +2:28
3030
}
3131

3232
bb1: {
@@ -41,7 +41,7 @@
4141
-
4242
- bb3: {
4343
- StorageDead(_6); // scope 0 at $DIR/const_goto_storage.rs:+2:51: +2:52
44-
- switchInt(move _5) -> [0: bb5, otherwise: bb4]; // scope 0 at $DIR/const_goto_storage.rs:+2:21: +2:52
44+
- switchInt(_5) -> [0: bb5, otherwise: bb4]; // scope 0 at $DIR/const_goto_storage.rs:+2:21: +2:52
4545
- }
4646
-
4747
- bb4: {
@@ -56,7 +56,7 @@
5656
-
5757
- bb6: {
5858
- StorageDead(_5); // scope 0 at $DIR/const_goto_storage.rs:+2:75: +2:76
59-
- switchInt(move _4) -> [0: bb8, otherwise: bb7]; // scope 0 at $DIR/const_goto_storage.rs:+2:18: +2:76
59+
- switchInt(_4) -> [0: bb8, otherwise: bb7]; // scope 0 at $DIR/const_goto_storage.rs:+2:18: +2:76
6060
- }
6161
-
6262
- bb7: {
@@ -70,7 +70,7 @@
7070
- }
7171
-
7272
- bb9: {
73-
- switchInt(move _3) -> [0: bb11, otherwise: bb10]; // scope 0 at $DIR/const_goto_storage.rs:+2:15: +6:10
73+
- switchInt(_3) -> [0: bb11, otherwise: bb10]; // scope 0 at $DIR/const_goto_storage.rs:+2:15: +6:10
7474
- }
7575
-
7676
- bb10: {

src/test/mir-opt/const_prop/aggregate.main.ConstProp.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
(_3.1: i32) = const 1_i32; // scope 0 at $DIR/aggregate.rs:+1:13: +1:22
2020
(_3.2: i32) = const 2_i32; // scope 0 at $DIR/aggregate.rs:+1:13: +1:22
2121
- _2 = (_3.1: i32); // scope 0 at $DIR/aggregate.rs:+1:13: +1:24
22-
- _1 = Add(move _2, const 0_i32); // scope 0 at $DIR/aggregate.rs:+1:13: +1:28
22+
- _1 = Add(_2, const 0_i32); // scope 0 at $DIR/aggregate.rs:+1:13: +1:28
2323
+ _2 = const 1_i32; // scope 0 at $DIR/aggregate.rs:+1:13: +1:24
2424
+ _1 = const 1_i32; // scope 0 at $DIR/aggregate.rs:+1:13: +1:28
2525
StorageDead(_2); // scope 0 at $DIR/aggregate.rs:+1:27: +1:28

src/test/mir-opt/const_prop/array_index.main.ConstProp.32bit.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
_3 = const 2_usize; // scope 0 at $DIR/array_index.rs:+1:31: +1:32
2121
- _4 = Len(_2); // scope 0 at $DIR/array_index.rs:+1:18: +1:33
2222
- _5 = Lt(_3, _4); // scope 0 at $DIR/array_index.rs:+1:18: +1:33
23-
- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
23+
- assert(_5, "index out of bounds: the length is {} but the index is {}", _4, _3) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
2424
+ _4 = const 4_usize; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
2525
+ _5 = const true; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
26-
+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
26+
+ assert(const true, "index out of bounds: the length is {} but the index is {}", _4, _3) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
2727
}
2828

2929
bb1: {

src/test/mir-opt/const_prop/array_index.main.ConstProp.64bit.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
_3 = const 2_usize; // scope 0 at $DIR/array_index.rs:+1:31: +1:32
2121
- _4 = Len(_2); // scope 0 at $DIR/array_index.rs:+1:18: +1:33
2222
- _5 = Lt(_3, _4); // scope 0 at $DIR/array_index.rs:+1:18: +1:33
23-
- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
23+
- assert(_5, "index out of bounds: the length is {} but the index is {}", _4, _3) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
2424
+ _4 = const 4_usize; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
2525
+ _5 = const true; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
26-
+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
26+
+ assert(const true, "index out of bounds: the length is {} but the index is {}", _4, _3) -> bb1; // scope 0 at $DIR/array_index.rs:+1:18: +1:33
2727
}
2828

2929
bb1: {

0 commit comments

Comments
 (0)