diff options
author | Lukas Wirth <[email protected]> | 2021-04-21 10:08:15 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-04-21 10:08:15 +0100 |
commit | 3f7a086b4f8f4c83ba03b36dcb722b897b260e6b (patch) | |
tree | ec28254cd1f8bdbdca15d1f30218abe43a383abc /crates | |
parent | 70fe7a4515ebdc6222a6565cd4cd1c5fd0c77350 (diff) |
Parse outer atttributes for RecordPatField
Diffstat (limited to 'crates')
3 files changed, 57 insertions, 8 deletions
diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs index da71498a8..3ab347834 100644 --- a/crates/parser/src/grammar/patterns.rs +++ b/crates/parser/src/grammar/patterns.rs | |||
@@ -206,13 +206,15 @@ fn record_pat_field_list(p: &mut Parser) { | |||
206 | T![.] if p.at(T![..]) => p.bump(T![..]), | 206 | T![.] if p.at(T![..]) => p.bump(T![..]), |
207 | T!['{'] => error_block(p, "expected ident"), | 207 | T!['{'] => error_block(p, "expected ident"), |
208 | 208 | ||
209 | c => { | 209 | _ => { |
210 | let m = p.start(); | 210 | let m = p.start(); |
211 | match c { | 211 | attributes::outer_attrs(p); |
212 | match p.current() { | ||
212 | // test record_pat_field | 213 | // test record_pat_field |
213 | // fn foo() { | 214 | // fn foo() { |
214 | // let S { 0: 1 } = (); | 215 | // let S { 0: 1 } = (); |
215 | // let S { x: 1 } = (); | 216 | // let S { x: 1 } = (); |
217 | // let S { #[cfg(any())] x: 1 } = (); | ||
216 | // } | 218 | // } |
217 | IDENT | INT_NUMBER if p.nth(1) == T![:] => { | 219 | IDENT | INT_NUMBER if p.nth(1) == T![:] => { |
218 | name_ref_or_index(p); | 220 | name_ref_or_index(p); |
diff --git a/crates/syntax/test_data/parser/inline/ok/0145_record_pat_field.rast b/crates/syntax/test_data/parser/inline/ok/0145_record_pat_field.rast index 925409bdf..e9202a612 100644 --- a/crates/syntax/test_data/parser/inline/ok/0145_record_pat_field.rast +++ b/crates/syntax/test_data/parser/inline/ok/0145_record_pat_field.rast | |||
@@ -1,5 +1,5 @@ | |||
1 | SOURCE_FILE@0..63 | 1 | SOURCE_FILE@0..102 |
2 | FN@0..62 | 2 | FN@0..101 |
3 | [email protected] "fn" | 3 | [email protected] "fn" |
4 | [email protected] " " | 4 | [email protected] " " |
5 | [email protected] | 5 | [email protected] |
@@ -8,7 +8,7 @@ [email protected] | |||
8 | [email protected] "(" | 8 | [email protected] "(" |
9 | [email protected] ")" | 9 | [email protected] ")" |
10 | [email protected] " " | 10 | [email protected] " " |
11 | BLOCK_EXPR@9..62 | 11 | BLOCK_EXPR@9..101 |
12 | [email protected] "{" | 12 | [email protected] "{" |
13 | [email protected] "\n " | 13 | [email protected] "\n " |
14 | [email protected] | 14 | [email protected] |
@@ -70,6 +70,52 @@ [email protected] | |||
70 | [email protected] "(" | 70 | [email protected] "(" |
71 | [email protected] ")" | 71 | [email protected] ")" |
72 | [email protected] ";" | 72 | [email protected] ";" |
73 | [email protected] "\n" | 73 | [email protected] "\n " |
74 | [email protected] "}" | 74 | [email protected] |
75 | [email protected] "\n" | 75 | [email protected] "let" |
76 | [email protected] " " | ||
77 | [email protected] | ||
78 | [email protected] | ||
79 | [email protected] | ||
80 | [email protected] | ||
81 | [email protected] "S" | ||
82 | [email protected] " " | ||
83 | [email protected] | ||
84 | [email protected] "{" | ||
85 | [email protected] " " | ||
86 | [email protected] | ||
87 | [email protected] | ||
88 | [email protected] "#" | ||
89 | [email protected] "[" | ||
90 | [email protected] | ||
91 | [email protected] | ||
92 | [email protected] | ||
93 | [email protected] "cfg" | ||
94 | [email protected] | ||
95 | [email protected] "(" | ||
96 | [email protected] "any" | ||
97 | [email protected] | ||
98 | [email protected] "(" | ||
99 | [email protected] ")" | ||
100 | [email protected] ")" | ||
101 | [email protected] "]" | ||
102 | [email protected] " " | ||
103 | [email protected] | ||
104 | [email protected] "x" | ||
105 | [email protected] ":" | ||
106 | [email protected] " " | ||
107 | [email protected] | ||
108 | [email protected] | ||
109 | [email protected] "1" | ||
110 | [email protected] " " | ||
111 | [email protected] "}" | ||
112 | [email protected] " " | ||
113 | [email protected] "=" | ||
114 | [email protected] " " | ||
115 | [email protected] | ||
116 | [email protected] "(" | ||
117 | [email protected] ")" | ||
118 | [email protected] ";" | ||
119 | [email protected] "\n" | ||
120 | [email protected] "}" | ||
121 | [email protected] "\n" | ||
diff --git a/crates/syntax/test_data/parser/inline/ok/0145_record_pat_field.rs b/crates/syntax/test_data/parser/inline/ok/0145_record_pat_field.rs index 26b1d5f89..53cfdc22d 100644 --- a/crates/syntax/test_data/parser/inline/ok/0145_record_pat_field.rs +++ b/crates/syntax/test_data/parser/inline/ok/0145_record_pat_field.rs | |||
@@ -1,4 +1,5 @@ | |||
1 | fn foo() { | 1 | fn foo() { |
2 | let S { 0: 1 } = (); | 2 | let S { 0: 1 } = (); |
3 | let S { x: 1 } = (); | 3 | let S { x: 1 } = (); |
4 | let S { #[cfg(any())] x: 1 } = (); | ||
4 | } | 5 | } |