@@ -1069,24 +1069,22 @@ impl<'a> Parser<'a> {
1069
1069
1070
1070
fn parse_labeled_expr ( & mut self , label : Label , attrs : AttrVec ) -> PResult < ' a , P < Expr > > {
1071
1071
let lo = label. ident . span ;
1072
+ let label = Some ( label) ;
1072
1073
self . expect ( & token:: Colon ) ?;
1073
1074
if self . eat_keyword ( kw:: While ) {
1074
- return self . parse_while_expr ( Some ( label) , lo, attrs) ;
1075
- }
1076
- if self . eat_keyword ( kw:: For ) {
1077
- return self . parse_for_expr ( Some ( label) , lo, attrs) ;
1078
- }
1079
- if self . eat_keyword ( kw:: Loop ) {
1080
- return self . parse_loop_expr ( Some ( label) , lo, attrs) ;
1081
- }
1082
- if self . token == token:: OpenDelim ( token:: Brace ) {
1083
- return self . parse_block_expr ( Some ( label) , lo, BlockCheckMode :: Default , attrs) ;
1075
+ self . parse_while_expr ( label, lo, attrs)
1076
+ } else if self . eat_keyword ( kw:: For ) {
1077
+ self . parse_for_expr ( label, lo, attrs)
1078
+ } else if self . eat_keyword ( kw:: Loop ) {
1079
+ self . parse_loop_expr ( label, lo, attrs)
1080
+ } else if self . check ( & token:: OpenDelim ( token:: Brace ) ) {
1081
+ self . parse_block_expr ( label, lo, BlockCheckMode :: Default , attrs)
1082
+ } else {
1083
+ let msg = "expected `while`, `for`, `loop` or `{` after a label" ;
1084
+ self . struct_span_err ( self . token . span , msg) . span_label ( self . token . span , msg) . emit ( ) ;
1085
+ // Continue as an expression in an effort to recover on `'label: non_block_expr`.
1086
+ self . parse_expr ( )
1084
1087
}
1085
-
1086
- let msg = "expected `while`, `for`, `loop` or `{` after a label" ;
1087
- self . struct_span_err ( self . token . span , msg) . span_label ( self . token . span , msg) . emit ( ) ;
1088
- // Continue as an expression in an effort to recover on `'label: non_block_expr`.
1089
- self . parse_expr ( )
1090
1088
}
1091
1089
1092
1090
/// Recover on the syntax `do catch { ... }` suggesting `try { ... }` instead.
0 commit comments