Closed

Description
Currently rustc
will allow for extra fields to be added to flexible target json without notifying the user, even with --verbose
. For example, the following is accepted:
{
"THIS-IS-INCORRECT": "but rustc will silently accept it anyway",
"data-layout": "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32",
"llvm-target": "i686-unknown-linux-gnu",
"target-endian": "little",
"target-pointer-width": "32",
"arch": "x86",
"os": "linux",
"morestack": "false",
"pre-link-args": "-nostdlib",
"dynamic_linking": false
}
dynamic_linking
has a underscore separator instead of a hyphen.morestack
is of type bool, but a string was providedpre-link-args
takes an array of strings, but a string was provided
The last three entries have errors that could be easy to miss. This is worrying, because for all the optional fields, simple errors such as misspellings will cause those fields to be discarded and the default values to be used instead. To the programmer it could seem as if the configuration is in place when in reality the compiler simply went with the default value.
I had one of these happen to me earlier and I almost missed it completely. I think that this should at the very least trigger a warning.