Skip to content

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
Collaborator

bors commented Jul 17, 2016

📌 Commit bd1ad76 has been approved by eddyb

@bors
Copy link
Collaborator

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
Collaborator

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