mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Make clear that TokenTree::Token
shouldn't contain a delimiter.
This commit is contained in:
parent
af1d16e82d
commit
b23f272db0
@ -41,7 +41,8 @@ use std::{fmt, iter};
|
|||||||
/// Nothing special happens to misnamed or misplaced `SubstNt`s.
|
/// Nothing special happens to misnamed or misplaced `SubstNt`s.
|
||||||
#[derive(Debug, Clone, PartialEq, Encodable, Decodable, HashStable_Generic)]
|
#[derive(Debug, Clone, PartialEq, Encodable, Decodable, HashStable_Generic)]
|
||||||
pub enum TokenTree {
|
pub enum TokenTree {
|
||||||
/// A single token.
|
/// A single token. Should never be `OpenDelim` or `CloseDelim`, because
|
||||||
|
/// delimiters are implicitly represented by `Delimited`.
|
||||||
Token(Token, Spacing),
|
Token(Token, Spacing),
|
||||||
/// A delimited sequence of token trees.
|
/// A delimited sequence of token trees.
|
||||||
Delimited(DelimSpan, Delimiter, TokenStream),
|
Delimited(DelimSpan, Delimiter, TokenStream),
|
||||||
|
@ -290,7 +290,13 @@ impl TokenCursor {
|
|||||||
self.frame.tree_cursor.replace_prev_and_rewind(desugared);
|
self.frame.tree_cursor.replace_prev_and_rewind(desugared);
|
||||||
// Continue to get the first token of the desugared doc comment.
|
// 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) => {
|
&TokenTree::Delimited(sp, delim, ref tts) => {
|
||||||
// Set `open_delim` to true here because we deal with it immediately.
|
// Set `open_delim` to true here because we deal with it immediately.
|
||||||
|
Loading…
Reference in New Issue
Block a user