diff options
| author | bohan <bohan-zhang@foxmail.com> | 2023-06-06 23:11:08 +0800 |
|---|---|---|
| committer | bohan <bohan-zhang@foxmail.com> | 2023-06-06 23:11:08 +0800 |
| commit | c927743b7b7bd382836dcce2d1140a7e829dc3d0 (patch) | |
| tree | c23fed95e63c567f62b5a5551aba4102e0647e41 /compiler/rustc_expand/src | |
| parent | fd9bf594366e73efb1a26a023e0b4de8eff82b94 (diff) | |
| download | rust-c927743b7b7bd382836dcce2d1140a7e829dc3d0.tar.gz rust-c927743b7b7bd382836dcce2d1140a7e829dc3d0.zip | |
fix(expand): prevent infinity loop in macro containing only "///"
Diffstat (limited to 'compiler/rustc_expand/src')
| -rw-r--r-- | compiler/rustc_expand/src/mbe/macro_parser.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_expand/src/mbe/macro_rules.rs | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rustc_expand/src/mbe/macro_parser.rs b/compiler/rustc_expand/src/mbe/macro_parser.rs index 1c222fb4a89..f0e67cfd50e 100644 --- a/compiler/rustc_expand/src/mbe/macro_parser.rs +++ b/compiler/rustc_expand/src/mbe/macro_parser.rs @@ -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, diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index e4c65a2049b..576d636d489 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -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 |
