-
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
Improve error message displayed when a string is used instead of an array for 'authors' in the manifest #10942
Comments
For now, I think it's challenging to improve it because the internal error will ignore by MaybeWorkspace. [package]
name = "cargo"
version = "0.65.0"
edition = "2021"
license = "MIT OR Apache-2.0"
homepage = "https://crates.io"
repository = "https://github.com/rust-lang/cargo"
documentation = "https://docs.rs/cargo"
readme = "README.md"
description = """
Cargo, a package manager for Rust.
"""
publish = "a"
It should be See more: serde-rs/serde#1544. @epage Do you have any thoughts about how to work around it? |
I saw #10944 try to fix it. Maybe it's a good way. |
Improve errors for TOML fields that support workspace inheritance Fixes #10997 This also addresses the issue with `MaybeWorkspace<VecStringOrBool>` mentioned in #10942: ``` Caused by: invalid type: string "foo", expected a boolean or vector of strings for key `package.publish` ``` I removed the `maybe_workspace_vec_string` deserializer in 7a50c0c because the error message from the inner `Vec<String>` is now surfaced, but I can revert that if it's preferable to keep those changes. I tried to base the `deserialize` implementation off of the derived impl for an untagged enum from `cargo expand`. This approach [ultimately led me](https://github.com/serde-rs/serde/blob/v1.0.144/serde/src/private/de.rs#L218) to adding the `serde-value` dependency.
Problem
Currently, if one uses a string instead of an array of strings as the value for the
authors
field an error message is displayed which is not helpful for a new Rust developer to identify the cause of the problem.Example of an incorrect
Cargo.toml
:The error message displayed is:
Proposed Solution
An error message along the lines of the below would be more informative:
Notes
I also submitted the PR below to update the Cargo documentation to better explain the requirements of the field:
#10938
@epage saw my post on the forum about my problem (link) and suggested that I also submit an issue to improve the error message itself.
Thank you
P. Todd Decker
The text was updated successfully, but these errors were encountered: