mirror of
https://github.com/rust-lang/cargo
synced 2024-08-25 10:35:53 +00:00
Auto merge of #9681 - hi-rustin:rustin-patch-reject, r=ehuss
Warning when using features in replace close https://github.com/rust-lang/cargo/issues/3034 close https://github.com/rust-lang/cargo/issues/2582 r? `@ehuss`
This commit is contained in:
commit
9535dc3dfd
|
@ -115,6 +115,16 @@ pub fn resolve_ws_with_opts<'cfg>(
|
|||
.shell()
|
||||
.warn(format!("package replacement is not used: {}", replace_spec))?
|
||||
}
|
||||
|
||||
if dep.features().len() != 0 || !dep.uses_default_features() {
|
||||
ws.config()
|
||||
.shell()
|
||||
.warn(format!(
|
||||
"replacement for `{}` uses the features mechanism. \
|
||||
default-features and features will not take effect because the replacement dependency does not support this mechanism",
|
||||
dep.package_name()
|
||||
))?
|
||||
}
|
||||
}
|
||||
|
||||
Some(resolve)
|
||||
|
|
|
@ -52,6 +52,104 @@ fn override_simple() {
|
|||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn override_with_features() {
|
||||
Package::new("bar", "0.1.0").publish();
|
||||
|
||||
let bar = git::repo(&paths::root().join("override"))
|
||||
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
||||
.file("src/lib.rs", "pub fn bar() {}")
|
||||
.build();
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
&format!(
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
bar = "0.1.0"
|
||||
|
||||
[replace]
|
||||
"bar:0.1.0" = {{ git = '{}', features = ["some_feature"] }}
|
||||
"#,
|
||||
bar.url()
|
||||
),
|
||||
)
|
||||
.file(
|
||||
"src/lib.rs",
|
||||
"extern crate bar; pub fn foo() { bar::bar(); }",
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build")
|
||||
.with_stderr(
|
||||
"\
|
||||
[UPDATING] [..] index
|
||||
[UPDATING] git repository `[..]`
|
||||
[WARNING] replacement for `bar` uses the features mechanism. default-features and features \
|
||||
will not take effect because the replacement dependency does not support this mechanism
|
||||
[COMPILING] bar v0.1.0 (file://[..])
|
||||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn override_with_setting_default_features() {
|
||||
Package::new("bar", "0.1.0").publish();
|
||||
|
||||
let bar = git::repo(&paths::root().join("override"))
|
||||
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
||||
.file("src/lib.rs", "pub fn bar() {}")
|
||||
.build();
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
&format!(
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
bar = "0.1.0"
|
||||
|
||||
[replace]
|
||||
"bar:0.1.0" = {{ git = '{}', default-features = false, features = ["none_default_feature"] }}
|
||||
"#,
|
||||
bar.url()
|
||||
),
|
||||
)
|
||||
.file(
|
||||
"src/lib.rs",
|
||||
"extern crate bar; pub fn foo() { bar::bar(); }",
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build")
|
||||
.with_stderr(
|
||||
"\
|
||||
[UPDATING] [..] index
|
||||
[UPDATING] git repository `[..]`
|
||||
[WARNING] replacement for `bar` uses the features mechanism. default-features and features \
|
||||
will not take effect because the replacement dependency does not support this mechanism
|
||||
[COMPILING] bar v0.1.0 (file://[..])
|
||||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn missing_version() {
|
||||
let p = project()
|
||||
|
|
Loading…
Reference in a new issue