From e9b01c745d52e5bb05ee2e8c184c188b92a349fb Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 3 Sep 2022 08:05:48 +0000 Subject: [PATCH] Fix global_asm macro pretty printing --- compiler/rustc_ast_pretty/src/pprust/state/item.rs | 2 ++ src/test/ui/asm/unpretty-expanded.rs | 3 +++ src/test/ui/asm/unpretty-expanded.stdout | 9 +++++++++ 3 files changed, 14 insertions(+) create mode 100644 src/test/ui/asm/unpretty-expanded.rs create mode 100644 src/test/ui/asm/unpretty-expanded.stdout diff --git a/compiler/rustc_ast_pretty/src/pprust/state/item.rs b/compiler/rustc_ast_pretty/src/pprust/state/item.rs index bd87987010e..54bac29a6ce 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/item.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/item.rs @@ -218,6 +218,8 @@ pub(crate) fn print_item(&mut self, item: &ast::Item) { ast::ItemKind::GlobalAsm(ref asm) => { self.head(visibility_qualified(&item.vis, "global_asm!")); self.print_inline_asm(asm); + self.word(";"); + self.end(); self.end(); } ast::ItemKind::TyAlias(box ast::TyAlias { diff --git a/src/test/ui/asm/unpretty-expanded.rs b/src/test/ui/asm/unpretty-expanded.rs new file mode 100644 index 00000000000..6128f49b89a --- /dev/null +++ b/src/test/ui/asm/unpretty-expanded.rs @@ -0,0 +1,3 @@ +// check-pass +// compile-flags: -Zunpretty=expanded +core::arch::global_asm!("x: .byte 42"); diff --git a/src/test/ui/asm/unpretty-expanded.stdout b/src/test/ui/asm/unpretty-expanded.stdout new file mode 100644 index 00000000000..15b60d1559c --- /dev/null +++ b/src/test/ui/asm/unpretty-expanded.stdout @@ -0,0 +1,9 @@ +#![feature(prelude_import)] +#![no_std] +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +// check-pass +// compile-flags: -Zunpretty=expanded +global_asm! ("x: .byte 42");