-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misleading/confusing error message for TOML type error (for lto profile) #10572
Comments
Nothing so involved is necessary, error messages aren't considered stable. Making Cargo accept |
I am pretty sure (but have not actually checked) that it used to be a boolean property, and then the |
Ah, I did search before but just found a related (but not duplicate) issue is #7491 |
Actually, cargo does little work here. The value itself is passed down into rustc (for both parsing and error message). It's confusing because the message is not from cargo but rustc. I agree the error message could be better, though the deserialization of |
Ah, I see thanks, would it be better to close and re-open there? Unless somebody has the ability to move the issue between repos (if that's a thing). On looking at the code, I see that the only string options that are actually accepted are "thin"/"fat" (ignoring the wildcard case), and then all the other valid values are purely from how the YAML spec specifies boolean values. If I were inclined to change semantics, the shortest possible change is just adding extra cases to the string pattern match (in a backwards compatible way) while keeping the The smallest possible change in general would be to just edit that error message string with something with extra information in like, e.g.
I'm now convinced the true culprit here is YAML's frankly unreasonable permissiveness but there's not much we can do about that. @rustbot label +A-errors |
Error: The feature Please let |
Hmm… I feel like the meaning of I sent myself back to the history and found that the |
Ah yes sorry, TOML not YAML, don't know why I thought that. |
After discussion on the rust side of things, it turns out that rustc's semantics for the CLI args are different than the cargo profile value. Because cargo is just deriving The end result of this is that simply changing the error message in rustc is not correct since rustc and cargo have different accepted values. It was suggested that I add special-cased validation logic here i.e. while the arg is still an unparsed (toml) string, before rustc's All that's left is the choice between the slightly weird option of only special casing if let Some(lto) = &self.lto {
if let StringOrBool::String(a@"true" | a@"false") = lto {
bail!(
"`lto` setting of string `\"{}\"` is not a valid setting, \
must be a boolean `true`/`false` or a string \
`\"yes\"`/`\"no\"`/`\"on\"`/`\"off\"`/`\"y\"`/`\"n\"`/ \
`\"thin\"`/`\"fat\"` or omitted.",
a
);
}
} and the latter would be a negation of the match as allow-list semantics instead of block-list ones. |
Thanks for the investigation. The former looks good to me, though I would try to avoid hardcoding all the LTO options in the message in case of out-of-sync. |
Enable triagebot's relabel functionality ### What does this PR try to resolve? This fixes the following failure that rustbot currently posts whenever someone tries to use "<b>`@</b><b>rustbot</b>` label" in this repository. > **Error**: The feature `relabel` is not enabled in this repository. > To enable it add its section in the `triagebot.toml` in the root of the repository. Unauthenticated relabel has been enabled in rust-lang/rust for nearly 4 years. People overwhelmingly use it in good faith. <br> ### How should we test and review this PR? Compare against https://github.com/rust-lang/rust/blob/1.66.0/triagebot.toml. Also skim through the 7 pages of labels on https://github.com/rust-lang/cargo/labels, whether it makes sense the ones I decided to allow arbitrary GitHub users to apply. <br> ### Additional information Attempted uses of "<b>`@</b><b>rustbot</b>` label", that failed, but this PR would allow: - #10343 (comment) - #10243 (comment) - #9982 (comment) - #9128 (comment) - #9067 (comment) - #8441 (comment) - #11432 (comment) - #8841 (comment) - #10820 (comment) - #10572 (comment) - #9114 (comment) - #8980 (comment) - #9064 (comment) - #8726 (comment) - #8089 (comment)
Problem
I had, in my toml file:
and this results in the error message:
As per the docs, both:
work as expected, but just not the string
"false"
. It's quite surprising to have "false" and be told that a boolean such asyes
was expected instead.Steps
Cargo.toml
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
The text was updated successfully, but these errors were encountered: