From 43ad9723181d30dcf7531b0fb0fb975d6590f4c0 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 18 Mar 2018 23:51:53 +0300 Subject: Use `Span::apply_mark` where possible --- src/libsyntax/ext/base.rs | 2 +- src/libsyntax/ext/expand.rs | 2 +- src/libsyntax/ext/tt/transcribe.rs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 75b1366d3cd..a09bea25a24 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -897,7 +897,7 @@ pub fn expr_to_spanned_string(cx: &mut ExtCtxt, expr: P, err_msg: &st -> Option> { // 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 }); diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index f9a6ab49039..bbfde736ef0 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -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 { diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 12ada3bdbc0..1cdb6b0e5c9 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -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())); } -- cgit 1.4.1-3-g733a5