about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2023-02-01 12:58:04 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2023-02-03 10:06:52 +1100
commita86fc727fa9b9fa1ac60b67147736783b3376e91 (patch)
tree209cdf6663964ae126c91a86717922a39db5a382 /compiler/rustc_parse/src
parentb5ecbbb998aae80541d70bf5c93be92e6c59a7a8 (diff)
downloadrust-a86fc727fa9b9fa1ac60b67147736783b3376e91.tar.gz
rust-a86fc727fa9b9fa1ac60b67147736783b3376e91.zip
Rename `Cursor`/`CursorRef` as `TokenTreeCursor`/`RefTokenTreeCursor`.
This makes it clear they return token trees, and makes for a nice
comparison against `TokenCursor` which returns tokens.
Diffstat (limited to 'compiler/rustc_parse/src')
-rw-r--r--compiler/rustc_parse/src/parser/mod.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs
index 982fde727c8..2ea55f838a3 100644
--- a/compiler/rustc_parse/src/parser/mod.rs
+++ b/compiler/rustc_parse/src/parser/mod.rs
@@ -19,9 +19,8 @@ pub use path::PathStyle;
 
 use rustc_ast::ptr::P;
 use rustc_ast::token::{self, Delimiter, Nonterminal, Token, TokenKind};
-use rustc_ast::tokenstream::AttributesData;
-use rustc_ast::tokenstream::{self, DelimSpan, Spacing};
-use rustc_ast::tokenstream::{TokenStream, TokenTree};
+use rustc_ast::tokenstream::{AttributesData, DelimSpan, Spacing};
+use rustc_ast::tokenstream::{TokenStream, TokenTree, TokenTreeCursor};
 use rustc_ast::util::case::Case;
 use rustc_ast::AttrId;
 use rustc_ast::DUMMY_NODE_ID;
@@ -221,17 +220,21 @@ impl<'a> Drop for Parser<'a> {
     }
 }
 
+/// Iterator over a `TokenStream` that produces `Token`s. It's a bit odd that
+/// we (a) lex tokens into a nice tree structure (`TokenStream`), and then (b)
+/// use this type to emit them as a linear sequence. But a linear sequence is
+/// what the parser expects, for the most part.
 #[derive(Clone)]
 struct TokenCursor {
     // Cursor for the current (innermost) token stream. The delimiters for this
     // token stream are found in `self.stack.last()`; when that is `None` then
     // we are in the outermost token stream which never has delimiters.
-    tree_cursor: tokenstream::Cursor,
+    tree_cursor: TokenTreeCursor,
 
     // Token streams surrounding the current one. The delimiters for stack[n]'s
     // tokens are in `stack[n-1]`. `stack[0]` (when present) has no delimiters
     // because it's the outermost token stream which never has delimiters.
-    stack: Vec<(tokenstream::Cursor, Delimiter, DelimSpan)>,
+    stack: Vec<(TokenTreeCursor, Delimiter, DelimSpan)>,
 
     desugar_doc_comments: bool,