@@ -1160,9 +1160,7 @@ impl<'a> Parser<'a> {
1160
1160
{
1161
1161
self . expect ( bra) ?;
1162
1162
let result = self . parse_seq_to_before_end ( ket, sep, f) ?;
1163
- if self . token == * ket {
1164
- self . bump ( ) ;
1165
- }
1163
+ self . eat ( ket) ;
1166
1164
Ok ( result)
1167
1165
}
1168
1166
@@ -1358,8 +1356,7 @@ impl<'a> Parser<'a> {
1358
1356
let ident = self . parse_ident ( ) ?;
1359
1357
self . expect ( & token:: Colon ) ?;
1360
1358
let ty = self . parse_ty ( ) ?;
1361
- let default = if self . check ( & token:: Eq ) {
1362
- self . bump ( ) ;
1359
+ let default = if self . eat ( & token:: Eq ) {
1363
1360
let expr = self . parse_expr ( ) ?;
1364
1361
self . expect ( & token:: Semi ) ?;
1365
1362
Some ( expr)
@@ -2270,10 +2267,8 @@ impl<'a> Parser<'a> {
2270
2267
while self . token != token:: CloseDelim ( token:: Paren ) {
2271
2268
es. push ( self . parse_expr ( ) ?) ;
2272
2269
self . expect_one_of ( & [ ] , & [ token:: Comma , token:: CloseDelim ( token:: Paren ) ] ) ?;
2273
- if self . check ( & token:: Comma ) {
2270
+ if self . eat ( & token:: Comma ) {
2274
2271
trailing_comma = true ;
2275
-
2276
- self . bump ( ) ;
2277
2272
} else {
2278
2273
trailing_comma = false ;
2279
2274
break ;
@@ -2299,25 +2294,22 @@ impl<'a> Parser<'a> {
2299
2294
2300
2295
attrs. extend ( self . parse_inner_attributes ( ) ?) ;
2301
2296
2302
- if self . check ( & token:: CloseDelim ( token:: Bracket ) ) {
2297
+ if self . eat ( & token:: CloseDelim ( token:: Bracket ) ) {
2303
2298
// Empty vector.
2304
- self . bump ( ) ;
2305
2299
ex = ExprKind :: Array ( Vec :: new ( ) ) ;
2306
2300
} else {
2307
2301
// Nonempty vector.
2308
2302
let first_expr = self . parse_expr ( ) ?;
2309
- if self . check ( & token:: Semi ) {
2303
+ if self . eat ( & token:: Semi ) {
2310
2304
// Repeating array syntax: [ 0; 512 ]
2311
- self . bump ( ) ;
2312
2305
let count = AnonConst {
2313
2306
id : ast:: DUMMY_NODE_ID ,
2314
2307
value : self . parse_expr ( ) ?,
2315
2308
} ;
2316
2309
self . expect ( & token:: CloseDelim ( token:: Bracket ) ) ?;
2317
2310
ex = ExprKind :: Repeat ( first_expr, count) ;
2318
- } else if self . check ( & token:: Comma ) {
2311
+ } else if self . eat ( & token:: Comma ) {
2319
2312
// Vector with two or more elements.
2320
- self . bump ( ) ;
2321
2313
let remaining_exprs = self . parse_seq_to_end (
2322
2314
& token:: CloseDelim ( token:: Bracket ) ,
2323
2315
SeqSep :: trailing_allowed ( token:: Comma ) ,
@@ -3624,8 +3616,7 @@ impl<'a> Parser<'a> {
3624
3616
3625
3617
/// Parse the RHS of a local variable declaration (e.g. '= 14;')
3626
3618
fn parse_initializer ( & mut self , skip_eq : bool ) -> PResult < ' a , Option < P < Expr > > > {
3627
- if self . check ( & token:: Eq ) {
3628
- self . bump ( ) ;
3619
+ if self . eat ( & token:: Eq ) {
3629
3620
Ok ( Some ( self . parse_expr ( ) ?) )
3630
3621
} else if skip_eq {
3631
3622
Ok ( Some ( self . parse_expr ( ) ?) )
@@ -3651,8 +3642,8 @@ impl<'a> Parser<'a> {
3651
3642
) ;
3652
3643
err. emit ( ) ;
3653
3644
self . bump ( ) ;
3654
- } else if self . check ( & token:: BinOp ( token:: Or ) ) {
3655
- self . bump ( ) ;
3645
+ } else if self . eat ( & token:: BinOp ( token:: Or ) ) {
3646
+ // No op.
3656
3647
} else {
3657
3648
return Ok ( pats) ;
3658
3649
}
@@ -6290,8 +6281,7 @@ impl<'a> Parser<'a> {
6290
6281
6291
6282
let id_span = self . span ;
6292
6283
let id = self . parse_ident ( ) ?;
6293
- if self . check ( & token:: Semi ) {
6294
- self . bump ( ) ;
6284
+ if self . eat ( & token:: Semi ) {
6295
6285
if in_cfg && self . recurse_into_file_modules {
6296
6286
// This mod is in an external file. Let's go get it!
6297
6287
let ModulePathSuccess { path, directory_ownership, warn } =
0 commit comments