Use Span::apply_mark
where possible
This commit is contained in:
parent
e2afefd80b
commit
43ad972318
9 changed files with 14 additions and 14 deletions
|
@ -897,7 +897,7 @@ pub fn expr_to_spanned_string(cx: &mut ExtCtxt, expr: P<ast::Expr>, err_msg: &st
|
|||
-> Option<Spanned<(Symbol, ast::StrStyle)>> {
|
||||
// Update `expr.span`'s ctxt now in case expr is an `include!` macro invocation.
|
||||
let expr = expr.map(|mut expr| {
|
||||
expr.span = expr.span.with_ctxt(expr.span.ctxt().apply_mark(cx.current_expansion.mark));
|
||||
expr.span = expr.span.apply_mark(cx.current_expansion.mark);
|
||||
expr
|
||||
});
|
||||
|
||||
|
|
|
@ -1383,7 +1383,7 @@ impl Folder for Marker {
|
|||
}
|
||||
|
||||
fn new_span(&mut self, span: Span) -> Span {
|
||||
span.with_ctxt(span.ctxt().apply_mark(self.0))
|
||||
span.apply_mark(self.0)
|
||||
}
|
||||
|
||||
fn fold_mac(&mut self, mac: ast::Mac) -> ast::Mac {
|
||||
|
|
|
@ -156,7 +156,7 @@ pub fn transcribe(cx: &ExtCtxt,
|
|||
if let NtTT(ref tt) = **nt {
|
||||
result.push(tt.clone().into());
|
||||
} else {
|
||||
sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
|
||||
sp = sp.apply_mark(cx.current_expansion.mark);
|
||||
let token = TokenTree::Token(sp, Token::interpolated((**nt).clone()));
|
||||
result.push(token.into());
|
||||
}
|
||||
|
@ -167,13 +167,13 @@ pub fn transcribe(cx: &ExtCtxt,
|
|||
} else {
|
||||
let ident =
|
||||
Ident::new(ident.name, ident.span.apply_mark(cx.current_expansion.mark));
|
||||
sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
|
||||
sp = sp.apply_mark(cx.current_expansion.mark);
|
||||
result.push(TokenTree::Token(sp, token::Dollar).into());
|
||||
result.push(TokenTree::Token(sp, token::Token::from_ast_ident(ident)).into());
|
||||
}
|
||||
}
|
||||
quoted::TokenTree::Delimited(mut span, delimited) => {
|
||||
span = span.with_ctxt(span.ctxt().apply_mark(cx.current_expansion.mark));
|
||||
span = span.apply_mark(cx.current_expansion.mark);
|
||||
stack.push(Frame::Delimited { forest: delimited, idx: 0, span: span });
|
||||
result_stack.push(mem::replace(&mut result, Vec::new()));
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ pub fn expand_assert<'cx>(
|
|||
None
|
||||
};
|
||||
|
||||
let sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
|
||||
let sp = sp.apply_mark(cx.current_expansion.mark);
|
||||
let panic_call = Mac_ {
|
||||
path: Path::from_ident(sp, Ident::from_str("panic")),
|
||||
tts: if let Some(ts) = custom_msg_args {
|
||||
|
|
|
@ -24,7 +24,7 @@ pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
|
|||
sp: Span,
|
||||
tts: &[tokenstream::TokenTree])
|
||||
-> Box<base::MacResult + 'static> {
|
||||
let sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
|
||||
let sp = sp.apply_mark(cx.current_expansion.mark);
|
||||
let mut p = cx.new_parser_from_tts(tts);
|
||||
let cfg = panictry!(p.parse_meta_item());
|
||||
|
||||
|
|
|
@ -57,6 +57,6 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
|
|||
}
|
||||
}
|
||||
}
|
||||
let sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
|
||||
let sp = sp.apply_mark(cx.current_expansion.mark);
|
||||
base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&accumulator)))
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt,
|
|||
Some(v) => v,
|
||||
};
|
||||
|
||||
let sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
|
||||
let sp = sp.apply_mark(cx.current_expansion.mark);
|
||||
let e = match env::var(&*var.as_str()) {
|
||||
Err(..) => {
|
||||
let lt = cx.lifetime(sp, keywords::StaticLifetime.ident());
|
||||
|
|
|
@ -641,7 +641,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
|||
ty: &ArgumentType,
|
||||
arg: ast::Ident)
|
||||
-> P<ast::Expr> {
|
||||
sp = sp.with_ctxt(sp.ctxt().apply_mark(ecx.current_expansion.mark));
|
||||
sp = sp.apply_mark(ecx.current_expansion.mark);
|
||||
let arg = ecx.expr_ident(sp, arg);
|
||||
let trait_ = match *ty {
|
||||
Placeholder(ref tyname) => {
|
||||
|
@ -678,7 +678,7 @@ pub fn expand_format_args<'cx>(ecx: &'cx mut ExtCtxt,
|
|||
mut sp: Span,
|
||||
tts: &[tokenstream::TokenTree])
|
||||
-> Box<base::MacResult + 'cx> {
|
||||
sp = sp.with_ctxt(sp.ctxt().apply_mark(ecx.current_expansion.mark));
|
||||
sp = sp.apply_mark(ecx.current_expansion.mark);
|
||||
match parse_args(ecx, sp, tts) {
|
||||
Some((efmt, args, names)) => {
|
||||
MacEager::expr(expand_preparsed_format_args(ecx, sp, efmt, args, names))
|
||||
|
@ -700,7 +700,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt,
|
|||
let arg_types: Vec<_> = (0..args.len()).map(|_| Vec::new()).collect();
|
||||
let arg_unique_types: Vec<_> = (0..args.len()).map(|_| Vec::new()).collect();
|
||||
let mut macsp = ecx.call_site();
|
||||
macsp = macsp.with_ctxt(macsp.ctxt().apply_mark(ecx.current_expansion.mark));
|
||||
macsp = macsp.apply_mark(ecx.current_expansion.mark);
|
||||
let msg = "format argument must be a string literal.";
|
||||
let fmt = match expr_to_spanned_string(ecx, efmt, msg) {
|
||||
Some(fmt) => fmt,
|
||||
|
|
|
@ -18,7 +18,7 @@ use syntax::codemap::{ExpnInfo, NameAndSpan, MacroAttribute, respan};
|
|||
use syntax::ext::base::ExtCtxt;
|
||||
use syntax::ext::build::AstBuilder;
|
||||
use syntax::ext::expand::ExpansionConfig;
|
||||
use syntax::ext::hygiene::{Mark, SyntaxContext};
|
||||
use syntax::ext::hygiene::Mark;
|
||||
use syntax::fold::Folder;
|
||||
use syntax::parse::ParseSess;
|
||||
use syntax::ptr::P;
|
||||
|
@ -371,7 +371,7 @@ fn mk_registrar(cx: &mut ExtCtxt,
|
|||
allow_internal_unsafe: false,
|
||||
}
|
||||
});
|
||||
let span = DUMMY_SP.with_ctxt(SyntaxContext::empty().apply_mark(mark));
|
||||
let span = DUMMY_SP.apply_mark(mark);
|
||||
|
||||
let proc_macro = Ident::from_str("proc_macro");
|
||||
let krate = cx.item(span,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue