about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2018-12-19 14:53:52 +1100
committerNicholas Nethercote <nnethercote@mozilla.com>2019-01-08 15:08:46 +1100
commite80a93040ffbbb7eb8013f1dcd3b594ce8a631cd (patch)
tree7dab947607d393e7d4fdc35ffa95a6f101f3a549 /src/libsyntax/parse/parser.rs
parentb92552d5578e4544006da0dd5e793a19c2149321 (diff)
downloadrust-e80a93040ffbbb7eb8013f1dcd3b594ce8a631cd.tar.gz
rust-e80a93040ffbbb7eb8013f1dcd3b594ce8a631cd.zip
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/parse/parser.rs')
-rw-r--r--src/libsyntax/parse/parser.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 1e4a26b3537..eababf58dfa 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2914,7 +2914,7 @@ impl<'a> Parser<'a> {
                 TokenTree::Delimited(
                     frame.span,
                     frame.delim,
-                    frame.tree_cursor.original_stream().into(),
+                    frame.tree_cursor.stream.into(),
                 )
             },
             token::CloseDelim(_) | token::Eof => unreachable!(),