rust/tests/target/issue-5011.rs
Yacin Tmimi f7c4a44149 Adjust non-empty tuple struct span to start before fields
Resolves 5011

Tuple structs with visibility modifiers and comments before the first
field were incorrectly formatted. Comments would duplicate part of the
visibility modifier and struct name.

When trying to parse the tuple fields the ``items::Context`` searches
for the opening '(', but because the visibility modifier introduces
another '(' -- for example ``pub(crate)`` -- the parsing gets messed up.

Now the span is adjusted to start after the struct identifier, or after
any generics. Adjusting the span in this way ensures that the
``items::Contex`` will correctly find the tuple fields.
2021-10-12 20:08:07 -05:00

9 lines
137 B
Rust

pub(crate) struct ASlash(
// hello
i32,
);
pub(crate) struct AStar(/* hello */ i32);
pub(crate) struct BStar(/* hello */ i32);