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

-Zunpretty=expanded output with global_asm! loses semicolon thus cannot be formatted #101047

Closed
ojeda opened this issue Aug 26, 2022 · 0 comments · Fixed by #101369
Closed

-Zunpretty=expanded output with global_asm! loses semicolon thus cannot be formatted #101047

ojeda opened this issue Aug 26, 2022 · 0 comments · Fixed by #101369
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way.

Comments

@ojeda
Copy link
Contributor

ojeda commented Aug 26, 2022

Consider:

core::arch::global_asm!("x: .byte 42");
fn f() {}

(Note: the f function is important to reproduce the issue, otherwise the output disappears: see #101051)

RUSTC_BOOTSTRAP=1 rustc --edition=2021 --crate-type rlib -Zunpretty=expanded a.rs > a.rsi
rustfmt --edition=2021 --check a.rsi

This generates a line like:

global_asm! ("x: .byte 42")

Which cannot be formatted because:

error: macros that expand to items must be delimited with braces or followed by a semicolon
 --> a.rsi:6:13
  |
6 | global_asm! ("x: .byte 42")
  |             ^^^^^^^^^^^^^^^
  |
help: change the delimiters to curly braces
  |
6 | global_asm! {"x: .byte 42"}
  |             ~             ~
help: add a semicolon
  |
6 | global_asm! ("x: .byte 42");
  |                          

(It also loses the path to global_asm!, but that is not required for formatting)

Meta

Reproduces in both stable (1.63.0) and nightly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants