Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ICE in pretty-printing global_asm! #138280

Merged
merged 1 commit into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compiler/rustc_middle/src/mir/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}

Expand Down
9 changes: 9 additions & 0 deletions tests/mir-opt/global_asm.rs
Original file line number Diff line number Diff line change
@@ -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() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// MIR for `{global_asm#0}` after SimplifyLocals-final

{global_asm#0}: ! = {
let mut _0: !;

bb0: {
asm!("/* */", options()) -> unwind unreachable;
}
}
Loading