mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Add error message for wrong cargo-features placement.
This is intended to help if the user puts cargo-features in the wrong place in Cargo.toml.
This commit is contained in:
parent
73b98edc34
commit
d89a78ee19
@ -69,6 +69,17 @@ fn do_read_manifest(
|
|||||||
parse(contents, pretty_filename, config)?
|
parse(contents, pretty_filename, config)?
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Provide a helpful error message for a common user error.
|
||||||
|
if let Some(package) = toml.get("package").or_else(|| toml.get("project")) {
|
||||||
|
if let Some(feats) = package.get("cargo-features") {
|
||||||
|
bail!(
|
||||||
|
"cargo-features = {} was found in the wrong location, it \
|
||||||
|
should be set at the top of Cargo.toml before any tables",
|
||||||
|
toml::to_string(feats).unwrap()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut unused = BTreeSet::new();
|
let mut unused = BTreeSet::new();
|
||||||
let manifest: TomlManifest = serde_ignored::deserialize(toml, |path| {
|
let manifest: TomlManifest = serde_ignored::deserialize(toml, |path| {
|
||||||
let mut key = String::new();
|
let mut key = String::new();
|
||||||
|
@ -327,3 +327,32 @@ fn publish_allowed() {
|
|||||||
.masquerade_as_nightly_cargo()
|
.masquerade_as_nightly_cargo()
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn wrong_position() {
|
||||||
|
let p = project()
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[package]
|
||||||
|
name = "foo"
|
||||||
|
version = "0.1.0"
|
||||||
|
cargo-features = ["test-dummy-unstable"]
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("src/lib.rs", "")
|
||||||
|
.build();
|
||||||
|
p.cargo("check")
|
||||||
|
.masquerade_as_nightly_cargo()
|
||||||
|
.with_status(101)
|
||||||
|
.with_stderr(
|
||||||
|
"\
|
||||||
|
error: failed to parse manifest at [..]
|
||||||
|
|
||||||
|
Caused by:
|
||||||
|
cargo-features = [\"test-dummy-unstable\"] was found in the wrong location, it \
|
||||||
|
should be set at the top of Cargo.toml before any tables
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user