@@ -245,11 +245,7 @@ impl<'a> Parser<'a> {
245
245
this. parse_assoc_expr_with ( prec + prec_adjustment, LhsExpr :: NotYetParsed )
246
246
} ) ?;
247
247
248
- // Make sure that the span of the parent node is larger than the span of lhs and rhs,
249
- // including the attributes.
250
- let lhs_span =
251
- lhs. attrs . iter ( ) . find ( |a| a. style == AttrStyle :: Outer ) . map_or ( lhs_span, |a| a. span ) ;
252
- let span = lhs_span. to ( rhs. span ) ;
248
+ let span = self . mk_expr_sp ( & lhs, lhs_span, rhs. span ) ;
253
249
lhs = match op {
254
250
AssocOp :: Add
255
251
| AssocOp :: Subtract
@@ -570,7 +566,11 @@ impl<'a> Parser<'a> {
570
566
expr_kind : fn ( P < Expr > , P < Ty > ) -> ExprKind ,
571
567
) -> PResult < ' a , P < Expr > > {
572
568
let mk_expr = |this : & mut Self , rhs : P < Ty > | {
573
- this. mk_expr ( lhs_span. to ( rhs. span ) , expr_kind ( lhs, rhs) , AttrVec :: new ( ) )
569
+ this. mk_expr (
570
+ this. mk_expr_sp ( & lhs, lhs_span, rhs. span ) ,
571
+ expr_kind ( lhs, rhs) ,
572
+ AttrVec :: new ( ) ,
573
+ )
574
574
} ;
575
575
576
576
// Save the state of the parser before parsing type normally, in case there is a
@@ -2298,4 +2298,14 @@ impl<'a> Parser<'a> {
2298
2298
pub ( super ) fn mk_expr_err ( & self , span : Span ) -> P < Expr > {
2299
2299
self . mk_expr ( span, ExprKind :: Err , AttrVec :: new ( ) )
2300
2300
}
2301
+
2302
+ /// Create expression span ensuring the span of the parent node
2303
+ /// is larger than the span of lhs and rhs, including the attributes.
2304
+ fn mk_expr_sp ( & self , lhs : & P < Expr > , lhs_span : Span , rhs_span : Span ) -> Span {
2305
+ lhs. attrs
2306
+ . iter ( )
2307
+ . find ( |a| a. style == AttrStyle :: Outer )
2308
+ . map_or ( lhs_span, |a| a. span )
2309
+ . to ( rhs_span)
2310
+ }
2301
2311
}
0 commit comments