Skip to content

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

Closed
@ojeda

Description

@ojeda

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-prettyArea: Pretty printing (including `-Z unpretty`)C-bugCategory: This is a bug.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions