@@ -2727,37 +2727,41 @@ impl<'a> Parser<'a> {
2727
2727
self . commit_expr_expecting ( discriminant, token:: LBRACE ) ;
2728
2728
let mut arms: Vec < Arm > = Vec :: new ( ) ;
2729
2729
while self . token != token:: RBRACE {
2730
- let attrs = self . parse_outer_attributes ( ) ;
2731
- let pats = self . parse_pats ( ) ;
2732
- let mut guard = None ;
2733
- if self . eat_keyword ( keywords:: If ) {
2734
- guard = Some ( self . parse_expr ( ) ) ;
2735
- }
2736
- self . expect ( & token:: FAT_ARROW ) ;
2737
- let expr = self . parse_expr_res ( RESTRICT_STMT_EXPR ) ;
2738
-
2739
- let require_comma =
2740
- !classify:: expr_is_simple_block ( expr)
2741
- && self . token != token:: RBRACE ;
2742
-
2743
- if require_comma {
2744
- self . commit_expr ( expr, & [ token:: COMMA ] , & [ token:: RBRACE ] ) ;
2745
- } else {
2746
- self . eat ( & token:: COMMA ) ;
2747
- }
2748
-
2749
- arms. push ( ast:: Arm {
2750
- attrs : attrs,
2751
- pats : pats,
2752
- guard : guard,
2753
- body : expr
2754
- } ) ;
2730
+ arms. push ( self . parse_arm ( ) ) ;
2755
2731
}
2756
2732
let hi = self . span . hi ;
2757
2733
self . bump ( ) ;
2758
2734
return self . mk_expr ( lo, hi, ExprMatch ( discriminant, arms) ) ;
2759
2735
}
2760
2736
2737
+ pub fn parse_arm ( & mut self ) -> Arm {
2738
+ let attrs = self . parse_outer_attributes ( ) ;
2739
+ let pats = self . parse_pats ( ) ;
2740
+ let mut guard = None ;
2741
+ if self . eat_keyword ( keywords:: If ) {
2742
+ guard = Some ( self . parse_expr ( ) ) ;
2743
+ }
2744
+ self . expect ( & token:: FAT_ARROW ) ;
2745
+ let expr = self . parse_expr_res ( RESTRICT_STMT_EXPR ) ;
2746
+
2747
+ let require_comma =
2748
+ !classify:: expr_is_simple_block ( expr)
2749
+ && self . token != token:: RBRACE ;
2750
+
2751
+ if require_comma {
2752
+ self . commit_expr ( expr, & [ token:: COMMA ] , & [ token:: RBRACE ] ) ;
2753
+ } else {
2754
+ self . eat ( & token:: COMMA ) ;
2755
+ }
2756
+
2757
+ ast:: Arm {
2758
+ attrs : attrs,
2759
+ pats : pats,
2760
+ guard : guard,
2761
+ body : expr,
2762
+ }
2763
+ }
2764
+
2761
2765
/// Parse an expression
2762
2766
pub fn parse_expr ( & mut self ) -> Gc < Expr > {
2763
2767
return self . parse_expr_res ( UNRESTRICTED ) ;
0 commit comments