Skip to content

Commit 10644e0

Browse files
committed
Remove an impossible code path.
Doc comments cannot appear in a matcher.
1 parent 39810a8 commit 10644e0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

compiler/rustc_expand/src/mbe/macro_parser.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,9 @@ impl TtParser {
593593
}
594594
}
595595

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

611609
TokenTree::Token(t) => {
610+
// Doc comments cannot appear in a matcher.
611+
debug_assert!(!matches!(t, Token { kind: DocComment(..), .. }));
612+
612613
// If the token matches, we can just advance the parser. Otherwise, this
613614
// match hash failed, there is nothing to do, and hopefully another item in
614615
// `cur_items` will match.

0 commit comments

Comments
 (0)