Skip to content

Commit 9eabf52

Browse files
committed
compiler: Require mir_opt_level > 1 for SingleUseConsts
To make `tests/debuginfo/basic-stepping.rs` prevent further regressions of issue 33013.
1 parent 16d2c8f commit 9eabf52

3 files changed

Lines changed: 8 additions & 15 deletions

File tree

compiler/rustc_mir_transform/src/single_use_consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub(super) struct SingleUseConsts;
2323

2424
impl<'tcx> crate::MirPass<'tcx> for SingleUseConsts {
2525
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
26-
sess.mir_opt_level() > 0
26+
sess.mir_opt_level() > 1
2727
}
2828

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

tests/debuginfo/basic-stepping.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,19 @@
1010
// Debugger tests need debuginfo
1111
//@ compile-flags: -g
1212

13-
// FIXME(#128945): SingleUseConsts shouldn't need to be disabled.
14-
//@ revisions: default-mir-passes no-SingleUseConsts-mir-pass
15-
//@ [no-SingleUseConsts-mir-pass] compile-flags: -Zmir-enable-passes=-SingleUseConsts
16-
1713
//@ gdb-command: run
1814
// FIXME(#97083): Should we be able to break on initialization of zero-sized types?
1915
// FIXME(#97083): Right now the first breakable line is:
2016
//@ gdb-check: let mut c = 27;
2117
//@ gdb-command: next
2218
//@ gdb-check: let d = c = 99;
2319
//@ gdb-command: next
24-
//@ [no-SingleUseConsts-mir-pass] gdb-check: let e = "hi bob";
25-
//@ [no-SingleUseConsts-mir-pass] gdb-command: next
26-
//@ [no-SingleUseConsts-mir-pass] gdb-check: let f = b"hi bob";
27-
//@ [no-SingleUseConsts-mir-pass] gdb-command: next
28-
//@ [no-SingleUseConsts-mir-pass] gdb-check: let g = b'9';
29-
//@ [no-SingleUseConsts-mir-pass] gdb-command: next
20+
//@ gdb-check: let e = "hi bob";
21+
//@ gdb-command: next
22+
//@ gdb-check: let f = b"hi bob";
23+
//@ gdb-command: next
24+
//@ gdb-check: let g = b'9';
25+
//@ gdb-command: next
3026
//@ gdb-check: let h = ["whatever"; 8];
3127
//@ gdb-command: next
3228
//@ gdb-check: let i = [1,2,3,4];

tests/debuginfo/macro-stepping.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
extern crate macro_stepping; // exports new_scope!()
1717

1818
//@ compile-flags: -g
19-
// FIXME(#128945): SingleUseConsts shouldn't need to be disabled.
20-
//@ revisions: default-mir-passes no-SingleUseConsts-mir-pass
21-
//@ [no-SingleUseConsts-mir-pass] compile-flags: -Zmir-enable-passes=-SingleUseConsts
2219

2320
// === GDB TESTS ===================================================================================
2421

@@ -51,7 +48,7 @@ extern crate macro_stepping; // exports new_scope!()
5148
//@ gdb-check:[...]#inc-loc2[...]
5249
//@ gdb-command:next
5350
//@ gdb-command:frame
54-
//@ [no-SingleUseConsts-mir-pass] gdb-check:[...]#inc-loc3[...]
51+
//@ gdb-check:[...]#inc-loc3[...]
5552

5653
// === LLDB TESTS ==================================================================================
5754

0 commit comments

Comments
 (0)