diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2017-07-31 23:04:34 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2017-08-30 01:38:54 +0300 |
| commit | 3da868dcb67e85ccbd6d64cdcc29829b1399de15 (patch) | |
| tree | 379d1e6e3d7a0b3bca1a5d6f73fd4443b841b0a6 /src/libsyntax/ext/tt | |
| parent | 630e02f25be1e65b316857c5bd8022da0b96db40 (diff) | |
| download | rust-3da868dcb67e85ccbd6d64cdcc29829b1399de15.tar.gz rust-3da868dcb67e85ccbd6d64cdcc29829b1399de15.zip | |
Make fields of `Span` private
Diffstat (limited to 'src/libsyntax/ext/tt')
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/quoted.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/transcribe.rs | 6 |
4 files changed, 13 insertions, 12 deletions
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 405d06dafbf..2167b64e610 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -329,7 +329,8 @@ fn inner_parse_loop(sess: &ParseSess, // Only touch the binders we have actually bound for idx in item.match_lo..item.match_hi { let sub = item.matches[idx].clone(); - new_pos.push_match(idx, MatchedSeq(sub, Span { lo: item.sp_lo, ..span })); + let span = span.with_lo(item.sp_lo); + new_pos.push_match(idx, MatchedSeq(sub, span)); } new_pos.match_cur = item.match_hi; @@ -379,7 +380,7 @@ fn inner_parse_loop(sess: &ParseSess, match_cur: item.match_cur, match_hi: item.match_cur + seq.num_captures, up: Some(item), - sp_lo: sp.lo, + sp_lo: sp.lo(), top_elts: Tt(TokenTree::Sequence(sp, seq)), })); } @@ -424,7 +425,7 @@ pub fn parse(sess: &ParseSess, recurse_into_modules: bool) -> NamedParseResult { let mut parser = Parser::new(sess, tts, directory, recurse_into_modules, true); - let mut cur_items = SmallVector::one(initial_matcher_pos(ms.to_owned(), parser.span.lo)); + let mut cur_items = SmallVector::one(initial_matcher_pos(ms.to_owned(), parser.span.lo())); let mut next_items = Vec::new(); // or proceed normally loop { diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 983b19c5bf0..6d58af497f0 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -130,7 +130,7 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt, tts = tts.map_enumerated(|i, tt| { let mut tt = tt.clone(); let mut sp = rhs_spans[i]; - sp.ctxt = tt.span().ctxt; + sp = sp.with_ctxt(tt.span().ctxt()); tt.set_span(sp); tt }); @@ -161,7 +161,7 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt, macro_ident: name }) } - Failure(sp, tok) => if sp.lo >= best_fail_spot.lo { + Failure(sp, tok) => if sp.lo() >= best_fail_spot.lo() { best_fail_spot = sp; best_fail_tok = Some(tok); }, diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index 012d4a54b36..0e21e3f6b00 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -37,7 +37,7 @@ impl Delimited { let open_span = if span == DUMMY_SP { DUMMY_SP } else { - Span { hi: span.lo + BytePos(self.delim.len() as u32), ..span } + span.with_lo(span.lo() + BytePos(self.delim.len() as u32)) }; TokenTree::Token(open_span, self.open_token()) } @@ -46,7 +46,7 @@ impl Delimited { let close_span = if span == DUMMY_SP { DUMMY_SP } else { - Span { lo: span.hi - BytePos(self.delim.len() as u32), ..span } + span.with_lo(span.hi() - BytePos(self.delim.len() as u32)) }; TokenTree::Token(close_span, self.close_token()) } @@ -152,7 +152,7 @@ pub fn parse(input: tokenstream::TokenStream, expect_matchers: bool, sess: &Pars Some(tokenstream::TokenTree::Token(span, token::Colon)) => match trees.next() { Some(tokenstream::TokenTree::Token(end_sp, ref tok)) => match tok.ident() { Some(kind) => { - let span = Span { lo: start_sp.lo, ..end_sp }; + let span = end_sp.with_lo(start_sp.lo()); result.push(TokenTree::MetaVarDecl(span, ident, kind)); continue } @@ -198,7 +198,7 @@ fn parse_tree<I>(tree: tokenstream::TokenTree, } Some(tokenstream::TokenTree::Token(ident_span, ref token)) if token.is_ident() => { let ident = token.ident().unwrap(); - let span = Span { lo: span.lo, ..ident_span }; + let span = ident_span.with_lo(span.lo()); if ident.name == keywords::Crate.name() { let ident = ast::Ident { name: keywords::DollarCrate.name(), ..ident }; TokenTree::Token(span, token::Ident(ident)) diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index fe3dd83f9d5..d51b0d0ae3e 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -155,7 +155,7 @@ pub fn transcribe(cx: &ExtCtxt, if let NtTT(ref tt) = **nt { result.push(tt.clone().into()); } else { - sp.ctxt = sp.ctxt.apply_mark(cx.current_expansion.mark); + sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark)); let token = TokenTree::Token(sp, Token::interpolated((**nt).clone())); result.push(token.into()); } @@ -166,13 +166,13 @@ pub fn transcribe(cx: &ExtCtxt, } else { let ident = Ident { ctxt: ident.ctxt.apply_mark(cx.current_expansion.mark), ..ident }; - sp.ctxt = sp.ctxt.apply_mark(cx.current_expansion.mark); + sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark)); result.push(TokenTree::Token(sp, token::Dollar).into()); result.push(TokenTree::Token(sp, token::Ident(ident)).into()); } } quoted::TokenTree::Delimited(mut span, delimited) => { - span.ctxt = span.ctxt.apply_mark(cx.current_expansion.mark); + span = span.with_ctxt(span.ctxt().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())); } |
