Closed
Description
rustfmt
is currently unable to format code which uses the new (and unstable) attributes on struct fields feature. Demonstration:
$ echo '
> struct Foo {
> foo: usize,
> #[cfg(feature = "include-bar")]
> bar: usize,
> }
>
> fn new_foo() -> Foo {
> Foo {
> foo: 0,
> #[cfg(feature = "include-bar")]
> bar: 0,
> }
> }
> ' | rustfmt
error: expected identifier, found `#`
--> stdin:14:9
|
14 | #[cfg(feature = "include-bar")]
| ^
Interestingly, the same code on the Rust playground is simply formatted to remove the #[cfg(feature = "include-bar")]
annotation, producing:
struct Foo {
foo: usize,
#[cfg(feature = "include-bar")]
bar: usize,
}
fn new_foo() -> Foo {
Foo { foo: 0, bar: 0 }
}
Metadata
Metadata
Assignees
Labels
No labels