You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a struct literal is initialized with a field name that does not belong to the struct, the result is a compiler error. This error does not have a code which can be looked up with --explain.
Repro
To reproduce, attempt to compile the following:
structS{}fnf(){let s = S{x:0};}
I would expect an error like:
src/main.rs:12:17: 12:18 error: structure `S` has no field named `x` [EXXXX]
src/main.rs:12 let s = S { x: 0 };
src/main.rs:12:20: 12:24 help: run `rustc --explain EXXXX` to see a detailed explanation
...where XXXX is an appropriate error code. Then, when I invoke rustc --explain EXXXX, I expect to see a verbose explanation of the error, which should also appear in the Rust Compiler Error Index.
Instead, the error has only a brief description with no code, and looks like:
src/main.rs:12:17: 12:18 error: structure `S` has no field named `x`
src/main.rs:12 let s = S { x: 0 };
This has since been done, and there are numerous compile-fail tests already which mention this. Closing.
error[E0560]: struct `S` has no field named `x`
--> test.rs:4:17
|
4 | let s = S { x: 0 };
| ^^ `S` does not have this field
error: aborting due to previous error
Summary
When a struct literal is initialized with a field name that does not belong to the struct, the result is a compiler error. This error does not have a code which can be looked up with
--explain
.Repro
To reproduce, attempt to compile the following:
I would expect an error like:
...where
XXXX
is an appropriate error code. Then, when I invokerustc --explain EXXXX
, I expect to see a verbose explanation of the error, which should also appear in the Rust Compiler Error Index.Instead, the error has only a brief description with no code, and looks like:
Meta
The existing compiler error is located in the Rust source in
librustc_typeck/check/mod.rs
.rustc
version info:The text was updated successfully, but these errors were encountered: