Description
Problem
I had, in my toml file:
[profile.dev]
lto="false"
and this results in the error message:
error: incorrect value `false` for codegen option `lto` - either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted was expected
As per the docs, both:
[profile.dev]
lto=false
[profile.dev]
lto="off"
work as expected, but just not the string "false"
. It's quite surprising to have "false" and be told that a boolean such as yes
was expected instead.
Steps
- put the following in your
Cargo.toml
[profile.dev]
lto="false"
- run
cargo build
Possible Solution(s)
I propose that the error message clarify this string vs bool (I note it doesn't include "false" in the list of valid booleans), possibly special cased to the strings "true"
or "false"
. Presumably this behaviour is like this for legacy reasons, believe me I've been there myself.
I would prefer (by which I mean, I think it's more intuitive) if the strings true/false were also accepted, which also allows for potentially deprecating the legacy yaml bools, but I understand that it's redundant and also a semantics change.
Notes
I'm happy enough to make this change myself, the error message change doesn't seem too bad but I don't exactly have the attention span the shepherd a breaking change through an RFC and a deprecation cycle or whatever.
Version
cargo 1.62.0-nightly (dba5baf 2022-04-13)
release: 1.62.0-nightly
commit-hash: dba5baf4345858c591517b24801902a062c399f8
commit-date: 2022-04-13
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1m)
os: Debian 10 (buster) [64-bit]