Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upmacros: Remove matching on "complex" nonterminals requiring AST comparisons #49326
Conversation
rust-highfive
assigned
michaelwoerister
Mar 24, 2018
This comment has been minimized.
This comment has been minimized.
|
(rust_highfive has picked a reviewer for you, use r? to override) |
rust-highfive
added
the
S-waiting-on-review
label
Mar 24, 2018
This comment has been minimized.
This comment has been minimized.
|
cc #49154 (comment) |
rust-highfive
assigned
eddyb
and unassigned
michaelwoerister
Mar 24, 2018
petrochenkov
added
the
S-waiting-on-crater
label
Mar 24, 2018
This comment has been minimized.
This comment has been minimized.
|
There's one pattern I know of that this could break, though it's fine if macro_rules! eq {
($a:tt $b:tt) => {
macro_rules! __eq {
($a $a) => { /* equal */ };
($a $b) => { /* not equal */ }
}
__eq!($a $b);
}
}Arcane, yes, but useful. This trick is the basis of my crate |
This comment has been minimized.
This comment has been minimized.
|
@durka notably, iirc, this trick no longer works if you call that macro more than once: last time I tried it, I got a "macro shadows another macro" error :( |
This comment has been minimized.
This comment has been minimized.
|
@sdleffler |
This comment has been minimized.
This comment has been minimized.
|
We'll want crater artifacts eventually presumably. @bors try |
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Mar 26, 2018
This comment has been minimized.
This comment has been minimized.
|
We should probably compare the underlying tokens the fragment was parsed from, eventually. Another weird thing happening with nonterminals is we expand macros in them (#47358 (comment)). |
eddyb
approved these changes
Mar 26, 2018
This comment has been minimized.
This comment has been minimized.
|
|
nikomatsakis
added
I-nominated
T-lang
labels
Mar 30, 2018
This comment has been minimized.
This comment has been minimized.
|
Crater run started. |
shepmaster
removed
the
S-waiting-on-review
label
Apr 7, 2018
This comment has been minimized.
This comment has been minimized.
|
(apologies for the delay, I fell ill last week) Hi @petrochenkov (crater requester), @eddyb (PR reviewer)! Crater results are at: http://cargobomb-reports.s3.amazonaws.com/pr-49326/index.html. 'Blacklisted' crates (spurious failures etc) can be found here. If you see any spurious failures not on the list, please make a PR against that file. (interested observers: Crater is a tool for testing the impact of changes on the crates.io ecosystem. You can find out more at the repo if you're curious) |
This comment has been minimized.
This comment has been minimized.
|
All the regressions are spurious. |
kennytm
added
S-waiting-on-review
and removed
S-waiting-on-crater
labels
Apr 8, 2018
This comment has been minimized.
This comment has been minimized.
|
Discussed in the @rust-lang/lang meeting and we agreed to go forward with this change. It seems like this was never intentional and we can't really be exposing the details of how |
nikomatsakis
removed
the
I-nominated
label
Apr 12, 2018
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-review
labels
Apr 12, 2018
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Apr 13, 2018
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-review
and removed
S-waiting-on-bors
labels
Apr 13, 2018
This comment has been minimized.
This comment has been minimized.
|
Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
This comment has been minimized.
This comment has been minimized.
|
Needs rebase. |
petrochenkov
added
S-waiting-on-author
T-lang
and removed
S-waiting-on-review
T-lang
labels
Apr 13, 2018
petrochenkov
force-pushed the
petrochenkov:nteq
branch
from
8eb9aa4
to
5bbfd67
Apr 13, 2018
This comment has been minimized.
This comment has been minimized.
|
@bors r=eddyb |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-author
labels
Apr 13, 2018
petrochenkov
force-pushed the
petrochenkov:nteq
branch
from
5bbfd67
to
7e1f73b
Apr 13, 2018
This comment has been minimized.
This comment has been minimized.
|
@bors r=eddyb |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Apr 14, 2018
This comment has been minimized.
This comment has been minimized.
|
|
petrochenkov commentedMar 24, 2018
•
edited
So, you can actually use nonterminals from outer macros in left hand side of nested macros and invocations of nested macros will try to match passed arguments to them.
Why this is bad:
PartialEqimpls derived on AST structures.PartialEqimpls for AST structures don't make much sense in general and compare various auxiliary garbage like spans. For the argument nonterminal to match we should use literally the same token (possibly cloned) as was used in the macro LHS (as in the example above). So we can reject matches that are actually correct.PartialEqfor all (!) AST structures. As I mentioned these impls are also mostly nonsensical.This PR removes support for matching on all nonterminals except for "simple" ones like
ident,lifetimeandttfor which we have original tokens that can be compared.After this is done I'll submit another PR removing huge number of
PartialEqimpls from AST and HIR structures.This is an arcane feature and I don't personally know why would anyone use it, but the change should ideally go through crater.
We'll be able to support this feature again in the future when all nonterminals have original token streams attached to them in addition to (or instead of) AST fragments.