Skip to content

Commit 43ad972

Browse files
committed
Use Span::apply_mark where possible
1 parent e2afefd commit 43ad972

File tree

9 files changed

+14
-14
lines changed

9 files changed

+14
-14
lines changed

src/libsyntax/ext/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ pub fn expr_to_spanned_string(cx: &mut ExtCtxt, expr: P<ast::Expr>, err_msg: &st
897897
-> Option<Spanned<(Symbol, ast::StrStyle)>> {
898898
// Update `expr.span`'s ctxt now in case expr is an `include!` macro invocation.
899899
let expr = expr.map(|mut expr| {
900-
expr.span = expr.span.with_ctxt(expr.span.ctxt().apply_mark(cx.current_expansion.mark));
900+
expr.span = expr.span.apply_mark(cx.current_expansion.mark);
901901
expr
902902
});
903903

src/libsyntax/ext/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,7 @@ impl Folder for Marker {
13831383
}
13841384

13851385
fn new_span(&mut self, span: Span) -> Span {
1386-
span.with_ctxt(span.ctxt().apply_mark(self.0))
1386+
span.apply_mark(self.0)
13871387
}
13881388

13891389
fn fold_mac(&mut self, mac: ast::Mac) -> ast::Mac {

src/libsyntax/ext/tt/transcribe.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub fn transcribe(cx: &ExtCtxt,
156156
if let NtTT(ref tt) = **nt {
157157
result.push(tt.clone().into());
158158
} else {
159-
sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
159+
sp = sp.apply_mark(cx.current_expansion.mark);
160160
let token = TokenTree::Token(sp, Token::interpolated((**nt).clone()));
161161
result.push(token.into());
162162
}
@@ -167,13 +167,13 @@ pub fn transcribe(cx: &ExtCtxt,
167167
} else {
168168
let ident =
169169
Ident::new(ident.name, ident.span.apply_mark(cx.current_expansion.mark));
170-
sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
170+
sp = sp.apply_mark(cx.current_expansion.mark);
171171
result.push(TokenTree::Token(sp, token::Dollar).into());
172172
result.push(TokenTree::Token(sp, token::Token::from_ast_ident(ident)).into());
173173
}
174174
}
175175
quoted::TokenTree::Delimited(mut span, delimited) => {
176-
span = span.with_ctxt(span.ctxt().apply_mark(cx.current_expansion.mark));
176+
span = span.apply_mark(cx.current_expansion.mark);
177177
stack.push(Frame::Delimited { forest: delimited, idx: 0, span: span });
178178
result_stack.push(mem::replace(&mut result, Vec::new()));
179179
}

src/libsyntax_ext/assert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn expand_assert<'cx>(
3535
None
3636
};
3737

38-
let sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
38+
let sp = sp.apply_mark(cx.current_expansion.mark);
3939
let panic_call = Mac_ {
4040
path: Path::from_ident(sp, Ident::from_str("panic")),
4141
tts: if let Some(ts) = custom_msg_args {

src/libsyntax_ext/cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
2424
sp: Span,
2525
tts: &[tokenstream::TokenTree])
2626
-> Box<base::MacResult + 'static> {
27-
let sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
27+
let sp = sp.apply_mark(cx.current_expansion.mark);
2828
let mut p = cx.new_parser_from_tts(tts);
2929
let cfg = panictry!(p.parse_meta_item());
3030

src/libsyntax_ext/concat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
5757
}
5858
}
5959
}
60-
let sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
60+
let sp = sp.apply_mark(cx.current_expansion.mark);
6161
base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&accumulator)))
6262
}

src/libsyntax_ext/env.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt,
3232
Some(v) => v,
3333
};
3434

35-
let sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark));
35+
let sp = sp.apply_mark(cx.current_expansion.mark);
3636
let e = match env::var(&*var.as_str()) {
3737
Err(..) => {
3838
let lt = cx.lifetime(sp, keywords::StaticLifetime.ident());

src/libsyntax_ext/format.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ impl<'a, 'b> Context<'a, 'b> {
641641
ty: &ArgumentType,
642642
arg: ast::Ident)
643643
-> P<ast::Expr> {
644-
sp = sp.with_ctxt(sp.ctxt().apply_mark(ecx.current_expansion.mark));
644+
sp = sp.apply_mark(ecx.current_expansion.mark);
645645
let arg = ecx.expr_ident(sp, arg);
646646
let trait_ = match *ty {
647647
Placeholder(ref tyname) => {
@@ -678,7 +678,7 @@ pub fn expand_format_args<'cx>(ecx: &'cx mut ExtCtxt,
678678
mut sp: Span,
679679
tts: &[tokenstream::TokenTree])
680680
-> Box<base::MacResult + 'cx> {
681-
sp = sp.with_ctxt(sp.ctxt().apply_mark(ecx.current_expansion.mark));
681+
sp = sp.apply_mark(ecx.current_expansion.mark);
682682
match parse_args(ecx, sp, tts) {
683683
Some((efmt, args, names)) => {
684684
MacEager::expr(expand_preparsed_format_args(ecx, sp, efmt, args, names))
@@ -700,7 +700,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt,
700700
let arg_types: Vec<_> = (0..args.len()).map(|_| Vec::new()).collect();
701701
let arg_unique_types: Vec<_> = (0..args.len()).map(|_| Vec::new()).collect();
702702
let mut macsp = ecx.call_site();
703-
macsp = macsp.with_ctxt(macsp.ctxt().apply_mark(ecx.current_expansion.mark));
703+
macsp = macsp.apply_mark(ecx.current_expansion.mark);
704704
let msg = "format argument must be a string literal.";
705705
let fmt = match expr_to_spanned_string(ecx, efmt, msg) {
706706
Some(fmt) => fmt,

src/libsyntax_ext/proc_macro_registrar.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use syntax::codemap::{ExpnInfo, NameAndSpan, MacroAttribute, respan};
1818
use syntax::ext::base::ExtCtxt;
1919
use syntax::ext::build::AstBuilder;
2020
use syntax::ext::expand::ExpansionConfig;
21-
use syntax::ext::hygiene::{Mark, SyntaxContext};
21+
use syntax::ext::hygiene::Mark;
2222
use syntax::fold::Folder;
2323
use syntax::parse::ParseSess;
2424
use syntax::ptr::P;
@@ -371,7 +371,7 @@ fn mk_registrar(cx: &mut ExtCtxt,
371371
allow_internal_unsafe: false,
372372
}
373373
});
374-
let span = DUMMY_SP.with_ctxt(SyntaxContext::empty().apply_mark(mark));
374+
let span = DUMMY_SP.apply_mark(mark);
375375

376376
let proc_macro = Ident::from_str("proc_macro");
377377
let krate = cx.item(span,

0 commit comments

Comments
 (0)