@@ -628,10 +628,10 @@ impl<'a> Parser<'a> {
628628 }
629629 _ => {
630630 Err ( if self . prev_token_kind == PrevTokenKind :: DocComment {
631- self . span_fatal_err ( self . prev_span , Error :: UselessDocComment )
632- } else {
633- self . expected_ident_found ( )
634- } )
631+ self . span_fatal_err ( self . prev_span , Error :: UselessDocComment )
632+ } else {
633+ self . expected_ident_found ( )
634+ } )
635635 }
636636 }
637637 }
@@ -1657,8 +1657,8 @@ impl<'a> Parser<'a> {
16571657 path = self . parse_path ( PathStyle :: Type ) ?;
16581658 path_span = path_lo. to ( self . prev_span ) ;
16591659 } else {
1660- path = ast:: Path { segments : Vec :: new ( ) , span : DUMMY_SP } ;
16611660 path_span = self . span . to ( self . span ) ;
1661+ path = ast:: Path { segments : Vec :: new ( ) , span : path_span } ;
16621662 }
16631663
16641664 // See doc comment for `unmatched_angle_bracket_count`.
@@ -2844,7 +2844,11 @@ impl<'a> Parser<'a> {
28442844 // want to keep their span info to improve diagnostics in these cases in a later stage.
28452845 ( true , Some ( AssocOp :: Multiply ) ) | // `{ 42 } *foo = bar;` or `{ 42 } * 3`
28462846 ( true , Some ( AssocOp :: Subtract ) ) | // `{ 42 } -5`
2847- ( true , Some ( AssocOp :: Add ) ) => { // `{ 42 } + 42
2847+ ( true , Some ( AssocOp :: LAnd ) ) | // `{ 42 } &&x` (#61475)
2848+ ( true , Some ( AssocOp :: Add ) ) // `{ 42 } + 42
2849+ // If the next token is a keyword, then the tokens above *are* unambiguously incorrect:
2850+ // `if x { a } else { b } && if y { c } else { d }`
2851+ if !self . look_ahead ( 1 , |t| t. is_reserved_ident ( ) ) => {
28482852 // These cases are ambiguous and can't be identified in the parser alone
28492853 let sp = self . sess . source_map ( ) . start_point ( self . span ) ;
28502854 self . sess . ambiguous_block_expr_parse . borrow_mut ( ) . insert ( sp, lhs. span ) ;
@@ -5298,7 +5302,7 @@ impl<'a> Parser<'a> {
52985302 let mut where_clause = WhereClause {
52995303 id : ast:: DUMMY_NODE_ID ,
53005304 predicates : Vec :: new ( ) ,
5301- span : DUMMY_SP ,
5305+ span : self . prev_span . to ( self . prev_span ) ,
53025306 } ;
53035307
53045308 if !self . eat_keyword ( kw:: Where ) {
0 commit comments