-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Allow lifetimes to be passed to macros #33135
Conversation
Partially fixes rust-lang#10413. This only handles lifetimes, as they're much more "obvious" than the type parameter list would be, as that implies that we probably want to mirror `ast::Generics` as well as all of the individual pieces. That should probably have an RFC. These are essentially just treated the same as idents. They're a single token, and are quite pervasive, so we interpolate them back into a real token rather than handling `NtLifetime` all over the parser. This change is specifically needed in Diesel in order for us to provide a "normal macro" alternative to some of our syntax extensions. With this change, we'd be able to have a decent stable story without syntex.
(rust_highfive has picked a reviewer for you, use r? to override) |
Only change I'd personally make would be to abbreviate the matcher name, since we have Really, there's no compelling reason not to support this. This would also play into rust-lang/rfcs#1583, allowing the expansion to use |
I'm strongly in favor of this change. According to our policies, though, I believe an RFC would be required (though not a complex one). Something like rust-lang/rfcs#1576 or rust-lang/rfcs#1575. I imagine we could "fast-track" such an RFC. (As we ought to consider fast-tracking those, which are changes of a similar magnitude.) cc @rust-lang/lang |
also cc @pnkfelix and @LeoTestard specifically |
I assumed that wasn't required since there was an open issue on the main Rust repo that had been around for a while. Certainly happy to write up an RFC though. |
The RFC is pretty brief as there's not a ton to say about the change. rust-lang/rfcs#1590 |
All of the other non-terminals have this implementation. If we allow them in macros, we should allow them in quoting
@sgrif I'm going to close this PR until the RFC is settled, just to keep queue under control. |
No problem On Wed, May 4, 2016, 9:37 AM Niko Matsakis notifications@github.com wrote:
|
@sgrif I'm going to try to finish this, can you tell me what still needs to be done? |
This PR should actually be good to go as-is (modulo rebasing). The thing I wanted to fix was an issue with |
@sgrif OK, sounds good. Rebasing has been pretty straightforward for the most part, with a couple of exceptions that I'll need some help with. I'll post a new PR and ping you when it's ready for your input. |
Started rebasing @sgrif's PR rust-lang#33135 off of current master. (Well, actually merging it into a new branch based off current master.) The following files still need to be fixed or at least reviewed: - `src/libsyntax/ext/tt/macro_parser.rs`: calls `Parser::parse_lifetime`, which doesn't exist anymore - `src/libsyntax/parse/parser.rs`: @sgrif added an error message to `Parser::parse_lifetime`. Code has since been refactored, so I just took it out for now. - `src/libsyntax/ext/tt/transcribe.rs`: This code has been refactored bigtime. Not sure whether @sgrif's changes here are still necessary. Took it out for this commit.
Started rebasing @sgrif's PR rust-lang#33135 off of current master. (Well, actually merging it into a new branch based off current master.) The following files still need to be fixed or at least reviewed: - `src/libsyntax/ext/tt/macro_parser.rs`: calls `Parser::parse_lifetime`, which doesn't exist anymore - `src/libsyntax/parse/parser.rs`: @sgrif added an error message to `Parser::parse_lifetime`. Code has since been refactored, so I just took it out for now. - `src/libsyntax/ext/tt/transcribe.rs`: This code has been refactored bigtime. Not sure whether @sgrif's changes here are still necessary. Took it out for this commit.
Partially fixes #10413. This only handles lifetimes, as they're much
more "obvious" than the type parameter list would be, as that implies
that we probably want to mirror
ast::Generics
as well as all of theindividual pieces. That should probably have an RFC.
These are essentially just treated the same as idents. They're a single
token, and are quite pervasive, so we interpolate them back into a real
token rather than handling
NtLifetime
all over the parser.This change is specifically needed in Diesel in order for us to provide
a "normal macro" alternative to some of our syntax extensions. With this
change, we'd be able to have a decent stable story without syntex.