From 375ccd2f4ac8130c12712de17875e13bb87ac85b Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Sat, 22 Jan 2022 12:55:19 +0800 Subject: [PATCH 1/8] Warning on conflicting proc_macro Signed-off-by: hi-rustin --- src/cargo/util/toml/mod.rs | 10 ++++++++++ src/cargo/util/toml/targets.rs | 1 + tests/testsuite/proc_macro.rs | 24 ++++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 69de9be3a2f..fa036284300 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -2057,6 +2057,16 @@ impl TomlTarget { } } + fn validate_proc_macro(&self, warnings: &mut Vec) { + if self.proc_macro_raw.is_some() && self.proc_macro_raw2.is_some() { + warnings.push(format!( + "found both `proc-macro` and `proc_macro` are set \ + in the `{}` library", + self.name() + )); + } + } + fn proc_macro(&self) -> Option { self.proc_macro_raw.or(self.proc_macro_raw2).or_else(|| { if let Some(types) = self.crate_types() { diff --git a/src/cargo/util/toml/targets.rs b/src/cargo/util/toml/targets.rs index 13aec29a4e8..08acb0286f1 100644 --- a/src/cargo/util/toml/targets.rs +++ b/src/cargo/util/toml/targets.rs @@ -174,6 +174,7 @@ fn clean_lib( Some(ref lib) => lib, None => return Ok(None), }; + lib.validate_proc_macro(warnings); validate_target_name(lib, "library", "lib", warnings)?; diff --git a/tests/testsuite/proc_macro.rs b/tests/testsuite/proc_macro.rs index 12ff56284a8..2d2f784c9d8 100644 --- a/tests/testsuite/proc_macro.rs +++ b/tests/testsuite/proc_macro.rs @@ -387,6 +387,30 @@ fn proc_macro_crate_type_warning() { .run(); } +#[cargo_test] +fn proc_macro_conflicting_warning() { + let foo = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + [lib] + proc-macro = false + proc_macro = true + "#, + ) + .file("src/lib.rs", "") + .build(); + + foo.cargo("build") + .with_stderr_contains( + "[WARNING] found both `proc-macro` and `proc_macro` are set in the `foo` library", + ) + .run(); +} + #[cargo_test] fn proc_macro_crate_type_warning_plugin() { let foo = project() From a317aff9b8ec23ee209288a0aa696a02638eab88 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Sun, 23 Jan 2022 17:20:39 +0800 Subject: [PATCH 2/8] Warning on conflicting crate_types keys Signed-off-by: hi-rustin --- src/cargo/util/toml/mod.rs | 13 +++++- src/cargo/util/toml/targets.rs | 2 + tests/testsuite/build.rs | 72 ++++++++++++++++++++++++++++++++++ tests/testsuite/proc_macro.rs | 2 +- 4 files changed, 87 insertions(+), 2 deletions(-) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index fa036284300..22447668ff9 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -2061,7 +2061,7 @@ impl TomlTarget { if self.proc_macro_raw.is_some() && self.proc_macro_raw2.is_some() { warnings.push(format!( "found both `proc-macro` and `proc_macro` are set \ - in the `{}` library", + in the `{}` library target", self.name() )); } @@ -2078,6 +2078,17 @@ impl TomlTarget { }) } + fn validate_crate_types(&self, target_kind_human: &str, warnings: &mut Vec) { + if self.crate_type.is_some() && self.crate_type2.is_some() { + warnings.push(format!( + "found both `crate-type` and `crate_type` are set \ + in the `{}` {} target", + self.name(), + target_kind_human + )); + } + } + fn crate_types(&self) -> Option<&Vec> { self.crate_type .as_ref() diff --git a/src/cargo/util/toml/targets.rs b/src/cargo/util/toml/targets.rs index 08acb0286f1..ac9bf468af5 100644 --- a/src/cargo/util/toml/targets.rs +++ b/src/cargo/util/toml/targets.rs @@ -175,6 +175,7 @@ fn clean_lib( None => return Ok(None), }; lib.validate_proc_macro(warnings); + lib.validate_crate_types("library", warnings); validate_target_name(lib, "library", "lib", warnings)?; @@ -399,6 +400,7 @@ fn clean_examples( let mut result = Vec::new(); for (path, toml) in targets { + toml.validate_crate_types("example", warnings); let crate_types = match toml.crate_types() { Some(kinds) => kinds.iter().map(|s| s.into()).collect(), None => Vec::new(), diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 70550431a35..43eb3ec8e97 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -1676,6 +1676,78 @@ Caused by: .run(); } +#[cargo_test] +fn lib_crate_types_conflicting_warning() { + let p = project() + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.5.0" + authors = ["wycats@example.com"] + + [lib] + name = "foo" + crate-type = ["rlib", "dylib"] + crate_type = ["staticlib", "dylib"] + "#, + ) + .file("src/lib.rs", "pub fn foo() {}") + .build(); + p.cargo("build") + .with_stderr_contains( + "[WARNING] found both `crate-type` and `crate_type` are set in the `foo` library target", + ) + .run(); +} + +#[cargo_test] +fn examples_crate_types_conflicting_warning() { + let p = project() + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.5.0" + authors = ["wycats@example.com"] + + [[example]] + name = "ex" + path = "examples/ex.rs" + crate-type = ["rlib", "dylib"] + crate_type = ["proc_macro"] + [[example]] + name = "goodbye" + path = "examples/ex-goodbye.rs" + crate-type = ["rlib", "dylib"] + crate_type = ["rlib", "staticlib"] + "#, + ) + .file("src/lib.rs", "") + .file( + "examples/ex.rs", + r#" + fn main() { println!("ex"); } + "#, + ) + .file( + "examples/ex-goodbye.rs", + r#" + fn main() { println!("goodbye"); } + "#, + ) + .build(); + p.cargo("build") + .with_stderr_contains( + "\ +[WARNING] found both `crate-type` and `crate_type` are set in the `ex` example target +[WARNING] found both `crate-type` and `crate_type` are set in the `goodbye` example target", + ) + .run(); +} + #[cargo_test] fn self_dependency() { let p = project() diff --git a/tests/testsuite/proc_macro.rs b/tests/testsuite/proc_macro.rs index 2d2f784c9d8..c40d6a1535b 100644 --- a/tests/testsuite/proc_macro.rs +++ b/tests/testsuite/proc_macro.rs @@ -406,7 +406,7 @@ fn proc_macro_conflicting_warning() { foo.cargo("build") .with_stderr_contains( - "[WARNING] found both `proc-macro` and `proc_macro` are set in the `foo` library", + "[WARNING] found both `proc-macro` and `proc_macro` are set in the `foo` library target", ) .run(); } From 154f372b6b5b543ad04bc7e82eb1c5fc41190621 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Wed, 9 Feb 2022 21:59:26 +0800 Subject: [PATCH 3/8] Warning on conflicting dev-dependencies keys Signed-off-by: hi-rustin --- src/cargo/util/toml/mod.rs | 7 +++++++ tests/testsuite/build.rs | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 22447668ff9..f520547366b 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -1264,6 +1264,13 @@ impl TomlManifest { // Collect the dependencies. process_dependencies(&mut cx, me.dependencies.as_ref(), None)?; + if me.dev_dependencies.is_some() && me.dev_dependencies2.is_some() { + cx.warnings.push(format!( + "found both `dev-dependencies` and `dev_dependencies` are set \ + in the `{}` package", + package_name + )); + } let dev_deps = me .dev_dependencies .as_ref() diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 43eb3ec8e97..471cc3476c3 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -1676,6 +1676,41 @@ Caused by: .run(); } +#[cargo_test] +fn dev_dependencies_conflicting_warning() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + edition = "2018" + + [dev-dependencies] + a = {path = "a"} + [dev_dependencies] + a = {path = "a"} + "#, + ) + .file("src/lib.rs", "") + .file( + "a/Cargo.toml", + r#" + [package] + name = "a" + version = "0.0.1" + "#, + ) + .file("a/src/lib.rs", "") + .build(); + p.cargo("build") + .with_stderr_contains( + "[WARNING] found both `dev-dependencies` and `dev_dependencies` are set in the `foo` package", + ) + .run(); +} + #[cargo_test] fn lib_crate_types_conflicting_warning() { let p = project() From ed93c94bd168b09ee8ca46270412bb864b8efd68 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Wed, 9 Feb 2022 22:02:18 +0800 Subject: [PATCH 4/8] Warning on conflicting build_dependencies keys Signed-off-by: hi-rustin --- src/cargo/util/toml/mod.rs | 7 +++++++ tests/testsuite/build.rs | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index f520547366b..4685fb71026 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -1276,6 +1276,13 @@ impl TomlManifest { .as_ref() .or_else(|| me.dev_dependencies2.as_ref()); process_dependencies(&mut cx, dev_deps, Some(DepKind::Development))?; + if me.build_dependencies.is_some() && me.build_dependencies2.is_some() { + cx.warnings.push(format!( + "found both `build-dependencies` and `build_dependencies` are set \ + in the `{}` package", + package_name + )); + } let build_deps = me .build_dependencies .as_ref() diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 471cc3476c3..a24a796b167 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -1711,6 +1711,41 @@ fn dev_dependencies_conflicting_warning() { .run(); } +#[cargo_test] +fn build_dependencies_conflicting_warning() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + edition = "2018" + + [build-dependencies] + a = {path = "a"} + [build_dependencies] + a = {path = "a"} + "#, + ) + .file("src/lib.rs", "") + .file( + "a/Cargo.toml", + r#" + [package] + name = "a" + version = "0.0.1" + "#, + ) + .file("a/src/lib.rs", "") + .build(); + p.cargo("build") + .with_stderr_contains( + "[WARNING] found both `build-dependencies` and `build_dependencies` are set in the `foo` package", + ) + .run(); +} + #[cargo_test] fn lib_crate_types_conflicting_warning() { let p = project() From 460ea25377d797f1bf8a4e1d7679eb99b8175ec4 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Wed, 9 Feb 2022 22:15:29 +0800 Subject: [PATCH 5/8] Warning on conflicting default_features keys Signed-off-by: hi-rustin --- src/cargo/util/toml/mod.rs | 7 +++++++ tests/testsuite/features.rs | 39 +++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 4685fb71026..44fef2d67e0 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -1922,6 +1922,13 @@ impl DetailedTomlDependency

{ let version = self.version.as_deref(); 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()) .set_default_features( self.default_features diff --git a/tests/testsuite/features.rs b/tests/testsuite/features.rs index 8a8ed78e595..01e06013a15 100644 --- a/tests/testsuite/features.rs +++ b/tests/testsuite/features.rs @@ -2067,3 +2067,42 @@ Caused by: ) .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(); +} From ad375afa7a1cfcf6fb6691160775bf782553d828 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Wed, 9 Feb 2022 22:31:09 +0800 Subject: [PATCH 6/8] Warning on conflicting build_dependencies keys of platform Signed-off-by: hi-rustin --- src/cargo/util/toml/mod.rs | 7 +++++++ tests/testsuite/build.rs | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 44fef2d67e0..c47ba00bc0f 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -1296,6 +1296,13 @@ impl TomlManifest { Some(platform) }; process_dependencies(&mut cx, platform.dependencies.as_ref(), None)?; + if platform.build_dependencies.is_some() && platform.build_dependencies2.is_some() { + cx.warnings.push(format!( + "found both `build-dependencies` and `build_dependencies` are set \ + in the `{}` platform target", + name + )); + } let build_deps = platform .build_dependencies .as_ref() diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index a24a796b167..a3afe1704db 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -2983,6 +2983,46 @@ fn cargo_platform_specific_dependency() { p.cargo("test").run(); } +#[cargo_test] +fn cargo_platform_specific_dependency_build_dependencies_conflicting_warning() { + let host = rustc_host(); + let p = project() + .file( + "Cargo.toml", + &format!( + r#" + [project] + name = "foo" + version = "0.5.0" + authors = ["wycats@example.com"] + build = "build.rs" + + [target.{host}.build-dependencies] + build = {{ path = "build" }} + [target.{host}.build_dependencies] + build = {{ path = "build" }} + "#, + host = host + ), + ) + .file("src/main.rs", "fn main() { }") + .file( + "build.rs", + "extern crate build; fn main() { build::build(); }", + ) + .file("build/Cargo.toml", &basic_manifest("build", "0.5.0")) + .file("build/src/lib.rs", "pub fn build() {}") + .build(); + + p.cargo("build") + .with_stderr_contains( + format!("[WARNING] found both `build-dependencies` and `build_dependencies` are set in the `{}` platform target", host), + ) + .run(); + + assert!(p.bin("foo").is_file()); +} + #[cargo_test] fn bad_platform_specific_dependency() { let p = project() From b295e2fd674307689191f1faf4aa8aae92aa75e9 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Wed, 9 Feb 2022 22:39:33 +0800 Subject: [PATCH 7/8] Warning on conflicting dev_dependencies keys of platform Signed-off-by: hi-rustin --- src/cargo/util/toml/mod.rs | 7 +++++++ tests/testsuite/build.rs | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index c47ba00bc0f..51fc86b9dfc 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -1308,6 +1308,13 @@ impl TomlManifest { .as_ref() .or_else(|| platform.build_dependencies2.as_ref()); process_dependencies(&mut cx, build_deps, Some(DepKind::Build))?; + if platform.dev_dependencies.is_some() && platform.dev_dependencies2.is_some() { + cx.warnings.push(format!( + "found both `dev-dependencies` and `dev_dependencies` are set \ + in the `{}` platform target", + name + )); + } let dev_deps = platform .dev_dependencies .as_ref() diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index a3afe1704db..59cb97a998d 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -3023,6 +3023,46 @@ fn cargo_platform_specific_dependency_build_dependencies_conflicting_warning() { assert!(p.bin("foo").is_file()); } +#[cargo_test] +fn cargo_platform_specific_dependency_dev_dependencies_conflicting_warning() { + let host = rustc_host(); + let p = project() + .file( + "Cargo.toml", + &format!( + r#" + [project] + name = "foo" + version = "0.5.0" + authors = ["wycats@example.com"] + + [target.{host}.dev-dependencies] + dev = {{ path = "dev" }} + [target.{host}.dev_dependencies] + dev = {{ path = "dev" }} + "#, + host = host + ), + ) + .file("src/main.rs", "fn main() { }") + .file( + "tests/foo.rs", + "extern crate dev; #[test] fn foo() { dev::dev() }", + ) + .file("dev/Cargo.toml", &basic_manifest("dev", "0.5.0")) + .file("dev/src/lib.rs", "pub fn dev() {}") + .build(); + + p.cargo("build") + .with_stderr_contains( + format!("[WARNING] found both `dev-dependencies` and `dev_dependencies` are set in the `{}` platform target", host), + ) + .run(); + + assert!(p.bin("foo").is_file()); + p.cargo("test").run(); +} + #[cargo_test] fn bad_platform_specific_dependency() { let p = project() From 8b895cc80be438fbf659c0413c2bcdd83bc5bb0c Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Wed, 9 Mar 2022 23:54:17 +0800 Subject: [PATCH 8/8] Use warn_on_deprecated Signed-off-by: hi-rustin --- src/cargo/util/toml/mod.rs | 62 +++++++++++++++-------------------- tests/testsuite/build.rs | 37 ++++++++++++--------- tests/testsuite/features.rs | 5 +-- tests/testsuite/proc_macro.rs | 3 +- 4 files changed, 53 insertions(+), 54 deletions(-) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 51fc86b9dfc..9a3a2c42211 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -180,6 +180,15 @@ pub fn parse_document( .map_err(|e| anyhow::Error::from(e).context("could not parse input as TOML")) } +/// Warn about paths that have been deprecated and may conflict. +fn warn_on_deprecated(new_path: &str, name: &str, kind: &str, warnings: &mut Vec) { + let old_path = new_path.replace("-", "_"); + warnings.push(format!( + "conflicting between `{new_path}` and `{old_path}` in the `{name}` {kind}.\n + `{old_path}` is ignored and not recommended for use in the future" + )) +} + type TomlLibTarget = TomlTarget; type TomlBinTarget = TomlTarget; type TomlExampleTarget = TomlTarget; @@ -1265,11 +1274,7 @@ impl TomlManifest { // Collect the dependencies. process_dependencies(&mut cx, me.dependencies.as_ref(), None)?; if me.dev_dependencies.is_some() && me.dev_dependencies2.is_some() { - cx.warnings.push(format!( - "found both `dev-dependencies` and `dev_dependencies` are set \ - in the `{}` package", - package_name - )); + warn_on_deprecated("dev-dependencies", package_name, "package", cx.warnings); } let dev_deps = me .dev_dependencies @@ -1277,11 +1282,7 @@ impl TomlManifest { .or_else(|| me.dev_dependencies2.as_ref()); process_dependencies(&mut cx, dev_deps, Some(DepKind::Development))?; if me.build_dependencies.is_some() && me.build_dependencies2.is_some() { - cx.warnings.push(format!( - "found both `build-dependencies` and `build_dependencies` are set \ - in the `{}` package", - package_name - )); + warn_on_deprecated("build-dependencies", package_name, "package", cx.warnings); } let build_deps = me .build_dependencies @@ -1297,11 +1298,7 @@ impl TomlManifest { }; process_dependencies(&mut cx, platform.dependencies.as_ref(), None)?; if platform.build_dependencies.is_some() && platform.build_dependencies2.is_some() { - cx.warnings.push(format!( - "found both `build-dependencies` and `build_dependencies` are set \ - in the `{}` platform target", - name - )); + warn_on_deprecated("build-dependencies", name, "platform target", cx.warnings); } let build_deps = platform .build_dependencies @@ -1309,11 +1306,7 @@ impl TomlManifest { .or_else(|| platform.build_dependencies2.as_ref()); process_dependencies(&mut cx, build_deps, Some(DepKind::Build))?; if platform.dev_dependencies.is_some() && platform.dev_dependencies2.is_some() { - cx.warnings.push(format!( - "found both `dev-dependencies` and `dev_dependencies` are set \ - in the `{}` platform target", - name - )); + warn_on_deprecated("dev-dependencies", name, "platform target", cx.warnings); } let dev_deps = platform .dev_dependencies @@ -1937,11 +1930,7 @@ impl DetailedTomlDependency

{ let version = self.version.as_deref(); 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 - )); + warn_on_deprecated("default-features", name_in_toml, "dependency", cx.warnings); } dep.set_features(self.features.iter().flatten()) .set_default_features( @@ -2094,11 +2083,12 @@ impl TomlTarget { fn validate_proc_macro(&self, warnings: &mut Vec) { if self.proc_macro_raw.is_some() && self.proc_macro_raw2.is_some() { - warnings.push(format!( - "found both `proc-macro` and `proc_macro` are set \ - in the `{}` library target", - self.name() - )); + warn_on_deprecated( + "proc-macro", + self.name().as_str(), + "library target", + warnings, + ); } } @@ -2115,12 +2105,12 @@ impl TomlTarget { fn validate_crate_types(&self, target_kind_human: &str, warnings: &mut Vec) { if self.crate_type.is_some() && self.crate_type2.is_some() { - warnings.push(format!( - "found both `crate-type` and `crate_type` are set \ - in the `{}` {} target", - self.name(), - target_kind_human - )); + warn_on_deprecated( + "crate-type", + self.name().as_str(), + format!("{target_kind_human} target").as_str(), + warnings, + ); } } diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 59cb97a998d..c6ab943e4ba 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -1705,9 +1705,10 @@ fn dev_dependencies_conflicting_warning() { .file("a/src/lib.rs", "") .build(); p.cargo("build") - .with_stderr_contains( - "[WARNING] found both `dev-dependencies` and `dev_dependencies` are set in the `foo` package", - ) + .with_stderr_contains( +"[WARNING] conflicting between `dev-dependencies` and `dev_dependencies` in the `foo` package.\n + `dev_dependencies` is ignored and not recommended for use in the future" + ) .run(); } @@ -1740,9 +1741,10 @@ fn build_dependencies_conflicting_warning() { .file("a/src/lib.rs", "") .build(); p.cargo("build") - .with_stderr_contains( - "[WARNING] found both `build-dependencies` and `build_dependencies` are set in the `foo` package", - ) + .with_stderr_contains( +"[WARNING] conflicting between `build-dependencies` and `build_dependencies` in the `foo` package.\n + `build_dependencies` is ignored and not recommended for use in the future" + ) .run(); } @@ -1766,9 +1768,10 @@ fn lib_crate_types_conflicting_warning() { .file("src/lib.rs", "pub fn foo() {}") .build(); p.cargo("build") - .with_stderr_contains( - "[WARNING] found both `crate-type` and `crate_type` are set in the `foo` library target", - ) + .with_stderr_contains( +"[WARNING] conflicting between `crate-type` and `crate_type` in the `foo` library target.\n + `crate_type` is ignored and not recommended for use in the future", + ) .run(); } @@ -1812,8 +1815,10 @@ fn examples_crate_types_conflicting_warning() { p.cargo("build") .with_stderr_contains( "\ -[WARNING] found both `crate-type` and `crate_type` are set in the `ex` example target -[WARNING] found both `crate-type` and `crate_type` are set in the `goodbye` example target", +[WARNING] conflicting between `crate-type` and `crate_type` in the `ex` example target.\n + `crate_type` is ignored and not recommended for use in the future +[WARNING] conflicting between `crate-type` and `crate_type` in the `goodbye` example target.\n + `crate_type` is ignored and not recommended for use in the future", ) .run(); } @@ -3016,9 +3021,10 @@ fn cargo_platform_specific_dependency_build_dependencies_conflicting_warning() { p.cargo("build") .with_stderr_contains( - format!("[WARNING] found both `build-dependencies` and `build_dependencies` are set in the `{}` platform target", host), + format!("[WARNING] conflicting between `build-dependencies` and `build_dependencies` in the `{}` platform target.\n + `build_dependencies` is ignored and not recommended for use in the future", host) ) - .run(); + .run(); assert!(p.bin("foo").is_file()); } @@ -3055,9 +3061,10 @@ fn cargo_platform_specific_dependency_dev_dependencies_conflicting_warning() { p.cargo("build") .with_stderr_contains( - format!("[WARNING] found both `dev-dependencies` and `dev_dependencies` are set in the `{}` platform target", host), + format!("[WARNING] conflicting between `dev-dependencies` and `dev_dependencies` in the `{}` platform target.\n + `dev_dependencies` is ignored and not recommended for use in the future", host) ) - .run(); + .run(); assert!(p.bin("foo").is_file()); p.cargo("test").run(); diff --git a/tests/testsuite/features.rs b/tests/testsuite/features.rs index 01e06013a15..cc5d10e4045 100644 --- a/tests/testsuite/features.rs +++ b/tests/testsuite/features.rs @@ -2102,7 +2102,8 @@ fn default_features_conflicting_warning() { p.cargo("build") .with_stderr_contains( - "[WARNING] found both `default-features` and `default_features` are set in the `a` dependency", +"[WARNING] conflicting between `default-features` and `default_features` in the `a` dependency.\n + `default_features` is ignored and not recommended for use in the future" ) - .run(); + .run(); } diff --git a/tests/testsuite/proc_macro.rs b/tests/testsuite/proc_macro.rs index c40d6a1535b..50e432a19c8 100644 --- a/tests/testsuite/proc_macro.rs +++ b/tests/testsuite/proc_macro.rs @@ -406,7 +406,8 @@ fn proc_macro_conflicting_warning() { foo.cargo("build") .with_stderr_contains( - "[WARNING] found both `proc-macro` and `proc_macro` are set in the `foo` library target", +"[WARNING] conflicting between `proc-macro` and `proc_macro` in the `foo` library target.\n + `proc_macro` is ignored and not recommended for use in the future", ) .run(); }