Skip to content

Commit 4613650

Browse files
committed
fix ICE in pretty-printing global_asm!
1 parent 4f52199 commit 4613650

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

compiler/rustc_middle/src/mir/pretty.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,10 @@ 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+
// things like anon const, not an item
657+
(DefKind::AnonConst | DefKind::InlineConst, _) => {}
658+
// `global_asm!` have fake bodies, which we may dump after mir-build
659+
(DefKind::GlobalAsm, _) => {}
657660
_ => bug!("Unexpected def kind {:?}", kind),
658661
}
659662

tests/ui/unpretty/mir/global-asm.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//@ compile-flags: -Zdump-mir=all --crate-type=lib
2+
//@ needs-asm-support
3+
//@ check-pass
4+
5+
// `global_asm!` gets a fake body, make sure it is handled correctly
6+
7+
std::arch::global_asm!("/* */");

0 commit comments

Comments
 (0)