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

macros: fix bug in stmt matchers #34886

Merged
merged 2 commits into from
Jul 18, 2016
Merged

Conversation

jseyfried
Copy link
Contributor

@jseyfried jseyfried commented Jul 17, 2016

Today, stmt matchers stop too early when parsing expression statements that begin with non-braced macro invocations. For example,

fn main() {
    macro_rules! m { ($s:stmt;) => { $s } }
    id!(vec![].push(0););
    //^ Before this PR, the `stmt` matcher only consumes "vec![]", so this is an error.
    //| After this PR, the `stmt` matcher consumes "vec![].push(0)", so this compiles.
}

This change is backwards compatible due to the follow set for stmt.

r? @eddyb

@jseyfried
Copy link
Contributor Author

jseyfried commented Jul 17, 2016

cc @nrc
c.f. #34660

@eddyb
Copy link
Member

eddyb commented Jul 17, 2016

@bors r+

@bors
Copy link
Contributor

bors commented Jul 17, 2016

📌 Commit bd1ad76 has been approved by eddyb

@bors
Copy link
Contributor

bors commented Jul 18, 2016

⌛ Testing commit bd1ad76 with merge 06ca016...

bors added a commit that referenced this pull request Jul 18, 2016
macros: fix bug in `stmt` matchers

Today, `stmt` matchers stop too early when parsing expression statements that begin with non-braced macro invocations. For example,
```rust
fn main() {
    macro_rules! m { ($s:stmt;) => { $s } }
    id!(vec![].push(0););
    //^ Before this PR, the `stmt` matcher only consumes "vec![]", so this is an error.
    //| After this PR, the `stmt` matcher consumes "vec![].push(0)", so this compiles.
}
```
This change is backwards compatible due to the follow set for `stmt`.

r? @eddyb
@bors
Copy link
Contributor

bors commented Jul 18, 2016

💔 Test failed - auto-win-msvc-64-opt-mir

@jseyfried
Copy link
Contributor Author

@bors force retry

@bors bors merged commit bd1ad76 into rust-lang:master Jul 18, 2016
@jseyfried jseyfried deleted the improve_stmt_matchers branch October 16, 2016 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants