Skip to content

Commit 6b292c7

Browse files
committed
compiler: Require mir-opt-level > 1 for SingleUseConsts
To make `tests/debuginfo/basic-stepping.rs` pass. Note that we must keep that pass for `tests/ui-fulldeps/rustc_public/check_allocation.rs` since its `fn collect_consts()` assumes that: VarDebugInfo { name: "_false", [...] value: Place( _5, ), } becomes: VarDebugInfo { name: "_false", [...] value: Const( [...] ), }
1 parent 9f6cd6d commit 6b292c7

4 files changed

Lines changed: 9 additions & 11 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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
//@ gdb-command: next
1616
//@ gdb-check: let d = c = 99;
1717
//@ gdb-command: next
18-
// FIXME(#33013): gdb-check: let e = "hi bob";
19-
// FIXME(#33013): gdb-command: next
20-
// FIXME(#33013): gdb-check: let f = b"hi bob";
21-
// FIXME(#33013): gdb-command: next
22-
// FIXME(#33013): gdb-check: let g = b'9';
23-
// FIXME(#33013): gdb-command: next
18+
//@ gdb-check: let e = "hi bob";
19+
//@ gdb-command: next
20+
//@ gdb-check: let f = b"hi bob";
21+
//@ gdb-command: next
22+
//@ gdb-check: let g = b'9';
23+
//@ gdb-command: next
2424
//@ gdb-check: let h = ["whatever"; 8];
2525
//@ gdb-command: next
2626
//@ 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
@@ -15,9 +15,6 @@
1515
extern crate macro_stepping; // exports new_scope!()
1616

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

2219
// === GDB TESTS ===================================================================================
2320

@@ -50,7 +47,7 @@ extern crate macro_stepping; // exports new_scope!()
5047
//@ gdb-check:[...]#inc-loc2[...]
5148
//@ gdb-command:next
5249
//@ gdb-command:frame
53-
//@ [no-SingleUseConsts-mir-pass] gdb-check:[...]#inc-loc3[...]
50+
//@ gdb-check:[...]#inc-loc3[...]
5451

5552
// === LLDB TESTS ==================================================================================
5653

tests/ui-fulldeps/rustc_public/check_allocation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ fn main() {
209209
generate_input(&path).unwrap();
210210
let args = &[
211211
"rustc".to_string(),
212+
"-Zmir-enable-passes=+SingleUseConsts".to_string(), // Needed for `fn collect_consts()`
212213
"--edition=2021".to_string(),
213214
"--crate-name".to_string(),
214215
CRATE_NAME.to_string(),

0 commit comments

Comments
 (0)