Skip to content

syntax: Merge parsing code for structures and variants #29714

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 3 commits into from
Nov 10, 2015

Conversation

petrochenkov
Copy link
Contributor

In particular, attributes are now parsed on fields of tuple variants

@rust-highfive
Copy link
Contributor

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

// For style and consistency reasons, non-parametrized enum variants must
// be used simply as `ident` instead of `ident ()`.
// This test-case covers enum declaration.

enum Foo {
Bar(), //~ ERROR nullary enum variants are written with no trailing `( )`
Baz(), //~ ERROR nullary enum variants are written with no trailing `( )`
Bar(), //~ ERROR empty tuple structs and enum variants are not allowed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is pretty major regression to the error message. It was pretty clearly pointing out at the mistake before and telling how to fix it. Now it seems to suggest it is not allowed altogether, although only the syntax is incorrect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a note then "note: Remove the trailing ()". Good enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tuple structs and enum variants with zero fields are indeed not allowed altogether, it's not just syntax.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a “help: remove trailing () if you meant to write empty enum variant” would be good enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@petrochenkov
Copy link
Contributor Author

r? @nrc
(@alexcrichton is already too busy)

@rust-highfive rust-highfive assigned nrc and unassigned alexcrichton Nov 9, 2015
@@ -867,6 +867,8 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
self.context.span_handler.span_err(span, "empty tuple structs and enum variants \
are not allowed, use unit structs and \
enum variants instead");
self.context.span_handler.span_help(span, "remove trailing `()` if you meant to \
write empty enum variant or structure");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The language here is a little bit confusing I would change to "remove trailing () to make a unit struct or unit enum variant" as the terminology then matches the error message.

@nrc
Copy link
Member

nrc commented Nov 9, 2015

r+ with the enum for bool and typos in the error message fixed.

@petrochenkov
Copy link
Contributor Author

Updated.

@nrc
Copy link
Member

nrc commented Nov 9, 2015

Thanks!

@bors: r+

@bors
Copy link
Collaborator

bors commented Nov 9, 2015

📌 Commit 649fc38 has been approved by nrc

bors added a commit that referenced this pull request Nov 10, 2015
In particular, attributes are now parsed on fields of tuple variants
@bors
Copy link
Collaborator

bors commented Nov 10, 2015

⌛ Testing commit 649fc38 with merge d668fab...

@bors bors merged commit 649fc38 into rust-lang:master Nov 10, 2015
@brson brson added the relnotes Marks issues that should be documented in the release notes of the next release. label Nov 14, 2015
@petrochenkov petrochenkov deleted the strparse branch November 22, 2015 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants