@@ -1160,9 +1160,7 @@ impl<'a> Parser<'a> {
11601160 {
11611161 self . expect ( bra) ?;
11621162 let result = self . parse_seq_to_before_end ( ket, sep, f) ?;
1163- if self . token == * ket {
1164- self . bump ( ) ;
1165- }
1163+ self . eat ( ket) ;
11661164 Ok ( result)
11671165 }
11681166
@@ -1358,8 +1356,7 @@ impl<'a> Parser<'a> {
13581356 let ident = self . parse_ident ( ) ?;
13591357 self . expect ( & token:: Colon ) ?;
13601358 let ty = self . parse_ty ( ) ?;
1361- let default = if self . check ( & token:: Eq ) {
1362- self . bump ( ) ;
1359+ let default = if self . eat ( & token:: Eq ) {
13631360 let expr = self . parse_expr ( ) ?;
13641361 self . expect ( & token:: Semi ) ?;
13651362 Some ( expr)
@@ -2270,10 +2267,8 @@ impl<'a> Parser<'a> {
22702267 while self . token != token:: CloseDelim ( token:: Paren ) {
22712268 es. push ( self . parse_expr ( ) ?) ;
22722269 self . expect_one_of ( & [ ] , & [ token:: Comma , token:: CloseDelim ( token:: Paren ) ] ) ?;
2273- if self . check ( & token:: Comma ) {
2270+ if self . eat ( & token:: Comma ) {
22742271 trailing_comma = true ;
2275-
2276- self . bump ( ) ;
22772272 } else {
22782273 trailing_comma = false ;
22792274 break ;
@@ -2299,25 +2294,22 @@ impl<'a> Parser<'a> {
22992294
23002295 attrs. extend ( self . parse_inner_attributes ( ) ?) ;
23012296
2302- if self . check ( & token:: CloseDelim ( token:: Bracket ) ) {
2297+ if self . eat ( & token:: CloseDelim ( token:: Bracket ) ) {
23032298 // Empty vector.
2304- self . bump ( ) ;
23052299 ex = ExprKind :: Array ( Vec :: new ( ) ) ;
23062300 } else {
23072301 // Nonempty vector.
23082302 let first_expr = self . parse_expr ( ) ?;
2309- if self . check ( & token:: Semi ) {
2303+ if self . eat ( & token:: Semi ) {
23102304 // Repeating array syntax: [ 0; 512 ]
2311- self . bump ( ) ;
23122305 let count = AnonConst {
23132306 id : ast:: DUMMY_NODE_ID ,
23142307 value : self . parse_expr ( ) ?,
23152308 } ;
23162309 self . expect ( & token:: CloseDelim ( token:: Bracket ) ) ?;
23172310 ex = ExprKind :: Repeat ( first_expr, count) ;
2318- } else if self . check ( & token:: Comma ) {
2311+ } else if self . eat ( & token:: Comma ) {
23192312 // Vector with two or more elements.
2320- self . bump ( ) ;
23212313 let remaining_exprs = self . parse_seq_to_end (
23222314 & token:: CloseDelim ( token:: Bracket ) ,
23232315 SeqSep :: trailing_allowed ( token:: Comma ) ,
@@ -3624,8 +3616,7 @@ impl<'a> Parser<'a> {
36243616
36253617 /// Parse the RHS of a local variable declaration (e.g. '= 14;')
36263618 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 ) {
36293620 Ok ( Some ( self . parse_expr ( ) ?) )
36303621 } else if skip_eq {
36313622 Ok ( Some ( self . parse_expr ( ) ?) )
@@ -3651,8 +3642,8 @@ impl<'a> Parser<'a> {
36513642 ) ;
36523643 err. emit ( ) ;
36533644 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.
36563647 } else {
36573648 return Ok ( pats) ;
36583649 }
@@ -6290,8 +6281,7 @@ impl<'a> Parser<'a> {
62906281
62916282 let id_span = self . span ;
62926283 let id = self . parse_ident ( ) ?;
6293- if self . check ( & token:: Semi ) {
6294- self . bump ( ) ;
6284+ if self . eat ( & token:: Semi ) {
62956285 if in_cfg && self . recurse_into_file_modules {
62966286 // This mod is in an external file. Let's go get it!
62976287 let ModulePathSuccess { path, directory_ownership, warn } =
0 commit comments