Open
Description
Improving Error Constructor is missing fields - E0063
- Fixing this issue, help [E0063] constructor is missing fields #2387 to emit more user friendly error code and error emission similiar to rustc.
- You can view the same on
compiler-explorer
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
- emit the name of
- 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)