Skip to content

Diagnostic could be more helpful for missing comma when using .. field initialization copy operator. #51103

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

Closed
vi opened this issue May 27, 2018 · 0 comments · Fixed by #94939
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@vi
Copy link
Contributor

vi commented May 27, 2018

#[derive(Default)]
struct A {
    b: u32,
    c: u64,
    d: usize,
}

fn main() {
    let q = A { c: 5 .. Default::default() };
}
error[E0308]: mismatched types
 --> src/main.rs:9:20
  |
9 |     let q = A { c: 5 .. Default::default() };
  |                    ^^^^^^^^^^^^^^^^^^^^^^^ expected u64, found struct `std::ops::Range`
  |
  = note: expected type `u64`
             found type `std::ops::Range<{integer}>`

error[E0063]: missing fields `b`, `d` in initializer of `A`
 --> src/main.rs:9:13
  |
9 |     let q = A { c: 5 .. Default::default() };
  |             ^ missing `b`, `d`

error: aborting due to 2 previous errors

Maybe it should suggest proper syntax when there are both missing fields and std::ops::Range-related error somewhere?

@vi vi changed the title Diagnostic could be more helpful for missing comma when using .. range operator. Diagnostic could be more helpful for missing comma when using .. field initialization copy operator. May 27, 2018
@XAMPPRocky XAMPPRocky added C-enhancement Category: An issue proposing an enhancement or a PR with one. 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 Oct 2, 2018
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Mar 27, 2022
…stion, r=cjgillot

diagnostics: suggest missing comma in bad FRU syntax

Fixes rust-lang#51103
@bors bors closed this as completed in 301fc07 Mar 28, 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 C-enhancement Category: An issue proposing an enhancement or a PR with one. 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