@@ -2130,7 +2130,7 @@ impl<'a> Parser<'a> {
21302130 return self . parse_lambda_expr ( lo, CaptureBy :: Value , attrs) ;
21312131 }
21322132 if self . eat_keyword ( keywords:: If ) {
2133- return self . parse_if_expr ( attrs, false ) ;
2133+ return self . parse_if_expr ( attrs) ;
21342134 }
21352135 if self . eat_keyword ( keywords:: For ) {
21362136 let lo = self . prev_span ;
@@ -2962,25 +2962,20 @@ impl<'a> Parser<'a> {
29622962 }
29632963
29642964 /// Parse an 'if' or 'if let' expression ('if' token already eaten)
2965- pub fn parse_if_expr ( & mut self , attrs : ThinVec < Attribute > ,
2966- in_else : bool ) -> PResult < ' a , P < Expr > > {
2965+ pub fn parse_if_expr ( & mut self , attrs : ThinVec < Attribute > ) -> PResult < ' a , P < Expr > > {
29672966 if self . check_keyword ( keywords:: Let ) {
29682967 return self . parse_if_let_expr ( attrs) ;
29692968 }
29702969 let lo = self . prev_span ;
29712970 let cond = self . parse_expr_res ( RESTRICTION_NO_STRUCT_LITERAL , None ) ?;
2972- let thn = self . parse_block ( ) . map_err ( |mut err| {
2973- if in_else {
2974- err. cancel ( ) ;
2975- let sp = lo. next_point ( ) ;
2976- let mut err = self . diagnostic ( )
2977- . struct_span_err ( sp, "missing condition for `if` statemement" ) ;
2978- err. span_label ( sp, "expected if condition here" ) ;
2979- err
2980- } else {
2981- err
2982- }
2983- } ) ?;
2971+ if self . eat_keyword ( keywords:: Else ) {
2972+ let sp = lo. next_point ( ) ;
2973+ let mut err = self . diagnostic ( )
2974+ . struct_span_err ( sp, "missing condition for `if` statemement" ) ;
2975+ err. span_label ( sp, "expected if condition here" ) ;
2976+ return Err ( err)
2977+ }
2978+ let thn = self . parse_block ( ) ?;
29842979 let mut els: Option < P < Expr > > = None ;
29852980 let mut hi = thn. span ;
29862981 if self . eat_keyword ( keywords:: Else ) {
@@ -3037,7 +3032,7 @@ impl<'a> Parser<'a> {
30373032 // `else` token already eaten
30383033 pub fn parse_else_expr ( & mut self ) -> PResult < ' a , P < Expr > > {
30393034 if self . eat_keyword ( keywords:: If ) {
3040- return self . parse_if_expr ( ThinVec :: new ( ) , true ) ;
3035+ return self . parse_if_expr ( ThinVec :: new ( ) ) ;
30413036 } else {
30423037 let blk = self . parse_block ( ) ?;
30433038 return Ok ( self . mk_expr ( blk. span , ExprKind :: Block ( blk) , ThinVec :: new ( ) ) ) ;
0 commit comments