Skip to content

:vis matcher for macro_rules - #41012

Merged
bors merged 10 commits into
rust-lang:masterfrom
durka:vis-matcher
Apr 17, 2017
Merged

:vis matcher for macro_rules#41012
bors merged 10 commits into
rust-lang:masterfrom
durka:vis-matcher

Conversation

@durka

@durkadurka commented Apr 2, 2017

Copy link
Copy Markdown
Contributor

Resurrection of @DanielKeep's implementation posted with RFC 1575.

@jseyfried was of the opinion that this doesn't need an RFC.

Needed before merge:

  • sign-off from @DanielKeep since I stole his code
  • feature gate
  • docs

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@DanielKeep

Copy link
Copy Markdown
Contributor
  • sign-off from @DanielKeep since I graciously resurrected his code lazy hack that he is

@jseyfriedjseyfried left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code LGTM

Comment threadsrc/libsyntax/ext/tt/macro_rules.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we just allow Comma and ModSep? Seems arbitrary to me.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If I remember correctly, I allowed ModSep because you can already have pub ::path::to::a_type that you might want to parse and special-case. I allowed comma because having some kind of sequence-delimiting token is useful. If you're passing bits of parsed input around, you might have inner!($thing, $a_vis, $more_tts). Everything else was excluded based on wanting to err on the side of being conservative.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I allowed ModSep because you can already have pub ::path::to::a_type

This seems quite inconsistent, you can already have pub ARBITRARY_TYPE, but only a subset of paths is allowed.

This should probably use all can_begin_type tokens (in addition to comma) + ty/path/ident for MetaVarDecls.
Or all is_path_start tokens (in addition to comma) + ty/path/ident for MetaVarDecls if we want to be conservative.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

can_begin_type seems good, tuple declarations really restrict us from changing visibility syntax too much in the future (as we saw during the pub(restricted) debate).

Comment threadsrc/libsyntax/parse/token.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Now the comment // These are not exposed to macros .... applies to NtVis, it's better moved higher in the list.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@DanielKeep why did you not use :vis at the top level of this macro??

@durkadurka changed the title [WIP] :vis matcher for macro_rules:vis matcher for macro_rulesApr 3, 2017
@durka

durka commented Apr 3, 2017

Copy link
Copy Markdown
ContributorAuthor

Comments addressed.

@durka
durkaforce-pushed the vis-matcher branch 2 times, most recently from 6f03265 to 41dcfecCompareApril 3, 2017 02:10
@petrochenkov

Copy link
Copy Markdown
Contributor

LGTM, but needs @rust-lang/lang decision

@petrochenkovpetrochenkov added I-nominated T-lang Relevant to the language team labels Apr 3, 2017
@joshtriplett

Copy link
Copy Markdown
Member

As a note: I observed someone needing this on the #rust IRC channel a few days ago, to avoid hard-coding "pub".

@nrc

nrc commented Apr 3, 2017

Copy link
Copy Markdown
Member

@rfcbot fcp merge

@rfcbot

rfcbot commented Apr 3, 2017

Copy link
Copy Markdown

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

No concerns currently listed.

Once these reviewers reach consensus, 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.

@withoutboats

Copy link
Copy Markdown
Contributor

@rfcbot reviewed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, I'm feeling dense: Why can a vis variable be followed by a comma?

@durkadurkaApr 4, 2017

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

To quote @DanielKeep's rationale from above (hidden comment):

I allowed comma because having some kind of sequence-delimiting token is useful. If you're passing bits of parsed input around, you might have inner!($thing, $a_vis, $more_tts).

This isn't required, we can exclude it and you'd have to use ($a_vis) to pass around parsed visibility fragments within macros.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems harmless to me. I can't imagine using , as an "operator" in a visibility specifier (at last outside of parens or something).

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@pnkfelix are you still worried about this? Should we exclude it in order to get this PR into FCP? I just don't want this to continue languishing for too long...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no its okay; thanks for your patience.

@nrcnrc removed the I-nominated label Apr 6, 2017
@bors

bors commented Apr 7, 2017

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #39987) made this pull request unmergeable. Please resolve the merge conflicts.

@pnkfelix

Copy link
Copy Markdown
Contributor

@rfcbot reviewed

@rfcbot

Copy link
Copy Markdown

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

@rfcbotrfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Apr 14, 2017
@Mark-SimulacrumMark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-team labels Apr 14, 2017
@durka

Copy link
Copy Markdown
ContributorAuthor

Rebased.

@bors

bors commented Apr 15, 2017

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #41312) made this pull request unmergeable. Please resolve the merge conflicts.

@durka

Copy link
Copy Markdown
ContributorAuthor

Rebased.

@aturon

Copy link
Copy Markdown
Contributor

@bors r=petrochenkov

@bors

bors commented Apr 17, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit cfa51f2 has been approved by petrochenkov

@aturonaturon added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 17, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Apr 17, 2017
:vis matcher for macro_rules
Resurrection of @DanielKeep's implementation posted with [RFC 1575](rust-lang/rfcs#1575).
@jseyfried was of the opinion that this doesn't need an RFC.
Needed before merge:
- [x] sign-off from @DanielKeep since I stole his code
- [x] feature gate
- [x] docs
@frewsxcvfrewsxcv mentioned this pull request Apr 17, 2017
bors added a commit that referenced this pull request Apr 17, 2017
Rollup of 3 pull requests
- Successful merges: #41012, #41280, #41290
- Failed merges:
@bors
bors merged commit cfa51f2 into rust-lang:masterApr 17, 2017
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-langRelevant to the language team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

14 participants

@durka@rust-highfive@DanielKeep@petrochenkov@joshtriplett@nrc@rfcbot@withoutboats@bors@pnkfelix@aturon@nikomatsakis@jseyfried@Mark-Simulacrum