about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/mod.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-04-20 12:22:03 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2022-04-20 12:28:26 +1000
commit3cd5e346170437f844d18c17d3f870dc4722c96a (patch)
treefa5275d0f1f78bc3bb3dd92aae7f56f97b420dc3 /compiler/rustc_parse/src/parser/mod.rs
parent86723d3d468745aa5e6494a766ea9ba6cb283b3c (diff)
downloadrust-3cd5e346170437f844d18c17d3f870dc4722c96a.tar.gz
rust-3cd5e346170437f844d18c17d3f870dc4722c96a.zip
Remove `TokenCursorFrame::open_delim`.
Because it's now always true.
Diffstat (limited to 'compiler/rustc_parse/src/parser/mod.rs')
-rw-r--r--compiler/rustc_parse/src/parser/mod.rs25
1 files changed, 5 insertions, 20 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs
index a337d8fae0f..a276fb53895 100644
--- a/compiler/rustc_parse/src/parser/mod.rs
+++ b/compiler/rustc_parse/src/parser/mod.rs
@@ -241,20 +241,13 @@ struct TokenCursor {
 struct TokenCursorFrame {
     delim: token::DelimToken,
     span: DelimSpan,
-    open_delim: bool,
     tree_cursor: tokenstream::Cursor,
     close_delim: bool,
 }
 
 impl TokenCursorFrame {
-    fn new(
-        span: DelimSpan,
-        delim: DelimToken,
-        open_delim: bool,
-        tts: TokenStream,
-        close_delim: bool,
-    ) -> Self {
-        TokenCursorFrame { delim, span, open_delim, tree_cursor: tts.into_trees(), close_delim }
+    fn new(span: DelimSpan, delim: DelimToken, tts: TokenStream, close_delim: bool) -> Self {
+        TokenCursorFrame { delim, span, tree_cursor: tts.into_trees(), close_delim }
     }
 }
 
@@ -267,13 +260,7 @@ impl TokenCursor {
     #[inline(always)]
     fn inlined_next(&mut self, desugar_doc_comments: bool) -> (Token, Spacing) {
         loop {
-            if !self.frame.open_delim {
-                self.frame.open_delim = true;
-                return (
-                    Token::new(token::OpenDelim(self.frame.delim), self.frame.span.open),
-                    Spacing::Alone,
-                );
-            } else if let Some((tree, spacing)) = self.frame.tree_cursor.next_with_spacing() {
+            if let Some((tree, spacing)) = self.frame.tree_cursor.next_with_spacing() {
                 return match tree {
                     TokenTree::Token(token) => match (desugar_doc_comments, &token) {
                         (true, &Token { kind: token::DocComment(_, attr_style, data), span }) => {
@@ -283,7 +270,7 @@ impl TokenCursor {
                     },
                     TokenTree::Delimited(sp, delim, tts) => {
                         // Set `open_delim` to true here because we deal with it immediately.
-                        let frame = TokenCursorFrame::new(sp, delim, true, tts, false);
+                        let frame = TokenCursorFrame::new(sp, delim, tts, false);
                         self.stack.push(mem::replace(&mut self.frame, frame));
                         (Token::new(token::OpenDelim(delim), sp.open), Spacing::Alone)
                     }
@@ -335,7 +322,6 @@ impl TokenCursor {
             TokenCursorFrame::new(
                 delim_span,
                 token::NoDelim,
-                true,
                 if attr_style == AttrStyle::Inner {
                     [TokenTree::token(token::Pound, span), TokenTree::token(token::Not, span), body]
                         .iter()
@@ -436,8 +422,7 @@ impl<'a> Parser<'a> {
         desugar_doc_comments: bool,
         subparser_name: Option<&'static str>,
     ) -> Self {
-        let start_frame =
-            TokenCursorFrame::new(DelimSpan::dummy(), token::NoDelim, true, tokens, true);
+        let start_frame = TokenCursorFrame::new(DelimSpan::dummy(), token::NoDelim, tokens, true);
 
         let mut parser = Parser {
             sess,