@@ -3,7 +3,7 @@ use super::{Parser, PResult, PathStyle};
3
3
use crate :: { maybe_recover_from_interpolated_ty_qpath, maybe_whole} ;
4
4
use crate :: ptr:: P ;
5
5
use crate :: ast:: { self , Attribute , Pat , PatKind , FieldPat , RangeEnd , RangeSyntax , Mac_ } ;
6
- use crate :: ast:: { BindingMode , Ident , Mutability , Expr , ExprKind } ;
6
+ use crate :: ast:: { BindingMode , Ident , Mutability , Path , Expr , ExprKind } ;
7
7
use crate :: parse:: token:: { self } ;
8
8
use crate :: print:: pprust;
9
9
use crate :: source_map:: { respan, Span , Spanned } ;
@@ -165,18 +165,7 @@ impl<'a> Parser<'a> {
165
165
( None , self . parse_path ( PathStyle :: Expr ) ?)
166
166
} ;
167
167
match self . token . kind {
168
- token:: Not if qself. is_none ( ) => {
169
- // Parse macro invocation
170
- self . bump ( ) ;
171
- let ( delim, tts) = self . expect_delimited_token_tree ( ) ?;
172
- let mac = respan ( lo. to ( self . prev_span ) , Mac_ {
173
- path,
174
- tts,
175
- delim,
176
- prior_type_ascription : self . last_type_ascription ,
177
- } ) ;
178
- PatKind :: Mac ( mac)
179
- }
168
+ token:: Not if qself. is_none ( ) => self . parse_pat_mac_invoc ( lo, path) ?,
180
169
token:: DotDotDot | token:: DotDotEq | token:: DotDot => {
181
170
let ( end_kind, form) = match self . token . kind {
182
171
token:: DotDot => ( RangeEnd :: Excluded , ".." ) ,
@@ -328,7 +317,8 @@ impl<'a> Parser<'a> {
328
317
} )
329
318
}
330
319
331
- // Recover on `mut ref? ident @ pat` and suggest that the order of `mut` and `ref` is incorrect.
320
+ /// Recover on `mut ref? ident @ pat` and suggest
321
+ /// that the order of `mut` and `ref` is incorrect.
332
322
fn recover_pat_ident_mut_first ( & mut self ) -> PResult < ' a , PatKind > {
333
323
let mutref_span = self . prev_span . to ( self . token . span ) ;
334
324
let binding_mode = if self . eat_keyword ( kw:: Ref ) {
@@ -347,6 +337,19 @@ impl<'a> Parser<'a> {
347
337
self . parse_pat_ident ( binding_mode)
348
338
}
349
339
340
+ /// Parse macro invocation
341
+ fn parse_pat_mac_invoc ( & mut self , lo : Span , path : Path ) -> PResult < ' a , PatKind > {
342
+ self . bump ( ) ;
343
+ let ( delim, tts) = self . expect_delimited_token_tree ( ) ?;
344
+ let mac = respan ( lo. to ( self . prev_span ) , Mac_ {
345
+ path,
346
+ tts,
347
+ delim,
348
+ prior_type_ascription : self . last_type_ascription ,
349
+ } ) ;
350
+ Ok ( PatKind :: Mac ( mac) )
351
+ }
352
+
350
353
// Helper function to decide whether to parse as ident binding
351
354
// or to try to do something more complex like range patterns.
352
355
fn parse_as_ident ( & mut self ) -> bool {
0 commit comments