-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Don’t swallow virtual manifest parsing errors #4828
Conversation
Before this change, `cargo::util::toml::do_read_manifest` ended like this: ```rust return match TomlManifest::to_real_manifest(/* … */) { Ok(/* … */) => /* … */, Err(e) => match TomlManifest::to_virtual_manifest(/* … */) { Ok(/* … */) => /* … */, Err(..) => Err(e), } }; ``` Errors returned by `to_virtual_manifest` were always ignored. As a result, when something was wrong in a virtual manifest, Cargo would unhelpfully exit with no more output than: ``` error: failed to parse manifest at `/tmp/a/Cargo.toml` Caused by: no `package` section found. ``` http://doc.crates.io/manifest.html#virtual-manifest defines a virtual manifest as “the `package` table is not present”, so let’s first determine if a manifest is virtual based on that criteria, and then only call one of the two methods. Although it is not mentioned in the documentation, `[project]` seems to be in the code an alias for `[package]`. So let’s preserve that here too.
(rust_highfive has picked a reviewer for you, use r? to override) |
By the way, this is unrelated to the point of this PR but the code being modified also implements a “unused manifest key”, but only for non-virtual manifest. Is there a reason for that, or should the warning also apply to virtual manifests? |
@bors: r+ Looks great, thanks! Also yeah seems plausible to me to warn about unused keys on virtual manifests as well! |
📌 Commit 3e06033 has been approved by |
Don’t swallow virtual manifest parsing errors Before this change, `cargo::util::toml::do_read_manifest` ended like this: ```rust return match TomlManifest::to_real_manifest(/* … */) { Ok(/* … */) => /* … */, Err(e) => match TomlManifest::to_virtual_manifest(/* … */) { Ok(/* … */) => /* … */, Err(..) => Err(e), } }; ``` Errors returned by `to_virtual_manifest` were always ignored. As a result, when something was wrong in a virtual manifest, Cargo would unhelpfully exit with no more output than: ``` error: failed to parse manifest at `/tmp/a/Cargo.toml` Caused by: no `package` section found. ``` http://doc.crates.io/manifest.html#virtual-manifest defines a virtual manifest as “the `package` table is not present”, so let’s first determine if a manifest is virtual based on that criteria, and then only call one of the two methods. Although it is not mentioned in the documentation, `[project]` seems to be in the code an alias for `[package]`. So let’s preserve that here too.
☀️ Test successful - status-appveyor, status-travis |
Before this change,
cargo::util::toml::do_read_manifest
ended like this:Errors returned by
to_virtual_manifest
were always ignored. As a result, when something was wrong in a virtual manifest, Cargo would unhelpfully exit with no more output than:http://doc.crates.io/manifest.html#virtual-manifest defines a virtual manifest as “the
package
table is not present”, so let’s first determine if a manifest is virtual based on that criteria, and then only call one of the two methods.Although it is not mentioned in the documentation,
[project]
seems to be in the code an alias for[package]
. So let’s preserve that here too.