mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Warning on conflicting default_features keys
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
This commit is contained in:
parent
ed93c94bd1
commit
460ea25377
@ -1922,6 +1922,13 @@ impl<P: ResolveToPath> DetailedTomlDependency<P> {
|
|||||||
|
|
||||||
let version = self.version.as_deref();
|
let version = self.version.as_deref();
|
||||||
let mut dep = Dependency::parse(pkg_name, version, new_source_id)?;
|
let mut dep = Dependency::parse(pkg_name, version, new_source_id)?;
|
||||||
|
if self.default_features.is_some() && self.default_features2.is_some() {
|
||||||
|
cx.warnings.push(format!(
|
||||||
|
"found both `default-features` and `default_features` are set \
|
||||||
|
in the `{}` dependency",
|
||||||
|
name_in_toml
|
||||||
|
));
|
||||||
|
}
|
||||||
dep.set_features(self.features.iter().flatten())
|
dep.set_features(self.features.iter().flatten())
|
||||||
.set_default_features(
|
.set_default_features(
|
||||||
self.default_features
|
self.default_features
|
||||||
|
@ -2067,3 +2067,42 @@ Caused by:
|
|||||||
)
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn default_features_conflicting_warning() {
|
||||||
|
let p = project()
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[package]
|
||||||
|
name = "foo"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = []
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
a = { path = "a", features = ["f1"], default-features = false, default_features = false }
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("src/lib.rs", "")
|
||||||
|
.file(
|
||||||
|
"a/Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[package]
|
||||||
|
name = "a"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = []
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["f1"]
|
||||||
|
f1 = []
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("a/src/lib.rs", "")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
p.cargo("build")
|
||||||
|
.with_stderr_contains(
|
||||||
|
"[WARNING] found both `default-features` and `default_features` are set in the `a` dependency",
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user