Auto merge of #13783 - epage:underscore, r=ehuss

fix(toml): Report `_` fied variants (e.g. `dev_dependencies`) as deprecated

### What does this PR try to resolve?

This is prep for removing them in the 2024 Edition and is part of rust-lang/rust#123754 and #13629

This doesn't include 2024 Edition work because there is a risk of conflict with other work going on these areas.

This changes us from
- When using `-` and `_` variants: deprecated, will error some time
- Otherwise, nothing

To
- When using `-` and `_` variants: unused field warning
- When using only `_`: deprecation, will be removed in 2024

I decided to model this as an unused field warning because that is what this is and that is how any other use of `_` works.  We might hard error during a transition period but I'd eventually want these to just make the code act like anything else in the end.

### How should we test and review this PR?

### Additional information
This commit is contained in:
bors 2024-04-22 16:25:06 +00:00
commit d29ad6788a
11 changed files with 704 additions and 364 deletions

View File

@ -904,9 +904,14 @@ fn inner_dependency_inherit_with<'a>(
this could become a hard error in the future"
))
}
if dependency.default_features.is_some() && dependency.default_features2.is_some() {
warn_on_deprecated("default-features", name, "dependency", warnings);
}
deprecated_underscore(
&dependency.default_features2,
&dependency.default_features,
"default-features",
name,
"dependency",
warnings,
);
inherit()?.get_dependency(name, package_root).map(|d| {
match d {
manifest::TomlDependency::Simple(s) => {
@ -1157,18 +1162,28 @@ fn to_real_manifest(
}
validate_dependencies(original_toml.dependencies.as_ref(), None, None, warnings)?;
if original_toml.dev_dependencies.is_some() && original_toml.dev_dependencies2.is_some() {
warn_on_deprecated("dev-dependencies", package_name, "package", warnings);
}
deprecated_underscore(
&original_toml.dev_dependencies2,
&original_toml.dev_dependencies,
"dev-dependencies",
package_name,
"package",
warnings,
);
validate_dependencies(
original_toml.dev_dependencies(),
None,
Some(DepKind::Development),
warnings,
)?;
if original_toml.build_dependencies.is_some() && original_toml.build_dependencies2.is_some() {
warn_on_deprecated("build-dependencies", package_name, "package", warnings);
}
deprecated_underscore(
&original_toml.build_dependencies2,
&original_toml.build_dependencies,
"build-dependencies",
package_name,
"package",
warnings,
);
validate_dependencies(
original_toml.build_dependencies(),
None,
@ -1185,18 +1200,28 @@ fn to_real_manifest(
None,
warnings,
)?;
if platform.build_dependencies.is_some() && platform.build_dependencies2.is_some() {
warn_on_deprecated("build-dependencies", name, "platform target", warnings);
}
deprecated_underscore(
&platform.build_dependencies2,
&platform.build_dependencies,
"build-dependencies",
name,
"platform target",
warnings,
);
validate_dependencies(
platform.build_dependencies(),
platform_kind.as_ref(),
Some(DepKind::Build),
warnings,
)?;
if platform.dev_dependencies.is_some() && platform.dev_dependencies2.is_some() {
warn_on_deprecated("dev-dependencies", name, "platform target", warnings);
}
deprecated_underscore(
&platform.dev_dependencies2,
&platform.dev_dependencies,
"dev-dependencies",
name,
"platform target",
warnings,
);
validate_dependencies(
platform.dev_dependencies(),
platform_kind.as_ref(),
@ -1885,14 +1910,14 @@ fn detailed_dep_to_dependency<P: ResolveToPath + Clone>(
let version = orig.version.as_deref();
let mut dep = Dependency::parse(pkg_name, version, new_source_id)?;
if orig.default_features.is_some() && orig.default_features2.is_some() {
warn_on_deprecated(
"default-features",
name_in_toml,
"dependency",
manifest_ctx.warnings,
);
}
deprecated_underscore(
&orig.default_features2,
&orig.default_features,
"default-features",
name_in_toml,
"dependency",
manifest_ctx.warnings,
);
dep.set_features(orig.features.iter().flatten())
.set_default_features(orig.default_features().unwrap_or(true))
.set_optional(orig.optional.unwrap_or(false))
@ -2304,12 +2329,25 @@ fn emit_diagnostic(
}
/// Warn about paths that have been deprecated and may conflict.
fn warn_on_deprecated(new_path: &str, name: &str, kind: &str, warnings: &mut Vec<String>) {
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"
))
fn deprecated_underscore<T>(
old: &Option<T>,
new: &Option<T>,
new_path: &str,
name: &str,
kind: &str,
warnings: &mut Vec<String>,
) {
if old.is_some() && new.is_some() {
let old_path = new_path.replace("-", "_");
warnings.push(format!(
"unused manifest key `{old_path}` in the `{name}` {kind}"
))
} else if old.is_some() {
let old_path = new_path.replace("-", "_");
warnings.push(format!(
"`{old_path}` is deprecated in favor of `{new_path}` and will not work in the 2024 edition\n(in the `{name}` {kind})"
))
}
}
fn warn_on_unused(unused: &BTreeSet<String>, warnings: &mut Vec<String>) {

View File

@ -25,7 +25,7 @@ use crate::core::compiler::CrateType;
use crate::core::{Edition, Feature, Features, Target};
use crate::util::errors::CargoResult;
use crate::util::restricted_names;
use crate::util::toml::warn_on_deprecated;
use crate::util::toml::deprecated_underscore;
const DEFAULT_TEST_DIR_NAME: &'static str = "tests";
const DEFAULT_BENCH_DIR_NAME: &'static str = "benches";
@ -1102,23 +1102,23 @@ fn name_or_panic(target: &TomlTarget) -> &str {
}
fn validate_proc_macro(target: &TomlTarget, kind: &str, warnings: &mut Vec<String>) {
if target.proc_macro.is_some() && target.proc_macro2.is_some() {
warn_on_deprecated(
"proc-macro",
name_or_panic(target),
format!("{kind} target").as_str(),
warnings,
);
}
deprecated_underscore(
&target.proc_macro2,
&target.proc_macro,
"proc-macro",
name_or_panic(target),
format!("{kind} target").as_str(),
warnings,
);
}
fn validate_crate_types(target: &TomlTarget, kind: &str, warnings: &mut Vec<String>) {
if target.crate_type.is_some() && target.crate_type2.is_some() {
warn_on_deprecated(
"crate-type",
name_or_panic(target),
format!("{kind} target").as_str(),
warnings,
);
}
deprecated_underscore(
&target.crate_type2,
&target.crate_type,
"crate-type",
name_or_panic(target),
format!("{kind} target").as_str(),
warnings,
);
}

View File

@ -804,6 +804,611 @@ Caused by:
.run();
}
#[cargo_test]
fn dev_dependencies2() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2018"
[dev_dependencies]
a = {path = "a"}
"#,
)
.file("src/lib.rs", "")
.file(
"a/Cargo.toml",
r#"
[package]
name = "a"
version = "0.0.1"
edition = "2015"
"#,
)
.file("a/src/lib.rs", "")
.build();
p.cargo("check")
.with_stderr_contains(
"\
[WARNING] `dev_dependencies` is deprecated in favor of `dev-dependencies` and will not work in the 2024 edition
(in the `foo` package)
"
)
.run();
}
#[cargo_test]
fn dev_dependencies2_conflict() {
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"
edition = "2015"
"#,
)
.file("a/src/lib.rs", "")
.build();
p.cargo("check")
.with_stderr_contains(
"\
[WARNING] unused manifest key `dev_dependencies` in the `foo` package
",
)
.run();
}
#[cargo_test]
fn build_dependencies2() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2018"
[build_dependencies]
a = {path = "a"}
"#,
)
.file("src/lib.rs", "")
.file(
"a/Cargo.toml",
r#"
[package]
name = "a"
version = "0.0.1"
edition = "2015"
"#,
)
.file("a/src/lib.rs", "")
.build();
p.cargo("check")
.with_stderr_contains(
"\
[WARNING] `build_dependencies` is deprecated in favor of `build-dependencies` and will not work in the 2024 edition
(in the `foo` package)
"
)
.run();
}
#[cargo_test]
fn build_dependencies2_conflict() {
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"
edition = "2015"
"#,
)
.file("a/src/lib.rs", "")
.build();
p.cargo("check")
.with_stderr_contains(
"\
[WARNING] unused manifest key `build_dependencies` in the `foo` package
",
)
.run();
}
#[cargo_test]
fn lib_crate_type2() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.5.0"
edition = "2015"
authors = ["wycats@example.com"]
[lib]
name = "foo"
crate_type = ["staticlib", "dylib"]
"#,
)
.file("src/lib.rs", "pub fn foo() {}")
.build();
p.cargo("check")
.with_stderr_contains(
"\
[WARNING] `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition
(in the `foo` library target)
",
)
.run();
}
#[cargo_test]
fn lib_crate_type2_conflict() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.5.0"
edition = "2015"
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("check")
.with_stderr_contains(
"\
[WARNING] unused manifest key `crate_type` in the `foo` library target
",
)
.run();
}
#[cargo_test]
fn examples_crate_type2() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.5.0"
edition = "2015"
authors = ["wycats@example.com"]
[[example]]
name = "ex"
path = "examples/ex.rs"
crate_type = ["proc_macro"]
[[example]]
name = "goodbye"
path = "examples/ex-goodbye.rs"
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("check")
.with_stderr_contains(
"\
[WARNING] `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition
(in the `ex` example target)
[WARNING] `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition
(in the `goodbye` example target)
",
)
.run();
}
#[cargo_test]
fn examples_crate_type2_conflict() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.5.0"
edition = "2015"
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("check")
.with_stderr_contains(
"\
[WARNING] unused manifest key `crate_type` in the `ex` example target
[WARNING] unused manifest key `crate_type` in the `goodbye` example target
",
)
.run();
}
#[cargo_test]
fn cargo_platform_build_dependencies2() {
let host = rustc_host();
let p = project()
.file(
"Cargo.toml",
&format!(
r#"
[package]
name = "foo"
version = "0.5.0"
edition = "2015"
authors = ["wycats@example.com"]
build = "build.rs"
[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("check")
.with_stderr_contains(
format!("\
[WARNING] `build_dependencies` is deprecated in favor of `build-dependencies` and will not work in the 2024 edition
(in the `{host}` platform target)
")
)
.run();
}
#[cargo_test]
fn cargo_platform_build_dependencies2_conflict() {
let host = rustc_host();
let p = project()
.file(
"Cargo.toml",
&format!(
r#"
[package]
name = "foo"
version = "0.5.0"
edition = "2015"
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("check")
.with_stderr_contains(format!(
"\
[WARNING] unused manifest key `build_dependencies` in the `{host}` platform target
"
))
.run();
}
#[cargo_test]
fn cargo_platform_dev_dependencies2() {
let host = rustc_host();
let p = project()
.file(
"Cargo.toml",
&format!(
r#"
[package]
name = "foo"
version = "0.5.0"
edition = "2015"
authors = ["wycats@example.com"]
[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("check")
.with_stderr_contains(
format!("\
[WARNING] `dev_dependencies` is deprecated in favor of `dev-dependencies` and will not work in the 2024 edition
(in the `{host}` platform target)
")
)
.run();
}
#[cargo_test]
fn cargo_platform_dev_dependencies2_conflict() {
let host = rustc_host();
let p = project()
.file(
"Cargo.toml",
&format!(
r#"
[package]
name = "foo"
version = "0.5.0"
edition = "2015"
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("check")
.with_stderr_contains(format!(
"\
[WARNING] unused manifest key `dev_dependencies` in the `{host}` platform target
"
))
.run();
}
#[cargo_test]
fn default_features2() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2015"
authors = []
[dependencies]
a = { path = "a", features = ["f1"], default_features = false }
"#,
)
.file("src/lib.rs", "")
.file(
"a/Cargo.toml",
r#"
[package]
name = "a"
version = "0.1.0"
edition = "2015"
authors = []
[features]
default = ["f1"]
f1 = []
"#,
)
.file("a/src/lib.rs", "")
.build();
p.cargo("check")
.with_stderr_contains(
"\
[WARNING] `default_features` is deprecated in favor of `default-features` and will not work in the 2024 edition
(in the `a` dependency)
"
)
.run();
}
#[cargo_test]
fn default_features2_conflict() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2015"
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"
edition = "2015"
authors = []
[features]
default = ["f1"]
f1 = []
"#,
)
.file("a/src/lib.rs", "")
.build();
p.cargo("check")
.with_stderr_contains(
"\
[WARNING] unused manifest key `default_features` in the `a` dependency
",
)
.run();
}
#[cargo_test]
fn proc_macro2() {
let foo = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2015"
[lib]
proc_macro = true
"#,
)
.file("src/lib.rs", "")
.build();
foo.cargo("check")
.with_stderr_contains(
"\
[WARNING] `proc_macro` is deprecated in favor of `proc-macro` and will not work in the 2024 edition
(in the `foo` library target)
",
)
.run();
}
#[cargo_test]
fn proc_macro2_conflict() {
let foo = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2015"
[lib]
proc-macro = false
proc_macro = true
"#,
)
.file("src/lib.rs", "")
.build();
foo.cargo("check")
.with_stderr_contains(
"\
[WARNING] unused manifest key `proc_macro` in the `foo` library target
",
)
.run();
}
#[cargo_test]
fn invalid_toml_historically_allowed_fails() {
let p = project()

View File

@ -853,7 +853,7 @@ fn bench_dylib() {
[lib]
name = "foo"
crate_type = ["dylib"]
crate-type = ["dylib"]
[dependencies.bar]
path = "bar"
@ -895,7 +895,7 @@ fn bench_dylib() {
[lib]
name = "bar"
crate_type = ["dylib"]
crate-type = ["dylib"]
"#,
)
.file("bar/src/lib.rs", "pub fn baz() {}")

View File

@ -1496,7 +1496,7 @@ fn cargo_default_env_metadata_env_var() {
[lib]
name = "bar"
crate_type = ["dylib"]
crate-type = ["dylib"]
"#,
)
.file("bar/src/lib.rs", "// hello")
@ -2089,7 +2089,7 @@ fn many_crate_types_old_style_lib_location() {
[lib]
name = "foo"
crate_type = ["rlib", "dylib"]
crate-type = ["rlib", "dylib"]
"#,
)
.file("src/foo.rs", "pub fn foo() {}")
@ -2123,7 +2123,7 @@ fn many_crate_types_correct() {
[lib]
name = "foo"
crate_type = ["rlib", "dylib"]
crate-type = ["rlib", "dylib"]
"#,
)
.file("src/lib.rs", "pub fn foo() {}")
@ -2151,7 +2151,7 @@ fn set_both_dylib_and_cdylib_crate_types() {
[lib]
name = "foo"
crate_type = ["cdylib", "dylib"]
crate-type = ["cdylib", "dylib"]
"#,
)
.file("src/lib.rs", "pub fn foo() {}")
@ -2169,157 +2169,6 @@ 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"
edition = "2015"
"#,
)
.file("a/src/lib.rs", "")
.build();
p.cargo("build")
.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();
}
#[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"
edition = "2015"
"#,
)
.file("a/src/lib.rs", "")
.build();
p.cargo("build")
.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();
}
#[cargo_test]
fn lib_crate_types_conflicting_warning() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.5.0"
edition = "2015"
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] 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();
}
#[cargo_test]
fn examples_crate_types_conflicting_warning() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.5.0"
edition = "2015"
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] 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();
}
#[cargo_test]
fn self_dependency() {
let p = project()
@ -2521,7 +2370,7 @@ fn verbose_release_build_deps() {
[lib]
name = "foo"
crate_type = ["dylib", "rlib"]
crate-type = ["dylib", "rlib"]
"#,
)
.file("foo/src/lib.rs", "")
@ -3506,90 +3355,6 @@ 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#"
[package]
name = "foo"
version = "0.5.0"
edition = "2015"
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] 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();
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#"
[package]
name = "foo"
version = "0.5.0"
edition = "2015"
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] 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();
assert!(p.bin("foo").is_file());
p.cargo("test").run();
}
#[cargo_test]
fn bad_platform_specific_dependency() {
let p = project()

View File

@ -1175,7 +1175,7 @@ fn cross_test_dylib() {
[lib]
name = "foo"
crate_type = ["dylib"]
crate-type = ["dylib"]
[dependencies.bar]
path = "bar"
@ -1212,7 +1212,7 @@ fn cross_test_dylib() {
[lib]
name = "bar"
crate_type = ["dylib"]
crate-type = ["dylib"]
"#,
)
.file(

View File

@ -2204,45 +2204,3 @@ fn invalid_feature_name_slash_error() {
)
.run();
}
#[cargo_test]
fn default_features_conflicting_warning() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2015"
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"
edition = "2015"
authors = []
[features]
default = ["f1"]
f1 = []
"#,
)
.file("a/src/lib.rs", "")
.build();
p.cargo("check")
.with_stderr_contains(
"[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();
}

View File

@ -345,32 +345,6 @@ 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"
edition = "2015"
[lib]
proc-macro = false
proc_macro = true
"#,
)
.file("src/lib.rs", "")
.build();
foo.cargo("check")
.with_stderr_contains(
"[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();
}
#[cargo_test]
fn proc_macro_crate_type_warning_plugin() {
let foo = project()
@ -509,7 +483,7 @@ fn proc_macro_built_once() {
edition = "2015"
[lib]
proc_macro = true
proc-macro = true
[features]
a = []

View File

@ -203,7 +203,7 @@ fn top_level_overrides_deps() {
[lib]
name = "foo"
crate_type = ["dylib", "rlib"]
crate-type = ["dylib", "rlib"]
"#,
)
.file("foo/src/lib.rs", "")

View File

@ -443,7 +443,7 @@ fn run_library_example() {
authors = []
[[example]]
name = "bar"
crate_type = ["lib"]
crate-type = ["lib"]
"#,
)
.file("src/lib.rs", "")
@ -468,7 +468,7 @@ fn run_bin_example() {
edition = "2015"
[[example]]
name = "bar"
crate_type = ["bin"]
crate-type = ["bin"]
"#,
)
.file("src/lib.rs", "")

View File

@ -1330,7 +1330,7 @@ fn test_dylib() {
[lib]
name = "foo"
crate_type = ["dylib"]
crate-type = ["dylib"]
[dependencies.bar]
path = "bar"
@ -1367,7 +1367,7 @@ fn test_dylib() {
[lib]
name = "bar"
crate_type = ["dylib"]
crate-type = ["dylib"]
"#,
)
.file("bar/src/lib.rs", "pub fn baz() {}")