Skip to content

Commit b394c8e

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

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-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/mir-opt/global_asm.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// skip-filecheck
2+
3+
// `global_asm!` gets a fake body, make sure it is handled correctly
4+
5+
// EMIT_MIR global_asm.{global_asm#0}.SimplifyLocals-final.after.mir
6+
std::arch::global_asm!("/* */");
7+
8+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// MIR for `{global_asm#0}` after SimplifyLocals-final
2+
3+
{global_asm#0}: ! = {
4+
let mut _0: !;
5+
6+
bb0: {
7+
asm!("/* */", options()) -> unwind unreachable;
8+
}
9+
}

0 commit comments

Comments
 (0)