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

Maybe alt arms shouldn't allow any blocky expression to omit the comma separator #3107

Closed
brson opened this issue Aug 4, 2012 · 2 comments
Closed
Labels
A-grammar Area: The grammar of Rust
Milestone

Comments

@brson
Copy link
Contributor

brson commented Aug 4, 2012

I made the parser able to parse (most) any expression that ends in a right brace as alt arms without comma separators, so you can write:

alt foo {
    bar => alt bar {
        ...
    }
    baz => alt baz {
        ...
    }
}

whereas other expressions in alt arms must be comma-terminated.

As I'm converting code I think that writing in this style isn't all that clear, mostly is only useful for nested alts and, when I have multi-line alt arms it's usually most readable when the code begins on the next line.

Perhaps this amount of flexibility isn't warranted. You now have to put some thought into how best to format every case, whereas when braces were always required you didn't have any choices.

There are also some bracey expressions that don't follow the optional comma rule - records (which are going away), extensions written with braces, possibly structs (not sure how they're parsed). This makes it just a little bit more inconsistent.

Maybe just making the choice for formatting arms between => expr, and => { } was the right balance after all.

@bblum
Copy link
Contributor

bblum commented Aug 6, 2012

+1. simpler syntax rules are better.

@brson
Copy link
Contributor Author

brson commented Aug 7, 2012

Fixed by 2772b2e

@brson brson closed this as completed Aug 7, 2012
bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
And do some refactoring in comments.rs

Closes rust-lang#3107
RalfJung pushed a commit to RalfJung/rust that referenced this issue Oct 6, 2023
RalfJung pushed a commit to RalfJung/rust that referenced this issue Oct 7, 2023
jaisnan pushed a commit to jaisnan/rust-dev that referenced this issue Jul 29, 2024
Adds a new regression test suite that includes safety contracts for
`core` functions.

For that, we've also improved the memory intrinsics,
and added a few new ones.

One last change was to add a new unsupported check to 
the invalid value workflow for a case that we were missing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-grammar Area: The grammar of Rust
Projects
None yet
Development

No branches or pull requests

2 participants