mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Merge #984
984: Allow attribute on struct literal field r=matklad a=pcpthm Cherrypicked from #980 Co-authored-by: pcpthm <pcpthm@gmail.com>
This commit is contained in:
commit
3ec28dd9b8
@ -453,8 +453,13 @@ pub(crate) fn named_field_list(p: &mut Parser) {
|
|||||||
p.bump();
|
p.bump();
|
||||||
while !p.at(EOF) && !p.at(R_CURLY) {
|
while !p.at(EOF) && !p.at(R_CURLY) {
|
||||||
match p.current() {
|
match p.current() {
|
||||||
IDENT => {
|
// test struct_literal_field_with_attr
|
||||||
|
// fn main() {
|
||||||
|
// S { #[cfg(test)] field: 1 }
|
||||||
|
// }
|
||||||
|
IDENT | POUND => {
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
|
attributes::outer_attributes(p);
|
||||||
name_ref(p);
|
name_ref(p);
|
||||||
if p.eat(COLON) {
|
if p.eat(COLON) {
|
||||||
expr(p);
|
expr(p);
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
S { #[cfg(test)] field: 1 }
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
SOURCE_FILE@[0; 46)
|
||||||
|
FN_DEF@[0; 45)
|
||||||
|
FN_KW@[0; 2)
|
||||||
|
WHITESPACE@[2; 3)
|
||||||
|
NAME@[3; 7)
|
||||||
|
IDENT@[3; 7) "main"
|
||||||
|
PARAM_LIST@[7; 9)
|
||||||
|
L_PAREN@[7; 8)
|
||||||
|
R_PAREN@[8; 9)
|
||||||
|
WHITESPACE@[9; 10)
|
||||||
|
BLOCK@[10; 45)
|
||||||
|
L_CURLY@[10; 11)
|
||||||
|
WHITESPACE@[11; 16)
|
||||||
|
STRUCT_LIT@[16; 43)
|
||||||
|
PATH@[16; 17)
|
||||||
|
PATH_SEGMENT@[16; 17)
|
||||||
|
NAME_REF@[16; 17)
|
||||||
|
IDENT@[16; 17) "S"
|
||||||
|
WHITESPACE@[17; 18)
|
||||||
|
NAMED_FIELD_LIST@[18; 43)
|
||||||
|
L_CURLY@[18; 19)
|
||||||
|
WHITESPACE@[19; 20)
|
||||||
|
NAMED_FIELD@[20; 41)
|
||||||
|
ATTR@[20; 32)
|
||||||
|
POUND@[20; 21)
|
||||||
|
TOKEN_TREE@[21; 32)
|
||||||
|
L_BRACK@[21; 22)
|
||||||
|
IDENT@[22; 25) "cfg"
|
||||||
|
TOKEN_TREE@[25; 31)
|
||||||
|
L_PAREN@[25; 26)
|
||||||
|
IDENT@[26; 30) "test"
|
||||||
|
R_PAREN@[30; 31)
|
||||||
|
R_BRACK@[31; 32)
|
||||||
|
WHITESPACE@[32; 33)
|
||||||
|
NAME_REF@[33; 38)
|
||||||
|
IDENT@[33; 38) "field"
|
||||||
|
COLON@[38; 39)
|
||||||
|
WHITESPACE@[39; 40)
|
||||||
|
LITERAL@[40; 41)
|
||||||
|
INT_NUMBER@[40; 41) "1"
|
||||||
|
WHITESPACE@[41; 42)
|
||||||
|
R_CURLY@[42; 43)
|
||||||
|
WHITESPACE@[43; 44)
|
||||||
|
R_CURLY@[44; 45)
|
||||||
|
WHITESPACE@[45; 46)
|
Loading…
Reference in New Issue
Block a user