Skip to content

Commit ee64f66

Browse files
committed
Reenable NRVO.
1 parent 24f5ef4 commit ee64f66

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

compiler/rustc_mir_transform/src/nrvo.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ pub struct RenameReturnPlace;
3535

3636
impl<'tcx> MirPass<'tcx> for RenameReturnPlace {
3737
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
38-
// #111005
39-
sess.mir_opt_level() > 0 && sess.opts.unstable_opts.unsound_mir_opts
38+
sess.mir_opt_level() > 0
4039
}
4140

4241
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {

tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir

+1-5
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,13 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range<usize>) -> &[u32] {
77
scope 1 (inlined #[track_caller] core::slice::index::<impl Index<std::ops::Range<usize>> for [u32]>::index) {
88
debug self => _1;
99
debug index => _2;
10-
let _3: &[u32];
1110
}
1211

1312
bb0: {
14-
StorageLive(_3);
15-
_3 = <std::ops::Range<usize> as SliceIndex<[u32]>>::index(move _2, move _1) -> [return: bb1, unwind unreachable];
13+
_0 = <std::ops::Range<usize> as SliceIndex<[u32]>>::index(move _2, move _1) -> [return: bb1, unwind unreachable];
1614
}
1715

1816
bb1: {
19-
_0 = _3;
20-
StorageDead(_3);
2117
return;
2218
}
2319
}

tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir

+1-5
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,13 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range<usize>) -> &[u32] {
77
scope 1 (inlined #[track_caller] core::slice::index::<impl Index<std::ops::Range<usize>> for [u32]>::index) {
88
debug self => _1;
99
debug index => _2;
10-
let _3: &[u32];
1110
}
1211

1312
bb0: {
14-
StorageLive(_3);
15-
_3 = <std::ops::Range<usize> as SliceIndex<[u32]>>::index(move _2, move _1) -> [return: bb1, unwind continue];
13+
_0 = <std::ops::Range<usize> as SliceIndex<[u32]>>::index(move _2, move _1) -> [return: bb1, unwind continue];
1614
}
1715

1816
bb1: {
19-
_0 = _3;
20-
StorageDead(_3);
2117
return;
2218
}
2319
}

0 commit comments

Comments
 (0)