diff options
| author | Folkert de Vries <folkert@folkertdev.nl> | 2025-03-09 16:47:38 +0100 |
|---|---|---|
| committer | Folkert de Vries <folkert@folkertdev.nl> | 2025-03-10 14:46:01 +0100 |
| commit | 9213cb80c29941a7fb752413613c2c68f7e7d7b3 (patch) | |
| tree | ca78411cc0f905f00cb5032f209d8220237bd017 | |
| parent | 4f521991945886709a875ba2aeaa859574126c0e (diff) | |
| download | rust-9213cb80c29941a7fb752413613c2c68f7e7d7b3.tar.gz rust-9213cb80c29941a7fb752413613c2c68f7e7d7b3.zip | |
fix ICE in pretty-printing `global_asm!`
| -rw-r--r-- | compiler/rustc_middle/src/mir/pretty.rs | 5 | ||||
| -rw-r--r-- | tests/mir-opt/global_asm.rs | 9 | ||||
| -rw-r--r-- | tests/mir-opt/global_asm.{global_asm#0}.SimplifyLocals-final.after.mir | 9 |
3 files changed, 22 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index f880b1364c2..05da8511361 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -653,7 +653,10 @@ fn write_mir_sig(tcx: TyCtxt<'_>, body: &Body<'_>, w: &mut dyn io::Write) -> io: write!(w, "static mut ")? } (_, _) if is_function => write!(w, "fn ")?, - (DefKind::AnonConst | DefKind::InlineConst, _) => {} // things like anon const, not an item + // things like anon const, not an item + (DefKind::AnonConst | DefKind::InlineConst, _) => {} + // `global_asm!` have fake bodies, which we may dump after mir-build + (DefKind::GlobalAsm, _) => {} _ => bug!("Unexpected def kind {:?}", kind), } diff --git a/tests/mir-opt/global_asm.rs b/tests/mir-opt/global_asm.rs new file mode 100644 index 00000000000..22b782d365e --- /dev/null +++ b/tests/mir-opt/global_asm.rs @@ -0,0 +1,9 @@ +// skip-filecheck +//@ needs-asm-support + +// `global_asm!` gets a fake body, make sure it is handled correctly + +// EMIT_MIR global_asm.{global_asm#0}.SimplifyLocals-final.after.mir +core::arch::global_asm!("/* */"); + +fn main() {} diff --git a/tests/mir-opt/global_asm.{global_asm#0}.SimplifyLocals-final.after.mir b/tests/mir-opt/global_asm.{global_asm#0}.SimplifyLocals-final.after.mir new file mode 100644 index 00000000000..cec3c4a8261 --- /dev/null +++ b/tests/mir-opt/global_asm.{global_asm#0}.SimplifyLocals-final.after.mir @@ -0,0 +1,9 @@ +// MIR for `{global_asm#0}` after SimplifyLocals-final + +{global_asm#0}: ! = { + let mut _0: !; + + bb0: { + asm!("/* */", options()) -> unwind unreachable; + } +} |
