@@ -907,16 +907,7 @@ impl<'a> Parser<'a> {
907
907
if self . eat_keyword ( kw:: Return ) {
908
908
return self . parse_return_expr ( attrs) ;
909
909
} else if self . eat_keyword ( kw:: Break ) {
910
- let label = self . eat_label ( ) ;
911
- let e = if self . token . can_begin_expr ( )
912
- && !( self . token == token:: OpenDelim ( token:: Brace )
913
- && self . restrictions . contains (
914
- Restrictions :: NO_STRUCT_LITERAL ) ) {
915
- Some ( self . parse_expr ( ) ?)
916
- } else {
917
- None
918
- } ;
919
- ( self . prev_span , ExprKind :: Break ( label, e) )
910
+ return self . parse_break_expr ( attrs) ;
920
911
} else if self . eat_keyword ( kw:: Yield ) {
921
912
return self . parse_yield_expr ( attrs) ;
922
913
} else if self . eat_keyword ( kw:: Let ) {
@@ -1109,6 +1100,21 @@ impl<'a> Parser<'a> {
1109
1100
self . maybe_recover_from_bad_qpath ( expr, true )
1110
1101
}
1111
1102
1103
+ /// Parse `"('label ":")? break expr?`.
1104
+ fn parse_break_expr ( & mut self , attrs : ThinVec < Attribute > ) -> PResult < ' a , P < Expr > > {
1105
+ let lo = self . prev_span ;
1106
+ let label = self . eat_label ( ) ;
1107
+ let kind = if self . token != token:: OpenDelim ( token:: Brace )
1108
+ || !self . restrictions . contains ( Restrictions :: NO_STRUCT_LITERAL )
1109
+ {
1110
+ self . parse_expr_opt ( ) ?
1111
+ } else {
1112
+ None
1113
+ } ;
1114
+ let expr = self . mk_expr ( lo. to ( self . prev_span ) , ExprKind :: Break ( label, kind) , attrs) ;
1115
+ self . maybe_recover_from_bad_qpath ( expr, true )
1116
+ }
1117
+
1112
1118
/// Parse `"yield" expr?`.
1113
1119
fn parse_yield_expr ( & mut self , attrs : ThinVec < Attribute > ) -> PResult < ' a , P < Expr > > {
1114
1120
let lo = self . prev_span ;
0 commit comments