Skip to content

Commit 903fc4b

Browse files
authored
Rollup merge of #60618 - mark-i-m:transcribe, r=petrochenkov
Comment ext::tt::transcribe Also did a bit of minor cleanup (remove unidiomatic use of `Add` and an unneeded `clone`). No functionality changes. r? @petrochenkov
2 parents bd17b5c + eb7d47c commit 903fc4b

File tree

4 files changed

+194
-69
lines changed

4 files changed

+194
-69
lines changed

src/libsyntax/ext/tt/macro_parser.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,10 @@ fn inner_parse_loop<'root, 'tt>(
554554
match item.top_elts.get_tt(idx) {
555555
// Need to descend into a sequence
556556
TokenTree::Sequence(sp, seq) => {
557-
// Examine the case where there are 0 matches of this sequence
557+
// Examine the case where there are 0 matches of this sequence. We are
558+
// implicitly disallowing OneOrMore from having 0 matches here. Thus, that will
559+
// result in a "no rules expected token" error by virtue of this matcher not
560+
// working.
558561
if seq.op == quoted::KleeneOp::ZeroOrMore
559562
|| seq.op == quoted::KleeneOp::ZeroOrOne
560563
{

src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt<'_>,
151151

152152
let rhs_spans = rhs.iter().map(|t| t.span()).collect::<Vec<_>>();
153153
// rhs has holes ( `$id` and `$(...)` that need filled)
154-
let mut tts = transcribe(cx, Some(named_matches), rhs);
154+
let mut tts = transcribe(cx, &named_matches, rhs);
155155

156156
// Replace all the tokens for the corresponding positions in the macro, to maintain
157157
// proper positions in error reporting, while maintaining the macro_backtrace.

src/libsyntax/ext/tt/quoted.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ pub enum KleeneOp {
7373
ZeroOrMore,
7474
/// Kleene plus (`+`) for one or more repetitions
7575
OneOrMore,
76+
/// Kleene optional (`?`) for zero or one reptitions
7677
ZeroOrOne,
7778
}
7879

0 commit comments

Comments
 (0)