@@ -249,10 +249,11 @@ impl<'a> Parser<'a> {
249249 continue ;
250250 }
251251
252+ let op_span = op. span ;
252253 let op = op. node ;
253254 // Special cases:
254255 if op == AssocOp :: As {
255- lhs = self . parse_assoc_op_cast ( lhs, lhs_span, ExprKind :: Cast ) ?;
256+ lhs = self . parse_assoc_op_cast ( lhs, lhs_span, op_span , ExprKind :: Cast ) ?;
256257 continue ;
257258 } else if op == AssocOp :: DotDot || op == AssocOp :: DotDotEq {
258259 // If we didn't have to handle `x..`/`x..=`, it would be pretty easy to
@@ -274,7 +275,7 @@ impl<'a> Parser<'a> {
274275 this. parse_expr_assoc_with ( prec + prec_adjustment, LhsExpr :: Unparsed { attrs } )
275276 } ) ?;
276277
277- let span = self . mk_expr_sp ( & lhs, lhs_span, rhs. span ) ;
278+ let span = self . mk_expr_sp ( & lhs, lhs_span, op_span , rhs. span ) ;
278279 lhs = match op {
279280 AssocOp :: Add
280281 | AssocOp :: Subtract
@@ -453,7 +454,7 @@ impl<'a> Parser<'a> {
453454 None
454455 } ;
455456 let rhs_span = rhs. as_ref ( ) . map_or ( cur_op_span, |x| x. span ) ;
456- let span = self . mk_expr_sp ( & lhs, lhs. span , rhs_span) ;
457+ let span = self . mk_expr_sp ( & lhs, lhs. span , cur_op_span , rhs_span) ;
457458 let limits =
458459 if op == AssocOp :: DotDot { RangeLimits :: HalfOpen } else { RangeLimits :: Closed } ;
459460 let range = self . mk_range ( Some ( lhs) , rhs, limits) ;
@@ -674,10 +675,11 @@ impl<'a> Parser<'a> {
674675 & mut self ,
675676 lhs : P < Expr > ,
676677 lhs_span : Span ,
678+ op_span : Span ,
677679 expr_kind : fn ( P < Expr > , P < Ty > ) -> ExprKind ,
678680 ) -> PResult < ' a , P < Expr > > {
679681 let mk_expr = |this : & mut Self , lhs : P < Expr > , rhs : P < Ty > | {
680- this. mk_expr ( this. mk_expr_sp ( & lhs, lhs_span, rhs. span ) , expr_kind ( lhs, rhs) )
682+ this. mk_expr ( this. mk_expr_sp ( & lhs, lhs_span, op_span , rhs. span ) , expr_kind ( lhs, rhs) )
681683 } ;
682684
683685 // Save the state of the parser before parsing type normally, in case there is a
@@ -3852,11 +3854,13 @@ impl<'a> Parser<'a> {
38523854
38533855 /// Create expression span ensuring the span of the parent node
38543856 /// is larger than the span of lhs and rhs, including the attributes.
3855- fn mk_expr_sp ( & self , lhs : & P < Expr > , lhs_span : Span , rhs_span : Span ) -> Span {
3857+ fn mk_expr_sp ( & self , lhs : & P < Expr > , lhs_span : Span , op_span : Span , rhs_span : Span ) -> Span {
38563858 lhs. attrs
38573859 . iter ( )
38583860 . find ( |a| a. style == AttrStyle :: Outer )
38593861 . map_or ( lhs_span, |a| a. span )
3862+ // An approximation to #126763.
3863+ . to ( op_span)
38603864 . to ( rhs_span)
38613865 }
38623866
0 commit comments