@@ -91,10 +91,10 @@ use std::iter;
9191
9292bitflags ! {
9393 flags Restrictions : u8 {
94- static Unrestricted = 0b0000 ,
95- static RestrictionStmtExpr = 0b0001 ,
96- static RestrictionNoBarOp = 0b0010 ,
97- static RestrictionNoStructLiteral = 0b0100
94+ static UNRESTRICTED = 0b0000 ,
95+ static RESTRICTION_STMT_EXPR = 0b0001 ,
96+ static RESTRICTION_NO_BAR_OP = 0b0010 ,
97+ static RESTRICTION_NO_STRUCT_LITERAL = 0b0100
9898 }
9999}
100100
@@ -383,7 +383,7 @@ impl<'a> Parser<'a> {
383383 buffer_start : 0 ,
384384 buffer_end : 0 ,
385385 tokens_consumed : 0 ,
386- restrictions : Unrestricted ,
386+ restrictions : UNRESTRICTED ,
387387 quote_depth : 0 ,
388388 obsolete_set : HashSet :: new ( ) ,
389389 mod_path_stack : Vec :: new ( ) ,
@@ -2242,7 +2242,7 @@ impl<'a> Parser<'a> {
22422242 if self . token == token:: LBRACE {
22432243 // This is a struct literal, unless we're prohibited
22442244 // from parsing struct literals here.
2245- if !self . restrictions . contains ( RestrictionNoStructLiteral ) {
2245+ if !self . restrictions . contains ( RESTRICTION_NO_STRUCT_LITERAL ) {
22462246 // It's a struct literal.
22472247 self . bump ( ) ;
22482248 let mut fields = Vec :: new ( ) ;
@@ -2771,7 +2771,7 @@ impl<'a> Parser<'a> {
27712771 // Prevent dynamic borrow errors later on by limiting the
27722772 // scope of the borrows.
27732773 if self . token == token:: BINOP ( token:: OR ) &&
2774- self . restrictions . contains ( RestrictionNoBarOp ) {
2774+ self . restrictions . contains ( RESTRICTION_NO_BAR_OP ) {
27752775 return lhs;
27762776 }
27772777
@@ -2812,7 +2812,7 @@ impl<'a> Parser<'a> {
28122812 pub fn parse_assign_expr ( & mut self ) -> P < Expr > {
28132813 let lo = self . span . lo ;
28142814 let lhs = self . parse_binops ( ) ;
2815- let restrictions = self . restrictions & RestrictionNoStructLiteral ;
2815+ let restrictions = self . restrictions & RESTRICTION_NO_STRUCT_LITERAL ;
28162816 match self . token {
28172817 token:: EQ => {
28182818 self . bump ( ) ;
@@ -2850,7 +2850,7 @@ impl<'a> Parser<'a> {
28502850 return self . parse_if_let_expr ( ) ;
28512851 }
28522852 let lo = self . last_span . lo ;
2853- let cond = self . parse_expr_res ( RestrictionNoStructLiteral ) ;
2853+ let cond = self . parse_expr_res ( RESTRICTION_NO_STRUCT_LITERAL ) ;
28542854 let thn = self . parse_block ( ) ;
28552855 let mut els: Option < P < Expr > > = None ;
28562856 let mut hi = thn. span . hi ;
@@ -2868,7 +2868,7 @@ impl<'a> Parser<'a> {
28682868 self . expect_keyword ( keywords:: Let ) ;
28692869 let pat = self . parse_pat ( ) ;
28702870 self . expect ( & token:: EQ ) ;
2871- let expr = self . parse_expr_res ( RestrictionNoStructLiteral ) ;
2871+ let expr = self . parse_expr_res ( RESTRICTION_NO_STRUCT_LITERAL ) ;
28722872 let thn = self . parse_block ( ) ;
28732873 let ( hi, els) = if self . eat_keyword ( keywords:: Else ) {
28742874 let expr = self . parse_else_expr ( ) ;
@@ -2928,7 +2928,7 @@ impl<'a> Parser<'a> {
29282928 let lo = self . last_span . lo ;
29292929 let pat = self . parse_pat ( ) ;
29302930 self . expect_keyword ( keywords:: In ) ;
2931- let expr = self . parse_expr_res ( RestrictionNoStructLiteral ) ;
2931+ let expr = self . parse_expr_res ( RESTRICTION_NO_STRUCT_LITERAL ) ;
29322932 let loop_block = self . parse_block ( ) ;
29332933 let hi = self . span . hi ;
29342934
@@ -2937,7 +2937,7 @@ impl<'a> Parser<'a> {
29372937
29382938 pub fn parse_while_expr ( & mut self , opt_ident : Option < ast:: Ident > ) -> P < Expr > {
29392939 let lo = self . last_span . lo ;
2940- let cond = self . parse_expr_res ( RestrictionNoStructLiteral ) ;
2940+ let cond = self . parse_expr_res ( RESTRICTION_NO_STRUCT_LITERAL ) ;
29412941 let body = self . parse_block ( ) ;
29422942 let hi = body. span . hi ;
29432943 return self . mk_expr ( lo, hi, ExprWhile ( cond, body, opt_ident) ) ;
@@ -2952,7 +2952,7 @@ impl<'a> Parser<'a> {
29522952
29532953 fn parse_match_expr ( & mut self ) -> P < Expr > {
29542954 let lo = self . last_span . lo ;
2955- let discriminant = self . parse_expr_res ( RestrictionNoStructLiteral ) ;
2955+ let discriminant = self . parse_expr_res ( RESTRICTION_NO_STRUCT_LITERAL ) ;
29562956 self . commit_expr_expecting ( & * discriminant, token:: LBRACE ) ;
29572957 let mut arms: Vec < Arm > = Vec :: new ( ) ;
29582958 while self . token != token:: RBRACE {
@@ -2971,7 +2971,7 @@ impl<'a> Parser<'a> {
29712971 guard = Some ( self . parse_expr ( ) ) ;
29722972 }
29732973 self . expect ( & token:: FAT_ARROW ) ;
2974- let expr = self . parse_expr_res ( RestrictionStmtExpr ) ;
2974+ let expr = self . parse_expr_res ( RESTRICTION_STMT_EXPR ) ;
29752975
29762976 let require_comma =
29772977 !classify:: expr_is_simple_block ( & * expr)
@@ -2993,7 +2993,7 @@ impl<'a> Parser<'a> {
29932993
29942994 /// Parse an expression
29952995 pub fn parse_expr ( & mut self ) -> P < Expr > {
2996- return self . parse_expr_res ( Unrestricted ) ;
2996+ return self . parse_expr_res ( UNRESTRICTED ) ;
29972997 }
29982998
29992999 /// Parse an expression, subject to the given restrictions
@@ -3290,9 +3290,9 @@ impl<'a> Parser<'a> {
32903290 self . look_ahead ( 2 , |t| {
32913291 * t != token:: COMMA && * t != token:: RBRACKET
32923292 } ) {
3293- let start = self . parse_expr_res ( RestrictionNoBarOp ) ;
3293+ let start = self . parse_expr_res ( RESTRICTION_NO_BAR_OP ) ;
32943294 self . eat ( & token:: DOTDOTDOT ) ;
3295- let end = self . parse_expr_res ( RestrictionNoBarOp ) ;
3295+ let end = self . parse_expr_res ( RESTRICTION_NO_BAR_OP ) ;
32963296 pat = PatRange ( start, end) ;
32973297 } else if is_plain_ident ( & self . token ) && !can_be_enum_or_struct {
32983298 let id = self . parse_ident ( ) ;
@@ -3593,7 +3593,7 @@ impl<'a> Parser<'a> {
35933593 }
35943594
35953595 // Remainder are line-expr stmts.
3596- let e = self . parse_expr_res ( RestrictionStmtExpr ) ;
3596+ let e = self . parse_expr_res ( RESTRICTION_STMT_EXPR ) ;
35973597 P ( spanned ( lo, e. span . hi , StmtExpr ( e, ast:: DUMMY_NODE_ID ) ) )
35983598 }
35993599 }
@@ -3602,7 +3602,7 @@ impl<'a> Parser<'a> {
36023602
36033603 /// Is this expression a successfully-parsed statement?
36043604 fn expr_is_complete ( & mut self , e : & Expr ) -> bool {
3605- self . restrictions . contains ( RestrictionStmtExpr ) &&
3605+ self . restrictions . contains ( RESTRICTION_STMT_EXPR ) &&
36063606 !classify:: expr_requires_semi_to_be_stmt ( e)
36073607 }
36083608
0 commit comments