diff options
Diffstat (limited to 'crates/parser/src/grammar/patterns.rs')
-rw-r--r-- | crates/parser/src/grammar/patterns.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs index 716bdc978..07b1d6dd5 100644 --- a/crates/parser/src/grammar/patterns.rs +++ b/crates/parser/src/grammar/patterns.rs | |||
@@ -79,13 +79,13 @@ const PAT_RECOVERY_SET: TokenSet = | |||
79 | fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> { | 79 | fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> { |
80 | let m = match p.nth(0) { | 80 | let m = match p.nth(0) { |
81 | T![box] => box_pat(p), | 81 | T![box] => box_pat(p), |
82 | T![ref] | T![mut] => bind_pat(p, true), | 82 | T![ref] | T![mut] => ident_pat(p, true), |
83 | IDENT => match p.nth(1) { | 83 | IDENT => match p.nth(1) { |
84 | // Checks the token after an IDENT to see if a pattern is a path (Struct { .. }) or macro | 84 | // Checks the token after an IDENT to see if a pattern is a path (Struct { .. }) or macro |
85 | // (T![x]). | 85 | // (T![x]). |
86 | T!['('] | T!['{'] | T![!] => path_or_macro_pat(p), | 86 | T!['('] | T!['{'] | T![!] => path_or_macro_pat(p), |
87 | T![:] if p.nth_at(1, T![::]) => path_or_macro_pat(p), | 87 | T![:] if p.nth_at(1, T![::]) => path_or_macro_pat(p), |
88 | _ => bind_pat(p, true), | 88 | _ => ident_pat(p, true), |
89 | }, | 89 | }, |
90 | 90 | ||
91 | // test type_path_in_pattern | 91 | // test type_path_in_pattern |
@@ -93,8 +93,8 @@ fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> { | |||
93 | _ if paths::is_path_start(p) => path_or_macro_pat(p), | 93 | _ if paths::is_path_start(p) => path_or_macro_pat(p), |
94 | _ if is_literal_pat_start(p) => literal_pat(p), | 94 | _ if is_literal_pat_start(p) => literal_pat(p), |
95 | 95 | ||
96 | T![.] if p.at(T![..]) => dot_dot_pat(p), | 96 | T![.] if p.at(T![..]) => rest_pat(p), |
97 | T![_] => placeholder_pat(p), | 97 | T![_] => wildcard_pat(p), |
98 | T![&] => ref_pat(p), | 98 | T![&] => ref_pat(p), |
99 | T!['('] => tuple_pat(p), | 99 | T!['('] => tuple_pat(p), |
100 | T!['['] => slice_pat(p), | 100 | T!['['] => slice_pat(p), |
@@ -149,7 +149,7 @@ fn path_or_macro_pat(p: &mut Parser) -> CompletedMarker { | |||
149 | TUPLE_STRUCT_PAT | 149 | TUPLE_STRUCT_PAT |
150 | } | 150 | } |
151 | T!['{'] => { | 151 | T!['{'] => { |
152 | record_field_pat_list(p); | 152 | record_pat_field_list(p); |
153 | RECORD_PAT | 153 | RECORD_PAT |
154 | } | 154 | } |
155 | // test marco_pat | 155 | // test marco_pat |
@@ -186,7 +186,7 @@ fn tuple_pat_fields(p: &mut Parser) { | |||
186 | // let S { h: _, ..} = (); | 186 | // let S { h: _, ..} = (); |
187 | // let S { h: _, } = (); | 187 | // let S { h: _, } = (); |
188 | // } | 188 | // } |
189 | fn record_field_pat_list(p: &mut Parser) { | 189 | fn record_pat_field_list(p: &mut Parser) { |
190 | assert!(p.at(T!['{'])); | 190 | assert!(p.at(T!['{'])); |
191 | let m = p.start(); | 191 | let m = p.start(); |
192 | p.bump(T!['{']); | 192 | p.bump(T!['{']); |
@@ -214,7 +214,7 @@ fn record_field_pat_list(p: &mut Parser) { | |||
214 | box_pat(p); | 214 | box_pat(p); |
215 | } | 215 | } |
216 | _ => { | 216 | _ => { |
217 | bind_pat(p, false); | 217 | ident_pat(p, false); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | m.complete(p, RECORD_PAT_FIELD); | 220 | m.complete(p, RECORD_PAT_FIELD); |
@@ -230,7 +230,7 @@ fn record_field_pat_list(p: &mut Parser) { | |||
230 | 230 | ||
231 | // test placeholder_pat | 231 | // test placeholder_pat |
232 | // fn main() { let _ = (); } | 232 | // fn main() { let _ = (); } |
233 | fn placeholder_pat(p: &mut Parser) -> CompletedMarker { | 233 | fn wildcard_pat(p: &mut Parser) -> CompletedMarker { |
234 | assert!(p.at(T![_])); | 234 | assert!(p.at(T![_])); |
235 | let m = p.start(); | 235 | let m = p.start(); |
236 | p.bump(T![_]); | 236 | p.bump(T![_]); |
@@ -263,7 +263,7 @@ fn placeholder_pat(p: &mut Parser) -> CompletedMarker { | |||
263 | // let [head, .., mid, tail @ ..] = (); | 263 | // let [head, .., mid, tail @ ..] = (); |
264 | // let [head, .., mid, .., cons] = (); | 264 | // let [head, .., mid, .., cons] = (); |
265 | // } | 265 | // } |
266 | fn dot_dot_pat(p: &mut Parser) -> CompletedMarker { | 266 | fn rest_pat(p: &mut Parser) -> CompletedMarker { |
267 | assert!(p.at(T![..])); | 267 | assert!(p.at(T![..])); |
268 | let m = p.start(); | 268 | let m = p.start(); |
269 | p.bump(T![..]); | 269 | p.bump(T![..]); |
@@ -353,7 +353,7 @@ fn pat_list(p: &mut Parser, ket: SyntaxKind) { | |||
353 | // let e @ _ = (); | 353 | // let e @ _ = (); |
354 | // let ref mut f @ g @ _ = (); | 354 | // let ref mut f @ g @ _ = (); |
355 | // } | 355 | // } |
356 | fn bind_pat(p: &mut Parser, with_at: bool) -> CompletedMarker { | 356 | fn ident_pat(p: &mut Parser, with_at: bool) -> CompletedMarker { |
357 | let m = p.start(); | 357 | let m = p.start(); |
358 | p.eat(T![ref]); | 358 | p.eat(T![ref]); |
359 | p.eat(T![mut]); | 359 | p.eat(T![mut]); |