Skip to content

Commit

Permalink
fix(toml): Deprecate underscore fields
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Apr 18, 2024
1 parent 868662c commit d1f0247
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 23 deletions.
5 changes: 5 additions & 0 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2342,6 +2342,11 @@ fn deprecated_underscore<T>(
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})"
))
}
}

Expand Down
56 changes: 33 additions & 23 deletions tests/testsuite/bad_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,10 +832,11 @@ fn dev_dependencies2() {
.file("a/src/lib.rs", "")
.build();
p.cargo("check")
.with_stderr_does_not_contain(
.with_stderr_contains(
"\
[WARNING] [..]
",
[WARNING] `dev_dependencies` is deprecated in favor of `dev-dependencies` and will not work in the 2024 edition
(in the `foo` package)
"
)
.run();
}
Expand Down Expand Up @@ -906,10 +907,11 @@ fn build_dependencies2() {
.file("a/src/lib.rs", "")
.build();
p.cargo("check")
.with_stderr_does_not_contain(
.with_stderr_contains(
"\
[WARNING] [..]
",
[WARNING] `build_dependencies` is deprecated in favor of `build-dependencies` and will not work in the 2024 edition
(in the `foo` package)
"
)
.run();
}
Expand Down Expand Up @@ -972,9 +974,10 @@ fn lib_crate_type2() {
.file("src/lib.rs", "pub fn foo() {}")
.build();
p.cargo("check")
.with_stderr_does_not_contain(
.with_stderr_contains(
"\
[WARNING] [..]
[WARNING] `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition
(in the `foo` library target)
",
)
.run();
Expand Down Expand Up @@ -1046,9 +1049,12 @@ fn examples_crate_type2() {
)
.build();
p.cargo("check")
.with_stderr_does_not_contain(
.with_stderr_contains(
"\
[WARNING] [..]
[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();
Expand Down Expand Up @@ -1133,10 +1139,11 @@ fn cargo_platform_build_dependencies2() {
.build();

p.cargo("check")
.with_stderr_does_not_contain(
"\
[WARNING] [..]
",
.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();
}
Expand Down Expand Up @@ -1212,10 +1219,11 @@ fn cargo_platform_dev_dependencies2() {
.build();

p.cargo("check")
.with_stderr_does_not_contain(
"\
[WARNING] [..]
",
.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();
}
Expand Down Expand Up @@ -1295,10 +1303,11 @@ fn default_features2() {
.build();

p.cargo("check")
.with_stderr_does_not_contain(
.with_stderr_contains(
"\
[WARNING] [..]
",
[WARNING] `default_features` is deprecated in favor of `default-features` and will not work in the 2024 edition
(in the `a` dependency)
"
)
.run();
}
Expand Down Expand Up @@ -1364,9 +1373,10 @@ fn proc_macro2() {
.build();

foo.cargo("check")
.with_stderr_does_not_contain(
.with_stderr_contains(
"\
[WARNING] [..]
[WARNING] `proc_macro` is deprecated in favor of `proc-macro` and will not work in the 2024 edition
(in the `foo` library target)
",
)
.run();
Expand Down

0 comments on commit d1f0247

Please sign in to comment.