Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macros: fix partially consumed tokens in macro matchers #37208

Merged

Conversation

jseyfried
Copy link
Contributor

@jseyfried jseyfried commented Oct 16, 2016

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

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!()
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to unreachable!().

@nrc
Copy link
Member

nrc commented Oct 17, 2016

r+ with the nit addressed

@jseyfried jseyfried force-pushed the fix_partially_consumed_tokens_in_macros branch from 71d4d24 to 95a9e2a Compare October 17, 2016 23:01
@jseyfried
Copy link
Contributor Author

@bors r=nrc

@bors
Copy link
Contributor

bors commented Oct 17, 2016

📌 Commit 95a9e2a has been approved by nrc

eddyb added a commit to eddyb/rust that referenced this pull request Oct 19, 2016
…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
eddyb added a commit to eddyb/rust that referenced this pull request Oct 19, 2016
…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
bors added a commit that referenced this pull request Oct 19, 2016
@bors bors merged commit 95a9e2a into rust-lang:master Oct 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants