diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-01-13 17:21:39 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-13 17:21:39 +0100 |
| commit | b1200a29b07dddb9c05b99166c7b676b6f2dbb4b (patch) | |
| tree | 1bc3034952a0cc72a6f85a2d8218da8a7734e9cb /src/libsyntax/ext/tt | |
| parent | d45bef9db62a0797c6dd3b06e21db1a0acd8cfe7 (diff) | |
| parent | e80a93040ffbbb7eb8013f1dcd3b594ce8a631cd (diff) | |
| download | rust-b1200a29b07dddb9c05b99166c7b676b6f2dbb4b.tar.gz rust-b1200a29b07dddb9c05b99166c7b676b6f2dbb4b.zip | |
Rollup merge of #57004 - nnethercote:TS-change-Stream, r=petrochenkov
Make `TokenStream` less recursive. `TokenStream` is currently recursive in *two* ways: - the `TokenTree` variant contains a `ThinTokenStream`, which can contain a `TokenStream`; - the `TokenStream` variant contains a `Vec<TokenStream>`. The latter is not necessary and causes significant complexity. This commit replaces it with the simpler `Vec<(TokenTree, IsJoint)>`. This reduces complexity significantly. In particular, `StreamCursor` is eliminated, and `Cursor` becomes much simpler, consisting now of just a `TokenStream` and an index. The commit also removes the `Extend` impl for `TokenStream`, because it is only used in tests. (The commit also removes those tests.) Overall, the commit reduces the number of lines of code by almost 200.
Diffstat (limited to 'src/libsyntax/ext/tt')
| -rw-r--r-- | src/libsyntax/ext/tt/transcribe.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 31d87508c6b..0ef2d3b749d 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -7,7 +7,7 @@ use fold::noop_fold_tt; use parse::token::{self, Token, NtTT}; use smallvec::SmallVec; use syntax_pos::DUMMY_SP; -use tokenstream::{TokenStream, TokenTree, DelimSpan}; +use tokenstream::{DelimSpan, TokenStream, TokenTree, TreeAndJoint}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lrc; @@ -63,7 +63,7 @@ pub fn transcribe(cx: &ExtCtxt, let mut stack: SmallVec<[Frame; 1]> = smallvec![Frame::new(src)]; let interpolations = interp.unwrap_or_else(FxHashMap::default); /* just a convenience */ let mut repeats = Vec::new(); - let mut result: Vec<TokenStream> = Vec::new(); + let mut result: Vec<TreeAndJoint> = Vec::new(); let mut result_stack = Vec::new(); loop { @@ -78,7 +78,7 @@ pub fn transcribe(cx: &ExtCtxt, if let Some(sep) = sep.clone() { // repeat same span, I guess let prev_span = match result.last() { - Some(stream) => stream.trees().next().unwrap().span(), + Some((tt, _)) => tt.span(), None => DUMMY_SP, }; result.push(TokenTree::Token(prev_span, sep).into()); |
