@@ -2928,7 +2928,7 @@ impl<'a> Parser<'a> {
2928
2928
self . this_token_descr( ) ) ;
2929
2929
let mut err = self . fatal ( & msg) ;
2930
2930
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 ( )
2932
2932
. get ( & sp)
2933
2933
{
2934
2934
self . sess . expr_parentheses_needed ( & mut err, * sp, None ) ;
@@ -3630,12 +3630,15 @@ impl<'a> Parser<'a> {
3630
3630
return Ok ( lhs) ;
3631
3631
}
3632
3632
( 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`
3634
3637
( true , Some ( AssocOp :: Subtract ) ) | // `{ 42 } -5`
3635
3638
( true , Some ( AssocOp :: Add ) ) => { // `{ 42 } + 42
3636
3639
// These cases are ambiguous and can't be identified in the parser alone
3637
3640
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 ) ;
3639
3642
return Ok ( lhs) ;
3640
3643
}
3641
3644
( true , Some ( ref op) ) if !op. can_continue_expr_unambiguously ( ) => {
@@ -4968,7 +4971,7 @@ impl<'a> Parser<'a> {
4968
4971
let mut err = self . fatal ( & msg) ;
4969
4972
err. span_label ( self . span , format ! ( "expected {}" , expected) ) ;
4970
4973
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) {
4972
4975
self . sess . expr_parentheses_needed ( & mut err, * sp, None ) ;
4973
4976
}
4974
4977
return Err ( err) ;
0 commit comments