Skip to content

A scheme for more macro-matcher friendly pre-expansion gating #65974

New issue

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

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

Already on GitHub? # to your account

Merged
merged 2 commits into from
Nov 7, 2019

Conversation

Centril
Copy link
Contributor

@Centril Centril commented Oct 30, 2019

Pre-expansion gating will now avoid gating macro matchers that did not result in Success(...). That is, the following is now OK despite box 42 being a valid expr and that form being pre-expansion gated:

macro_rules! m {
    ($e:expr) => { 0 }; // This fails on the input below due to `, foo`.
    (box $e:expr, foo) => { 1 }; // Successful matcher, we should get `2`.
}

fn main() {
    assert_eq!(1, m!(box 42, foo));
}

Closes #65846.

r? @petrochenkov
cc @Mark-Simulacrum

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 30, 2019
@petrochenkov petrochenkov 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-review Status: Awaiting review from the assignee but also interested parties. labels Nov 2, 2019
@bors

This comment has been minimized.

@Centril Centril force-pushed the matcher-friendly-gating branch from e6d4cd6 to acbfe3f Compare November 6, 2019 10:24
@Centril Centril force-pushed the matcher-friendly-gating branch from 3dbf9fb to bceaba8 Compare November 6, 2019 11:30
@Centril Centril added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 6, 2019
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Nov 6, 2019

📌 Commit bceaba8 has been approved by petrochenkov

@bors bors 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-review Status: Awaiting review from the assignee but also interested parties. labels Nov 6, 2019
Centril added a commit to Centril/rust that referenced this pull request Nov 7, 2019
…petrochenkov

A scheme for more macro-matcher friendly pre-expansion gating

Pre-expansion gating will now avoid gating macro matchers that did not result in `Success(...)`. That is, the following is now OK despite `box 42` being a valid `expr` and that form being pre-expansion gated:

```rust
macro_rules! m {
    ($e:expr) => { 0 }; // This fails on the input below due to `, foo`.
    (box $e:expr, foo) => { 1 }; // Successful matcher, we should get `2`.
}

fn main() {
    assert_eq!(1, m!(box 42, foo));
}
```

Closes rust-lang#65846.

r? @petrochenkov
cc @Mark-Simulacrum
bors added a commit that referenced this pull request Nov 7, 2019
Rollup of 5 pull requests

Successful merges:

 - #59789 (Revert two unapproved changes to rustc_typeck.)
 - #65752 (Use structured suggestions for missing associated items)
 - #65884 (syntax: ABI-oblivious grammar)
 - #65974 (A scheme for more macro-matcher friendly pre-expansion gating)
 - #66017 (Add future incompatibility lint for `array.into_iter()`)

Failed merges:

 - #66056 (rustc_metadata: Some reorganization of the module structure)

r? @ghost
@bors bors merged commit bceaba8 into rust-lang:master Nov 7, 2019
@Centril Centril deleted the matcher-friendly-gating branch November 7, 2019 11:40
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pre-expansion gating collects spans from unSuccessful macro matchers
5 participants