@@ -2928,7 +2928,7 @@ impl<'a> Parser<'a> {
29282928 self . this_token_descr( ) ) ;
29292929 let mut err = self . fatal ( & msg) ;
29302930 let sp = self . sess . source_map ( ) . start_point ( self . span ) ;
2931- if let Some ( sp) = self . sess . abiguous_block_expr_parse . borrow ( )
2931+ if let Some ( sp) = self . sess . ambiguous_block_expr_parse . borrow ( )
29322932 . get ( & sp)
29332933 {
29342934 self . sess . expr_parentheses_needed ( & mut err, * sp, None ) ;
@@ -3630,12 +3630,15 @@ impl<'a> Parser<'a> {
36303630 return Ok ( lhs) ;
36313631 }
36323632 ( false , _) => { } // continue parsing the expression
3633- ( true , Some ( AssocOp :: Multiply ) ) | // `{ 42 } *foo = bar;`
3633+ // An exhaustive check is done in the following block, but these are checked first
3634+ // because they *are* ambiguous but also reasonable looking incorrect syntax, so we
3635+ // want to keep their span info to improve diagnostics in these cases in a later stage.
3636+ ( true , Some ( AssocOp :: Multiply ) ) | // `{ 42 } *foo = bar;` or `{ 42 } * 3`
36343637 ( true , Some ( AssocOp :: Subtract ) ) | // `{ 42 } -5`
36353638 ( true , Some ( AssocOp :: Add ) ) => { // `{ 42 } + 42
36363639 // These cases are ambiguous and can't be identified in the parser alone
36373640 let sp = self . sess . source_map ( ) . start_point ( self . span ) ;
3638- self . sess . abiguous_block_expr_parse . borrow_mut ( ) . insert ( sp, lhs. span ) ;
3641+ self . sess . ambiguous_block_expr_parse . borrow_mut ( ) . insert ( sp, lhs. span ) ;
36393642 return Ok ( lhs) ;
36403643 }
36413644 ( true , Some ( ref op) ) if !op. can_continue_expr_unambiguously ( ) => {
@@ -4968,7 +4971,7 @@ impl<'a> Parser<'a> {
49684971 let mut err = self . fatal ( & msg) ;
49694972 err. span_label ( self . span , format ! ( "expected {}" , expected) ) ;
49704973 let sp = self . sess . source_map ( ) . start_point ( self . span ) ;
4971- if let Some ( sp) = self . sess . abiguous_block_expr_parse . borrow ( ) . get ( & sp) {
4974+ if let Some ( sp) = self . sess . ambiguous_block_expr_parse . borrow ( ) . get ( & sp) {
49724975 self . sess . expr_parentheses_needed ( & mut err, * sp, None ) ;
49734976 }
49744977 return Err ( err) ;
0 commit comments