提交 cc662efc 编写于 作者: B bors

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.
......@@ -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 @@ fn expr_unary(&self, sp: Span, op: ast::UnOp, e: P<ast::Expr>) -> P<ast::Expr> {
}
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> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册