@@ -91,10 +91,10 @@ use std::iter;
91
91
92
92
bitflags ! {
93
93
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
98
98
}
99
99
}
100
100
@@ -383,7 +383,7 @@ impl<'a> Parser<'a> {
383
383
buffer_start : 0 ,
384
384
buffer_end : 0 ,
385
385
tokens_consumed : 0 ,
386
- restrictions : Unrestricted ,
386
+ restrictions : UNRESTRICTED ,
387
387
quote_depth : 0 ,
388
388
obsolete_set : HashSet :: new ( ) ,
389
389
mod_path_stack : Vec :: new ( ) ,
@@ -2242,7 +2242,7 @@ impl<'a> Parser<'a> {
2242
2242
if self . token == token:: LBRACE {
2243
2243
// This is a struct literal, unless we're prohibited
2244
2244
// from parsing struct literals here.
2245
- if !self . restrictions . contains ( RestrictionNoStructLiteral ) {
2245
+ if !self . restrictions . contains ( RESTRICTION_NO_STRUCT_LITERAL ) {
2246
2246
// It's a struct literal.
2247
2247
self . bump ( ) ;
2248
2248
let mut fields = Vec :: new ( ) ;
@@ -2771,7 +2771,7 @@ impl<'a> Parser<'a> {
2771
2771
// Prevent dynamic borrow errors later on by limiting the
2772
2772
// scope of the borrows.
2773
2773
if self . token == token:: BINOP ( token:: OR ) &&
2774
- self . restrictions . contains ( RestrictionNoBarOp ) {
2774
+ self . restrictions . contains ( RESTRICTION_NO_BAR_OP ) {
2775
2775
return lhs;
2776
2776
}
2777
2777
@@ -2812,7 +2812,7 @@ impl<'a> Parser<'a> {
2812
2812
pub fn parse_assign_expr ( & mut self ) -> P < Expr > {
2813
2813
let lo = self . span . lo ;
2814
2814
let lhs = self . parse_binops ( ) ;
2815
- let restrictions = self . restrictions & RestrictionNoStructLiteral ;
2815
+ let restrictions = self . restrictions & RESTRICTION_NO_STRUCT_LITERAL ;
2816
2816
match self . token {
2817
2817
token:: EQ => {
2818
2818
self . bump ( ) ;
@@ -2850,7 +2850,7 @@ impl<'a> Parser<'a> {
2850
2850
return self . parse_if_let_expr ( ) ;
2851
2851
}
2852
2852
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 ) ;
2854
2854
let thn = self . parse_block ( ) ;
2855
2855
let mut els: Option < P < Expr > > = None ;
2856
2856
let mut hi = thn. span . hi ;
@@ -2868,7 +2868,7 @@ impl<'a> Parser<'a> {
2868
2868
self . expect_keyword ( keywords:: Let ) ;
2869
2869
let pat = self . parse_pat ( ) ;
2870
2870
self . expect ( & token:: EQ ) ;
2871
- let expr = self . parse_expr_res ( RestrictionNoStructLiteral ) ;
2871
+ let expr = self . parse_expr_res ( RESTRICTION_NO_STRUCT_LITERAL ) ;
2872
2872
let thn = self . parse_block ( ) ;
2873
2873
let ( hi, els) = if self . eat_keyword ( keywords:: Else ) {
2874
2874
let expr = self . parse_else_expr ( ) ;
@@ -2928,7 +2928,7 @@ impl<'a> Parser<'a> {
2928
2928
let lo = self . last_span . lo ;
2929
2929
let pat = self . parse_pat ( ) ;
2930
2930
self . expect_keyword ( keywords:: In ) ;
2931
- let expr = self . parse_expr_res ( RestrictionNoStructLiteral ) ;
2931
+ let expr = self . parse_expr_res ( RESTRICTION_NO_STRUCT_LITERAL ) ;
2932
2932
let loop_block = self . parse_block ( ) ;
2933
2933
let hi = self . span . hi ;
2934
2934
@@ -2937,7 +2937,7 @@ impl<'a> Parser<'a> {
2937
2937
2938
2938
pub fn parse_while_expr ( & mut self , opt_ident : Option < ast:: Ident > ) -> P < Expr > {
2939
2939
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 ) ;
2941
2941
let body = self . parse_block ( ) ;
2942
2942
let hi = body. span . hi ;
2943
2943
return self . mk_expr ( lo, hi, ExprWhile ( cond, body, opt_ident) ) ;
@@ -2952,7 +2952,7 @@ impl<'a> Parser<'a> {
2952
2952
2953
2953
fn parse_match_expr ( & mut self ) -> P < Expr > {
2954
2954
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 ) ;
2956
2956
self . commit_expr_expecting ( & * discriminant, token:: LBRACE ) ;
2957
2957
let mut arms: Vec < Arm > = Vec :: new ( ) ;
2958
2958
while self . token != token:: RBRACE {
@@ -2971,7 +2971,7 @@ impl<'a> Parser<'a> {
2971
2971
guard = Some ( self . parse_expr ( ) ) ;
2972
2972
}
2973
2973
self . expect ( & token:: FAT_ARROW ) ;
2974
- let expr = self . parse_expr_res ( RestrictionStmtExpr ) ;
2974
+ let expr = self . parse_expr_res ( RESTRICTION_STMT_EXPR ) ;
2975
2975
2976
2976
let require_comma =
2977
2977
!classify:: expr_is_simple_block ( & * expr)
@@ -2993,7 +2993,7 @@ impl<'a> Parser<'a> {
2993
2993
2994
2994
/// Parse an expression
2995
2995
pub fn parse_expr ( & mut self ) -> P < Expr > {
2996
- return self . parse_expr_res ( Unrestricted ) ;
2996
+ return self . parse_expr_res ( UNRESTRICTED ) ;
2997
2997
}
2998
2998
2999
2999
/// Parse an expression, subject to the given restrictions
@@ -3290,9 +3290,9 @@ impl<'a> Parser<'a> {
3290
3290
self . look_ahead ( 2 , |t| {
3291
3291
* t != token:: COMMA && * t != token:: RBRACKET
3292
3292
} ) {
3293
- let start = self . parse_expr_res ( RestrictionNoBarOp ) ;
3293
+ let start = self . parse_expr_res ( RESTRICTION_NO_BAR_OP ) ;
3294
3294
self . eat ( & token:: DOTDOTDOT ) ;
3295
- let end = self . parse_expr_res ( RestrictionNoBarOp ) ;
3295
+ let end = self . parse_expr_res ( RESTRICTION_NO_BAR_OP ) ;
3296
3296
pat = PatRange ( start, end) ;
3297
3297
} else if is_plain_ident ( & self . token ) && !can_be_enum_or_struct {
3298
3298
let id = self . parse_ident ( ) ;
@@ -3593,7 +3593,7 @@ impl<'a> Parser<'a> {
3593
3593
}
3594
3594
3595
3595
// Remainder are line-expr stmts.
3596
- let e = self . parse_expr_res ( RestrictionStmtExpr ) ;
3596
+ let e = self . parse_expr_res ( RESTRICTION_STMT_EXPR ) ;
3597
3597
P ( spanned ( lo, e. span . hi , StmtExpr ( e, ast:: DUMMY_NODE_ID ) ) )
3598
3598
}
3599
3599
}
@@ -3602,7 +3602,7 @@ impl<'a> Parser<'a> {
3602
3602
3603
3603
/// Is this expression a successfully-parsed statement?
3604
3604
fn expr_is_complete ( & mut self , e : & Expr ) -> bool {
3605
- self . restrictions . contains ( RestrictionStmtExpr ) &&
3605
+ self . restrictions . contains ( RESTRICTION_STMT_EXPR ) &&
3606
3606
!classify:: expr_requires_semi_to_be_stmt ( e)
3607
3607
}
3608
3608
0 commit comments