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

Tracking issue for adding a lifetime specifier to macro_rules! #34303

Closed
nikomatsakis opened this issue Jun 16, 2016 · 25 comments · Fixed by #46895
Closed

Tracking issue for adding a lifetime specifier to macro_rules! #34303

nikomatsakis opened this issue Jun 16, 2016 · 25 comments · Fixed by #46895
Labels
B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. E-help-wanted Call for participation: Help is requested to fix this issue. finished-final-comment-period The final comment period is finished for this PR / Issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

cc rust-lang/rfcs#1590 @sgrif

@sgrif
Copy link
Contributor

sgrif commented Jun 16, 2016

I'll open a new PR soon, I want to do one more thing on top of #33135

@apasel422 apasel422 added the B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. label Jun 17, 2016
@Phlosioneer
Copy link
Contributor

Godspeed, @sgrif! This being in nightly would make my week.

@comex
Copy link
Contributor

comex commented Jan 3, 2017

@sgrif Any update?

@brson brson added B-unstable Blocker: Implemented in the nightly compiler and unstable. E-help-wanted Call for participation: Help is requested to fix this issue. labels Mar 1, 2017
@brson
Copy link
Contributor

brson commented Mar 1, 2017

This doesn't seem particularly hard. Help wanted.

@durka
Copy link
Contributor

durka commented Mar 1, 2017

I wish we knew what the "one more thing" was besides just reopening the closed PR.

@mikeyhew
Copy link
Contributor

mikeyhew commented May 4, 2017

I'd like to help implement this. Where do I start?

@petrochenkov
Copy link
Contributor

@mikeyhew
This is a good issue to start working on the compiler frontend.
You may want to start with taking @sgrif's patch and rebasing it on the current master, and then making sure the tests pass.
Then you'll have to add a feature gate for lifetime matcher and some docs (unstable book section) (see e0cd766, and 1d46805, and #41012 as a whole for examples of the same things being done with vis matcher.)

@durka

I wish we knew what the "one more thing" was besides just reopening the closed PR.

This should be something truly marvelous, that this GitHub comment was too narrow to contain.

@Mark-Simulacrum Mark-Simulacrum added the C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. label Jul 22, 2017
bors added a commit that referenced this issue Jan 1, 2018
Allow lifetimes in macros

This is a resurrection of PR #41927 which was a resurrection of #33135, which is intended to fix #34303.

In short, this allows macros_rules! to use :lifetime as a matcher to match 'lifetimes.

Still to do:
- [x]  Feature gate
@sgrif
Copy link
Contributor

sgrif commented Jan 1, 2018

This issue should remain open until the feature is stable, right?

@petrochenkov petrochenkov reopened this Jan 1, 2018
@cramertj
Copy link
Member

cramertj commented Mar 9, 2018

@rfcbot fcp merge

AFAIK this feature has gone relatively without-incident since its implementation, and it adds key functionality to macros. Tests can be found here, here, here, and here.

@petrochenkov
Copy link
Contributor

Some alternatives are discussed in https://internals.rust-lang.org/t/pre-rfc-splitting-lifetime-into-two-tokens/6716 - either splitting lifetimes into two tokens, then they can be matched with ' $i: ident or just making them identifiers so the can be matched with $i: ident / $'i: ident.

I don't think it prevents stabilization of the lifetime matcher, if those changes are implemented it will still continue to work and we'll be able to deprecate it if necessary.

@cramertj
Copy link
Member

@rfcbot fcp merge

trying again

@nikomatsakis nikomatsakis added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Mar 12, 2018
@nikomatsakis
Copy link
Contributor Author

@rfcbot fcp merge

See @cramertj's brief summary here.

@rfcbot rfcbot added the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Mar 12, 2018
@rfcbot
Copy link

rfcbot commented Mar 12, 2018

Team member @nikomatsakis has proposed to merge this. The next step is review by the rest of the tagged teams:

Concerns:

Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@nikomatsakis
Copy link
Contributor Author

@rfcbot fcp concern

@petrochenkov recently brought it to my attention that '_ matches the lifetime fragment (whereas _ -- rightly, to my mind -- does not match ident). I believe this is incorrect, or at least worth debating. =) '_ is not a lifetime name, it is rather a token used to control elision rules.

On the other hand, I can see an argument that not supporting '_ means we can't "forward" lifetimes in some cases where we would like to. (I suppose a similar argument would apply to _ and ident.)

@nikomatsakis
Copy link
Contributor Author

@rfcbot concern underscore-lifetime

@nikomatsakis
Copy link
Contributor Author

(Bother, I can never remember the dang syntax.)

@durka
Copy link
Contributor

durka commented Mar 15, 2018 via email

@nikomatsakis
Copy link
Contributor Author

@durka right, that's precisely what I was thinking when I wrote the "on the other hand" part. I think I'm going to resolve my concern -- otherwise I guess we need a bunch more matchers.

@rfcbot resolve underscore-lifetime

@durka
Copy link
Contributor

durka commented Mar 19, 2018

@nikomatsakis please say "resolved" for the bot

@nikomatsakis
Copy link
Contributor Author

@rfcbot resolved underscore-lifetime

Sigh.

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Mar 20, 2018
@rfcbot
Copy link

rfcbot commented Mar 20, 2018

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot
Copy link

rfcbot commented Mar 30, 2018

The final comment period is now complete.

@durka
Copy link
Contributor

durka commented Mar 30, 2018

🚀 🚀 🚀 🚀 🚀

bors added a commit that referenced this issue May 14, 2018
stabilize macro_lifetime_matcher

This stabilizes `:lifetime` which has completed FCP in #34303.
@Centril Centril added disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels May 24, 2018
@dtolnay
Copy link
Member

dtolnay commented Jun 10, 2018

We don't have tests for a macro_rules falling through to the next rule after a $:lifetime matcher.

And it doesn't work. 😢 I filed #51477 to follow up.

@Centril
Copy link
Contributor

Centril commented Sep 15, 2018

I think we can close this as it was stabilized; bugs and other things can be tracked as we usually do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. E-help-wanted Call for participation: Help is requested to fix this issue. finished-final-comment-period The final comment period is finished for this PR / Issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.