@@ -907,16 +907,7 @@ impl<'a> Parser<'a> {
907907 if self . eat_keyword ( kw:: Return ) {
908908 return self . parse_return_expr ( attrs) ;
909909 } 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) ;
920911 } else if self . eat_keyword ( kw:: Yield ) {
921912 return self . parse_yield_expr ( attrs) ;
922913 } else if self . eat_keyword ( kw:: Let ) {
@@ -1109,6 +1100,21 @@ impl<'a> Parser<'a> {
11091100 self . maybe_recover_from_bad_qpath ( expr, true )
11101101 }
11111102
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+
11121118 /// Parse `"yield" expr?`.
11131119 fn parse_yield_expr ( & mut self , attrs : ThinVec < Attribute > ) -> PResult < ' a , P < Expr > > {
11141120 let lo = self . prev_span ;
0 commit comments