]> git.lizzy.rs Git - rust.git/commit
Handle pub tuple fields in tuple structs
authorAdam Bratschi-Kaye <ark.email@gmail.com>
Wed, 3 Nov 2021 22:57:46 +0000 (23:57 +0100)
committerAdam Bratschi-Kaye <ark.email@gmail.com>
Wed, 10 Nov 2021 20:29:50 +0000 (21:29 +0100)
commit0d54754ca73d8f370a902f605c94f4b588ded532
tree6dbedff8944e276f7e128c98fc7bb272eda406f7
parent04f03a360ab8fef3d9c0ff84de2d39b8a196c717
Handle pub tuple fields in tuple structs

The current implementation will throw a parser error for tuple structs
that contain a pub tuple field. For example,
```rust
struct Foo(pub (u32, u32));
```
is valid Rust, but rust-analyzer will throw a parser error.  This is
because the parens after `pub` is treated as a visibility context.
Allowing a tuple type to follow `pub` in the special case when we are
defining fields in a tuple struct can fix the issue.
crates/parser/src/grammar.rs
crates/parser/src/grammar/items.rs
crates/parser/src/grammar/items/adt.rs
crates/syntax/test_data/parser/inline/ok/0196_pub_tuple_field.rast [new file with mode: 0644]
crates/syntax/test_data/parser/inline/ok/0196_pub_tuple_field.rs [new file with mode: 0644]