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

Require structs to use newtype form or have at least one field #5167

Closed
nikomatsakis opened this issue Feb 28, 2013 · 3 comments
Closed

Require structs to use newtype form or have at least one field #5167

nikomatsakis opened this issue Feb 28, 2013 · 3 comments
Labels
A-parser Area: The parsing of Rust source code to an AST

Comments

@nikomatsakis
Copy link
Contributor

Per this thread on the mailing list, structs should be required to either be written struct Foo; or to have at least one field. This avoids various ambiguities when parsing.

@thomaslee
Copy link
Contributor

Is this as simple as modifying the parser to prevent the "struct Foo {}" syntax (i.e. a struct with no fields) & modifying it to support the braceless syntax, or is more work needed to make it a newtype? And if so, what?

@huonw
Copy link
Member

huonw commented Apr 4, 2013

@thomaslee, this seems to have been done already:

$ cat empty-struct.rs
struct A {}
fn main() {}

$ rustc empty-struct.rs
empty-struct.rs:1:10: 1:11 error: Unit-like struct should be written as: struct A;
empty-struct.rs:1 struct A {}
                            ^

(ping @nikomatsakis, you can probably close this.)

@thomaslee
Copy link
Contributor

Ah good catch @dbaupp -- thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST
Projects
None yet
Development

No branches or pull requests

4 participants