-
Notifications
You must be signed in to change notification settings - Fork 932
Open
Labels
Description
Given a snippet like this
unsafe fn foobar() {
core::arch::asm!("{}",
const X)
}
I'd expect that to format to
unsafe fn foobar() {
core::arch::asm!("{}", const X)
}
but instead nothing happens. Given that these operands are quite new, I suspect this is an oversight.
I'd happily look into fixing this, but I'm not 100% clear on whether the formatting behavior for existing code can be change? Though here I'd clearly consider it a bug.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
ytmimi commentedon Mar 29, 2025
rustfmt has never had dedicated support for the
asm!
macro. I put something together a while ago (#5191), but that open PR is fairly out of date and I'm sure there's a lot of room for improvement.It's still an open ended question on how the
asm!
macro should be formatted rust-lang/style-team#152 (at the very least no one has added the rules to the style guide).folkertdev commentedon Mar 29, 2025
Looks like no progress for the last 3 years then? And there is no real process that would make sure a decision is eventually made?
Also, while maybe it's not been decided exactly what the formatting should look like, it is more functional for certain syntax components that are older, e.g. this
does format to the expected
It would be nice if
sym
,const
and nowlabel
(stable on nightly) would at least do that rather than freezing formatting altogether.ytmimi commentedon Mar 29, 2025
That's because
options(noreturn)
looks like a function call. When it comes to macro calls, rustfmt can only format them if it can parse all of it's input tokens as valid rust syntax.sym <path>
,const <expr>
, andlabel <block>
don't parse as valid rust and prevent the macro from being formatted.There's no way around that until we add dedicated support for the
asm!
macro.[-]`asm!` operands `const` and `sym` are not formatted[/-][+]Add formatting support for the `asm!` macro[/+]ytmimi commentedon Mar 29, 2025
Marking this as blocked on rust-lang/style-team#152
asm!
parsing and validation rust-lang/rust#140490Rollup merge of rust-lang#140490 - folkertdev:asm-parser-changes, r=A…
Rollup merge of rust-lang#140490 - folkertdev:asm-parser-changes, r=A…
Auto merge of rust-lang#140490 - folkertdev:asm-parser-changes, r=<try>
Rollup merge of rust-lang#140490 - folkertdev:asm-parser-changes, r=A…
Rollup merge of rust-lang#140490 - folkertdev:asm-parser-changes, r=A…
Unrolled build for rust-lang#140490
2 remaining items