rust-lang/rustfmt

rustfmt eats attributes while formatting functions with variadic parameters

Open

#6561 aperta il 11 mag 2025

Vedi su GitHub
 (3 commenti) (0 reazioni) (0 assegnatari)Rust (760 fork)batch import
C-buggood first issue

Metriche repository

Star
 (4893 star)
Metriche merge PR
 (Merge medio 10g 21h) (8 PR mergiate in 30 g)

Descrizione

If you format...

#[allow()]
unsafe extern "C" {
    #[allow()]
    pub fn foo(#[allow()] arg: *mut u8, #[allow()]...);
}

Then it will format into

#[allow()]
unsafe extern "C" {
    #[allow()]
    pub fn foo(#[allow()] arg: *mut u8, ...);
}

(The choice of attribute seems irrelevant, I've used allow because it compiles in any position).

Note that this position is explicitly documented at https://doc.rust-lang.org/nightly/reference/attributes.html#r-attributes.allowed-position

Guida contributor