Skip to content

Commit d1f0247

Browse files
committed
fix(toml): Deprecate underscore fields
1 parent 868662c commit d1f0247

File tree

2 files changed

+38
-23
lines changed

2 files changed

+38
-23
lines changed

src/cargo/util/toml/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -2342,6 +2342,11 @@ fn deprecated_underscore<T>(
23422342
warnings.push(format!(
23432343
"unused manifest key `{old_path}` in the `{name}` {kind}"
23442344
))
2345+
} else if old.is_some() {
2346+
let old_path = new_path.replace("-", "_");
2347+
warnings.push(format!(
2348+
"`{old_path}` is deprecated in favor of `{new_path}` and will not work in the 2024 edition\n(in the `{name}` {kind})"
2349+
))
23452350
}
23462351
}
23472352

tests/testsuite/bad_config.rs

+33-23
Original file line numberDiff line numberDiff line change
@@ -832,10 +832,11 @@ fn dev_dependencies2() {
832832
.file("a/src/lib.rs", "")
833833
.build();
834834
p.cargo("check")
835-
.with_stderr_does_not_contain(
835+
.with_stderr_contains(
836836
"\
837-
[WARNING] [..]
838-
",
837+
[WARNING] `dev_dependencies` is deprecated in favor of `dev-dependencies` and will not work in the 2024 edition
838+
(in the `foo` package)
839+
"
839840
)
840841
.run();
841842
}
@@ -906,10 +907,11 @@ fn build_dependencies2() {
906907
.file("a/src/lib.rs", "")
907908
.build();
908909
p.cargo("check")
909-
.with_stderr_does_not_contain(
910+
.with_stderr_contains(
910911
"\
911-
[WARNING] [..]
912-
",
912+
[WARNING] `build_dependencies` is deprecated in favor of `build-dependencies` and will not work in the 2024 edition
913+
(in the `foo` package)
914+
"
913915
)
914916
.run();
915917
}
@@ -972,9 +974,10 @@ fn lib_crate_type2() {
972974
.file("src/lib.rs", "pub fn foo() {}")
973975
.build();
974976
p.cargo("check")
975-
.with_stderr_does_not_contain(
977+
.with_stderr_contains(
976978
"\
977-
[WARNING] [..]
979+
[WARNING] `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition
980+
(in the `foo` library target)
978981
",
979982
)
980983
.run();
@@ -1046,9 +1049,12 @@ fn examples_crate_type2() {
10461049
)
10471050
.build();
10481051
p.cargo("check")
1049-
.with_stderr_does_not_contain(
1052+
.with_stderr_contains(
10501053
"\
1051-
[WARNING] [..]
1054+
[WARNING] `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition
1055+
(in the `ex` example target)
1056+
[WARNING] `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition
1057+
(in the `goodbye` example target)
10521058
",
10531059
)
10541060
.run();
@@ -1133,10 +1139,11 @@ fn cargo_platform_build_dependencies2() {
11331139
.build();
11341140

11351141
p.cargo("check")
1136-
.with_stderr_does_not_contain(
1137-
"\
1138-
[WARNING] [..]
1139-
",
1142+
.with_stderr_contains(
1143+
format!("\
1144+
[WARNING] `build_dependencies` is deprecated in favor of `build-dependencies` and will not work in the 2024 edition
1145+
(in the `{host}` platform target)
1146+
")
11401147
)
11411148
.run();
11421149
}
@@ -1212,10 +1219,11 @@ fn cargo_platform_dev_dependencies2() {
12121219
.build();
12131220

12141221
p.cargo("check")
1215-
.with_stderr_does_not_contain(
1216-
"\
1217-
[WARNING] [..]
1218-
",
1222+
.with_stderr_contains(
1223+
format!("\
1224+
[WARNING] `dev_dependencies` is deprecated in favor of `dev-dependencies` and will not work in the 2024 edition
1225+
(in the `{host}` platform target)
1226+
")
12191227
)
12201228
.run();
12211229
}
@@ -1295,10 +1303,11 @@ fn default_features2() {
12951303
.build();
12961304

12971305
p.cargo("check")
1298-
.with_stderr_does_not_contain(
1306+
.with_stderr_contains(
12991307
"\
1300-
[WARNING] [..]
1301-
",
1308+
[WARNING] `default_features` is deprecated in favor of `default-features` and will not work in the 2024 edition
1309+
(in the `a` dependency)
1310+
"
13021311
)
13031312
.run();
13041313
}
@@ -1364,9 +1373,10 @@ fn proc_macro2() {
13641373
.build();
13651374

13661375
foo.cargo("check")
1367-
.with_stderr_does_not_contain(
1376+
.with_stderr_contains(
13681377
"\
1369-
[WARNING] [..]
1378+
[WARNING] `proc_macro` is deprecated in favor of `proc-macro` and will not work in the 2024 edition
1379+
(in the `foo` library target)
13701380
",
13711381
)
13721382
.run();

0 commit comments

Comments
 (0)