]> git.lizzy.rs Git - rust.git/commit
Support attributes on array members
authorRyan Cumming <etaoins@gmail.com>
Sun, 30 Jun 2019 07:59:26 +0000 (17:59 +1000)
committerRyan Cumming <etaoins@gmail.com>
Sun, 30 Jun 2019 08:36:54 +0000 (18:36 +1000)
commitb01496538c938d6a0c904512a38e4325cc960334
treea6588dc1af1094aadac540bfe90acced3fb08fea
parent27df89f47d5f0a6e8e62d517d98dda854efabc34
Support attributes on array members

Array members are allow to have attributes such as `#[cfg]`.

This is a bit tricky as we don't know if the first expression is an
initializer or a member until we encounter a `;`. This reuses a trick
from `stmt` where we remember if we saw an attribute and then raise an
error if the first expression ends up being an initializer.

This isn't perfect as the error isn't correctly located on the attribute
or initializer; it ends up immediately after the `;`.
crates/ra_parser/src/grammar/expressions/atom.rs
crates/ra_syntax/tests/data/parser/inline/err/0015_array_length_attributes.rs [new file with mode: 0644]
crates/ra_syntax/tests/data/parser/inline/err/0015_array_length_attributes.txt [new file with mode: 0644]
crates/ra_syntax/tests/data/parser/inline/ok/0135_first_array_member_attributes.rs [new file with mode: 0644]
crates/ra_syntax/tests/data/parser/inline/ok/0135_first_array_member_attributes.txt [new file with mode: 0644]
crates/ra_syntax/tests/data/parser/inline/ok/0136_subsequent_array_member_attributes.rs [new file with mode: 0644]
crates/ra_syntax/tests/data/parser/inline/ok/0136_subsequent_array_member_attributes.txt [new file with mode: 0644]