From 9851a296885cc745eccbc33858915d08e839eadc Mon Sep 17 00:00:00 2001 From: topecongiro Date: Mon, 4 Feb 2019 00:35:12 +0900 Subject: [PATCH] Add the span of attributes of the lhs to the span of the assignment expression --- src/libsyntax/parse/parser.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 514b2952c5036..1c02a80df4683 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3455,6 +3455,14 @@ impl<'a> Parser<'a> { }), }?; + // Make sure that the span of the parent node is larger than the span of lhs and rhs, + // including the attributes. + let lhs_span = lhs + .attrs + .iter() + .filter(|a| a.style == AttrStyle::Outer) + .next() + .map_or(lhs_span, |a| a.span); let span = lhs_span.to(rhs.span); lhs = match op { AssocOp::Add | AssocOp::Subtract | AssocOp::Multiply | AssocOp::Divide |