Skip to content

initializer & field location info missing in Error message #2388

Open
@MahadMuhammad

Description

@MahadMuhammad

Improving Error Constructor is missing fields - E0063


I tried this code from E0063:

// https://doc.rust-lang.org/error_codes/E0063.html
struct Foo {
    x: i32,
    y: i32,
    z: i32,
}

fn main() {
    let x = Foo { x: 0 , y:1 }; // { dg-error "constructor is missing fields" }
}

I expected to see this happen:

  • Emit error message, similiar to rustc .i.e.,
    • emit the name of initializer & field
  • Error message emitted by rustc:
error[E0063]: missing field `y` in initializer of `Foo`
 --> <source>:7:13
  |
7 |     let x = Foo {  x:0}; // error: missing field: `y`
  |             ^^^ missing `y`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0063`.
Compiler returned: 1

Instead, this happened:

  • No initializer & field information in error messge.
  • This is the output of gccrs:
- missing field `y` in initializer of `Foo` // rustc output
+ error: constructor is missing fields [E0063] // gccrs output
➜  gccrs-build gcc/crab1 /home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/missing_constructor_fields.rs
/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/missing_constructor_fields.rs:9:13: error: constructor is missing fields [E0063]
    9 |     let x = Foo { x: 0 , y:1 }; // { dg-error "constructor is missing fields" }
      |             ^~~

Analyzing compilation unit

Time variable                                   usr           sys          wall           GGC
 TOTAL                              :   0.00          0.00          0.00          146k
Extra diagnostic checks enabled; compiler may run slowly.
Configure with --enable-checking=release to disable checks.

Meta

  • What version of Rust GCC were you using, git sha 5437803.
  • gccrs (Compiler-Explorer-Build-gcc-2f91d511200bf85558c9013b09a458c06edd1e02-binutils-2.40) 13.0.1 20230417 (experimental)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions