about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2023-02-01 11:21:28 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2023-02-03 10:06:52 +1100
commitb23f272db017c3bfd8cdf57fad6e5fdd057168c6 (patch)
tree05a770839f620d2556424e8a97ea433ace944978 /compiler/rustc_parse/src/parser
parentaf1d16e82ddc27166438e8bc2a520087862f12af (diff)
downloadrust-b23f272db017c3bfd8cdf57fad6e5fdd057168c6.tar.gz
rust-b23f272db017c3bfd8cdf57fad6e5fdd057168c6.zip
Make clear that `TokenTree::Token` shouldn't contain a delimiter.
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/mod.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs
index 0499a56a09d..510588f8a5f 100644
--- a/compiler/rustc_parse/src/parser/mod.rs
+++ b/compiler/rustc_parse/src/parser/mod.rs
@@ -290,7 +290,13 @@ impl TokenCursor {
                             self.frame.tree_cursor.replace_prev_and_rewind(desugared);
                             // Continue to get the first token of the desugared doc comment.
                         }
-                        _ => return (token.clone(), spacing),
+                        _ => {
+                            debug_assert!(!matches!(
+                                token.kind,
+                                token::OpenDelim(_) | token::CloseDelim(_)
+                            ));
+                            return (token.clone(), spacing);
+                        }
                     },
                     &TokenTree::Delimited(sp, delim, ref tts) => {
                         // Set `open_delim` to true here because we deal with it immediately.