diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index 4f3281641359d..c3a197eaf3ae8 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -778,7 +778,7 @@ impl<'a> State<'a> { } ast::ExprKind::InlineAsm(a) => { // FIXME: Print `builtin # asm` once macro `asm` uses `builtin_syntax`. - self.word("asm!"); + self.word(format!("{}!", a.asm_macro.macro_name())); self.print_inline_asm(a); } ast::ExprKind::FormatArgs(fmt) => { diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 447ad2447b3b9..14ec11daa22fb 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -1740,7 +1740,7 @@ impl<'a> State<'a> { self.print_expr_cond_paren(result, self.precedence(result) < ExprPrecedence::Jump); } hir::ExprKind::InlineAsm(asm) => { - self.word("asm!"); + self.word(format!("{}!", asm.asm_macro.macro_name())); self.print_inline_asm(asm); } hir::ExprKind::OffsetOf(container, fields) => { diff --git a/tests/ui/unpretty/exhaustive-asm.expanded.stdout b/tests/ui/unpretty/exhaustive-asm.expanded.stdout index 9b3c60b03ba77..8d2c1a5bc48bd 100644 --- a/tests/ui/unpretty/exhaustive-asm.expanded.stdout +++ b/tests/ui/unpretty/exhaustive-asm.expanded.stdout @@ -22,6 +22,10 @@ mod expressions { out(reg) _); } + + /// ExprKind::InlineAsm, with the `naked_asm!` macro + #[unsafe(naked)] + extern "C" fn expr_naked_asm() { naked_asm!("ret"); } } mod items { diff --git a/tests/ui/unpretty/exhaustive-asm.hir.stdout b/tests/ui/unpretty/exhaustive-asm.hir.stdout index c44db08653967..e3375ddcc0604 100644 --- a/tests/ui/unpretty/exhaustive-asm.hir.stdout +++ b/tests/ui/unpretty/exhaustive-asm.hir.stdout @@ -21,6 +21,10 @@ mod expressions { out(reg) _); } + + /// ExprKind::InlineAsm, with the `naked_asm!` macro + #[attr = Naked] + extern "C" fn expr_naked_asm() { naked_asm!("ret"); } } mod items { diff --git a/tests/ui/unpretty/exhaustive-asm.rs b/tests/ui/unpretty/exhaustive-asm.rs index 74a45447a20f1..dc4b3eee5e2ba 100644 --- a/tests/ui/unpretty/exhaustive-asm.rs +++ b/tests/ui/unpretty/exhaustive-asm.rs @@ -21,6 +21,12 @@ mod expressions { tmp = out(reg) _, ); } + + /// ExprKind::InlineAsm, with the `naked_asm!` macro + #[unsafe(naked)] + extern "C" fn expr_naked_asm() { + core::arch::naked_asm!("ret"); + } } mod items {