@@ -249,10 +249,11 @@ impl<'a> Parser<'a> {
249
249
continue ;
250
250
}
251
251
252
+ let op_span = op. span ;
252
253
let op = op. node ;
253
254
// Special cases:
254
255
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 ) ?;
256
257
continue ;
257
258
} else if op == AssocOp :: DotDot || op == AssocOp :: DotDotEq {
258
259
// If we didn't have to handle `x..`/`x..=`, it would be pretty easy to
@@ -274,7 +275,7 @@ impl<'a> Parser<'a> {
274
275
this. parse_expr_assoc_with ( prec + prec_adjustment, LhsExpr :: Unparsed { attrs } )
275
276
} ) ?;
276
277
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 ) ;
278
279
lhs = match op {
279
280
AssocOp :: Add
280
281
| AssocOp :: Subtract
@@ -453,7 +454,7 @@ impl<'a> Parser<'a> {
453
454
None
454
455
} ;
455
456
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) ;
457
458
let limits =
458
459
if op == AssocOp :: DotDot { RangeLimits :: HalfOpen } else { RangeLimits :: Closed } ;
459
460
let range = self . mk_range ( Some ( lhs) , rhs, limits) ;
@@ -674,10 +675,11 @@ impl<'a> Parser<'a> {
674
675
& mut self ,
675
676
lhs : P < Expr > ,
676
677
lhs_span : Span ,
678
+ op_span : Span ,
677
679
expr_kind : fn ( P < Expr > , P < Ty > ) -> ExprKind ,
678
680
) -> PResult < ' a , P < Expr > > {
679
681
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) )
681
683
} ;
682
684
683
685
// Save the state of the parser before parsing type normally, in case there is a
@@ -3852,11 +3854,13 @@ impl<'a> Parser<'a> {
3852
3854
3853
3855
/// Create expression span ensuring the span of the parent node
3854
3856
/// 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 {
3856
3858
lhs. attrs
3857
3859
. iter ( )
3858
3860
. find ( |a| a. style == AttrStyle :: Outer )
3859
3861
. map_or ( lhs_span, |a| a. span )
3862
+ // An approximation to #126763.
3863
+ . to ( op_span)
3860
3864
. to ( rhs_span)
3861
3865
}
3862
3866
0 commit comments