about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authortopecongiro <seuchida@gmail.com>2019-02-04 00:35:12 +0900
committertopecongiro <seuchida@gmail.com>2019-02-04 00:35:12 +0900
commit9851a296885cc745eccbc33858915d08e839eadc (patch)
treebd4b61c23bcf0c4e3a295e88f4e9e28c93781243 /src/libsyntax/parse
parentec7ecb3076260256ae7e43f6991ecc1566c73708 (diff)
downloadrust-9851a296885cc745eccbc33858915d08e839eadc.tar.gz
rust-9851a296885cc745eccbc33858915d08e839eadc.zip
Add the span of attributes of the lhs to the span of the assignment expression
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 514b2952c50..1c02a80df46 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 |