Skip to content

Fix invalid shorthand initialization diagnostic for tuple structs #4857

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

Conversation

optimalstrategy
Copy link
Contributor

Initializing tuple structs explicitly, like in the example below, produces a "Shorthand struct initialization" diagnostic that leads to a compilation error when applied:

struct S(usize);

fn main() { 
    let s = S { 0: 0 };  // OK, but triggers the diagnostic
    // let s = S { 0 };  // Compilation error
}

This PR adds a check that the field name is not a literal.

@jonas-schievink
Copy link
Contributor

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 12, 2020

@bors bors bot merged commit b56ad14 into rust-lang:master Jun 12, 2020
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.

2 participants