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

Suggest missing comma on last field before struct update syntax #100300

Closed
Havvy opened this issue Aug 9, 2022 · 0 comments · Fixed by #100309
Closed

Suggest missing comma on last field before struct update syntax #100300

Havvy opened this issue Aug 9, 2022 · 0 comments · Fixed by #100309
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Havvy
Copy link
Contributor

Havvy commented Aug 9, 2022

Given the following code: [Playground]

#[derive(Default)]
struct Defaultable;

#[derive(Default)]
struct HoldsDefaultable {
    defaultable: Defaultable,
}

fn main() {
    HoldsDefaultable {
      defaultable: Defaultable
      ..Default::default()
    };
}

The current output is:

Compiling playground v0.0.1 (/playground)
error[[E0308]](https://doc.rust-lang.org/stable/error-index.html#E0308): mismatched types
  --> src/main.rs:11:20
   |
11 |         defaultable: Defaultable
   |  ____________________^
12 | |       ..Default::default()
   | |__________________________^ expected struct `Defaultable`, found struct `std::ops::Range`
   |
   = note: expected struct `Defaultable`
              found struct `std::ops::Range<Defaultable>`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground` due to previous error

Ideally the output should suggest adding a comma after Defaultable on line 11 if doing so would solve the type error.

@Havvy Havvy added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 9, 2022
@compiler-errors compiler-errors self-assigned this Aug 9, 2022
@bors bors closed this as completed in 8733550 Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants