Skip to content

Introduce TtParser #95159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 23, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove an impossible code path.
Doc comments cannot appear in a matcher.
  • Loading branch information
nnethercote committed Mar 18, 2022
commit 10644e0789a3c722e11f74968f24c1382f9ccb11
11 changes: 6 additions & 5 deletions compiler/rustc_expand/src/mbe/macro_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,11 +593,9 @@ impl TtParser {
}
}

seq @ (TokenTree::Delimited(..)
| TokenTree::Token(Token { kind: DocComment(..), .. })) => {
// To descend into a delimited submatcher or a doc comment, we push the
// current matcher onto a stack and push a new item containing the
// submatcher onto `cur_items`.
seq @ TokenTree::Delimited(..) => {
// To descend into a delimited submatcher, we push the current matcher onto
// a stack and push a new item containing the submatcher onto `cur_items`.
//
// At the beginning of the loop, if we reach the end of the delimited
// submatcher, we pop the stack to backtrack out of the descent.
Expand All @@ -609,6 +607,9 @@ impl TtParser {
}

TokenTree::Token(t) => {
// Doc comments cannot appear in a matcher.
debug_assert!(!matches!(t, Token { kind: DocComment(..), .. }));

// If the token matches, we can just advance the parser. Otherwise, this
// match hash failed, there is nothing to do, and hopefully another item in
// `cur_items` will match.
Expand Down