fix(expand): prevent infinity loop in macro containing only "///"
This commit is contained in:
parent
fd9bf59436
commit
c927743b7b
5 changed files with 95 additions and 0 deletions
|
@ -249,6 +249,7 @@ pub(super) fn compute_locs(matcher: &[TokenTree]) -> Vec<MatcherLoc> {
|
|||
}
|
||||
|
||||
/// A single matcher position, representing the state of matching.
|
||||
#[derive(Debug)]
|
||||
struct MatcherPos {
|
||||
/// The index into `TtParser::locs`, which represents the "dot".
|
||||
idx: usize,
|
||||
|
|
|
@ -647,6 +647,7 @@ fn check_lhs_no_empty_seq(sess: &ParseSess, tts: &[mbe::TokenTree]) -> bool {
|
|||
if seq.separator.is_none()
|
||||
&& seq.tts.iter().all(|seq_tt| match seq_tt {
|
||||
TokenTree::MetaVarDecl(_, _, Some(NonterminalKind::Vis)) => true,
|
||||
TokenTree::Token(t) => matches!(t, Token { kind: DocComment(..), .. }),
|
||||
TokenTree::Sequence(_, sub_seq) => {
|
||||
sub_seq.kleene.op == mbe::KleeneOp::ZeroOrMore
|
||||
|| sub_seq.kleene.op == mbe::KleeneOp::ZeroOrOne
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue