Skip to content

Add support for arms in macros and quotes, fix a pretty printer bug, and other minor features #16037

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

Merged
merged 5 commits into from
Jul 30, 2014

Conversation

erickt
Copy link
Contributor

@erickt erickt commented Jul 28, 2014

This adds support for quote_arm!(cx, $pat => $expr), and macro_rules!(($a:arm) => (...)). It also fixes a bug in pretty printing, where this would generate invalid code:

match { 5i } {
    1 => 2,
    _ => 3,
}

It would generate this code:

match { 5i } {
    1 => 2
    _ => 3
}

Finally, it adds a couple helper methods to ExtCtxt.

@alexcrichton
Copy link
Member

This looks like it also adds a $foo:arm matcher for macros, was that intentional?

@erickt
Copy link
Contributor Author

erickt commented Jul 28, 2014

@alexcrichton: oops, it wasn't, but that could be useful. For now I'll factor that bit out and see if I can add support for it in a future PR.

@killerswan
Copy link
Contributor

Oooh, if quote_arm does what I think it does, I have a use for it right now. :D

@erickt
Copy link
Contributor Author

erickt commented Jul 28, 2014

@killerswan: I hope so! I using it to great effect in https://github.com/erickt/rust-serde/blob/master/serde_macros/src/lib.rs#L381. It really helps to simplify down complex syntax extensions. Plus it makes the extensions a bit more independent from the actual ast, which is also handy.

@erickt erickt changed the title Add support for quoting arms, fix a pretty printer bug, and other minor features Add support for arms in macros and quotes, fix a pretty printer bug, and other minor features Jul 28, 2014
@erickt
Copy link
Contributor Author

erickt commented Jul 28, 2014

@alexcrichton: It turns out it was pretty simple to add $a:arm matchers, so I added it in this PR as well.

@alexcrichton
Copy link
Member

I don't think we've extended the macro matchers much recently, but it may be RFC-worty to add an arm matcher (unsure).

@erickt
Copy link
Contributor Author

erickt commented Jul 30, 2014

@bors: retry

bors added a commit that referenced this pull request Jul 30, 2014
This adds support for `quote_arm!(cx, $pat => $expr)`, and `macro_rules!(($a:arm) => (...))`. It also fixes a bug in pretty printing, where this would generate invalid code:

```
match { 5i } {
    1 => 2,
    _ => 3,
}
```

It would generate this code:

```
match { 5i } {
    1 => 2
    _ => 3
}
```

Finally, it adds a couple helper methods to `ExtCtxt`.
@bors bors closed this Jul 30, 2014
@bors bors merged commit e841a88 into rust-lang:master Jul 30, 2014
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 11, 2023
fix: Don't print proc-macro panic backtraces in the logs

Fixes rust-lang/rust-analyzer#9859
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.

4 participants