about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-12-19 04:39:18 +0000
committerbors <bors@rust-lang.org>2016-12-19 04:39:18 +0000
commitcc662efca1e2a070887839a935c3d14de4991526 (patch)
tree8b094e169569fea3b343bc252e44430d3e5e2415 /src/libsyntax
parent0102127963098b7656f0213206908d6597018d5f (diff)
parent0ddf61890bc68409b8e72352a83520940c228b29 (diff)
downloadrust-cc662efca1e2a070887839a935c3d14de4991526.tar.gz
rust-cc662efca1e2a070887839a935c3d14de4991526.zip
Auto merge of #38194 - sgrif:sg-no-span-mangling, r=nrc
Don't perform span mangling when building field/tup access nodes

There are no guarantees that the two spans used to create the new one
come from the same place or are even valid.

Fixes #36081.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/build.rs18
1 files changed, 3 insertions, 15 deletions
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs
index a208b934d79..6c0d40b69d3 100644
--- a/src/libsyntax/ext/build.rs
+++ b/src/libsyntax/ext/build.rs
@@ -11,7 +11,7 @@
 use abi::Abi;
 use ast::{self, Ident, Generics, Expr, BlockCheckMode, UnOp, PatKind};
 use attr;
-use syntax_pos::{Span, DUMMY_SP, Pos};
+use syntax_pos::{Span, DUMMY_SP};
 use codemap::{dummy_spanned, respan, Spanned};
 use ext::base::ExtCtxt;
 use ptr::P;
@@ -659,23 +659,11 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
     }
 
     fn expr_field_access(&self, sp: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr> {
-        let field_span = Span {
-            lo: sp.lo - Pos::from_usize(ident.name.as_str().len()),
-            hi: sp.hi,
-            expn_id: sp.expn_id,
-        };
-
-        let id = Spanned { node: ident, span: field_span };
+        let id = Spanned { node: ident, span: sp };
         self.expr(sp, ast::ExprKind::Field(expr, id))
     }
     fn expr_tup_field_access(&self, sp: Span, expr: P<ast::Expr>, idx: usize) -> P<ast::Expr> {
-        let field_span = Span {
-            lo: sp.lo - Pos::from_usize(idx.to_string().len()),
-            hi: sp.hi,
-            expn_id: sp.expn_id,
-        };
-
-        let id = Spanned { node: idx, span: field_span };
+        let id = Spanned { node: idx, span: sp };
         self.expr(sp, ast::ExprKind::TupField(expr, id))
     }
     fn expr_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {