Skip to content

Commit 65d9a66

Browse files
committed
fix ICE in pretty-printing global_asm! const operands
1 parent 4f52199 commit 65d9a66

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

compiler/rustc_middle/src/mir/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ fn write_mir_sig(tcx: TyCtxt<'_>, body: &Body<'_>, w: &mut dyn io::Write) -> io:
653653
write!(w, "static mut ")?
654654
}
655655
(_, _) if is_function => write!(w, "fn ")?,
656-
(DefKind::AnonConst | DefKind::InlineConst, _) => {} // things like anon const, not an item
656+
(DefKind::AnonConst | DefKind::InlineConst | DefKind::GlobalAsm, _) => {} // things like anon const, not an item
657657
_ => bug!("Unexpected def kind {:?}", kind),
658658
}
659659

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ compile-flags: -Zdump-mir=all --crate-type=lib
2+
//@ needs-asm-support
3+
//@ check-pass
4+
5+
use std::arch::{asm, global_asm};
6+
7+
// test that pretty mir printing of `const` operands in `global_asm!` does not ICE
8+
9+
global_asm!("/* {} */", const 5);
10+
11+
pub fn foo() {
12+
unsafe { asm!("/* {} */", const 5) };
13+
}

0 commit comments

Comments
 (0)