-
Notifications
You must be signed in to change notification settings - Fork 13.3k
macros: fix partially consumed tokens in macro matchers #37208
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
macros: fix partially consumed tokens in macro matchers #37208
Conversation
let match_cur = ei.match_cur; | ||
(&mut ei.matches[match_cur]).push(Rc::new(MatchedNonterminal( | ||
parse_nt(&mut rust_parser, span, &ident.name.as_str())))); | ||
ei.idx += 1; | ||
ei.match_cur += 1; | ||
} else { | ||
panic!() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this panic should be unreachable (it might be better though to encapsulate this on the token tree somewhere, rather than doing it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to unreachable!()
.
r+ with the nit addressed |
71d4d24
to
95a9e2a
Compare
@bors r=nrc |
📌 Commit 95a9e2a has been approved by |
…kens_in_macros, r=nrc macros: fix partially consumed tokens in macro matchers Fixes rust-lang#37175. This PR also avoids re-transcribing the tokens consumed by a matcher (and cloning the `TtReader` once per matcher), which improves expansion performance of the test case from rust-lang#34630 by ~8%. r? @nrc
…kens_in_macros, r=nrc macros: fix partially consumed tokens in macro matchers Fixes rust-lang#37175. This PR also avoids re-transcribing the tokens consumed by a matcher (and cloning the `TtReader` once per matcher), which improves expansion performance of the test case from rust-lang#34630 by ~8%. r? @nrc
Fixes #37175.
This PR also avoids re-transcribing the tokens consumed by a matcher (and cloning the
TtReader
once per matcher), which improves expansion performance of the test case from #34630 by ~8%.r? @nrc