Skip to content

Commit e3d42b6

Browse files
committed
Auto merge of #13798 - epage:underscore, r=weihanglo
fix(toml): Be more forceful with underscore/dash redundancy ### 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 During #13783, I had considered making the 2024 edition behavior a "unused key" warning. However, the work and code mess to pipe the data through correctly handle the two fields in all cases didn't seem worth it (and a hard error might be better to help users transition). ### How should we test and review this PR? ### Additional information
2 parents 52dae0c + 034ef3c commit e3d42b6

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/cargo/util/toml/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2340,7 +2340,7 @@ fn deprecated_underscore<T>(
23402340
if old.is_some() && new.is_some() {
23412341
let old_path = new_path.replace("-", "_");
23422342
warnings.push(format!(
2343-
"unused manifest key `{old_path}` in the `{name}` {kind}"
2343+
"`{old_path}` is redundant with `{new_path}`, preferring `{new_path}` in the `{name}` {kind}"
23442344
))
23452345
} else if old.is_some() {
23462346
let old_path = new_path.replace("-", "_");

tests/testsuite/bad_config.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ fn dev_dependencies2_conflict() {
873873
p.cargo("check")
874874
.with_stderr_contains(
875875
"\
876-
[WARNING] unused manifest key `dev_dependencies` in the `foo` package
876+
[WARNING] `dev_dependencies` is redundant with `dev-dependencies`, preferring `dev-dependencies` in the `foo` package
877877
",
878878
)
879879
.run();
@@ -948,7 +948,7 @@ fn build_dependencies2_conflict() {
948948
p.cargo("check")
949949
.with_stderr_contains(
950950
"\
951-
[WARNING] unused manifest key `build_dependencies` in the `foo` package
951+
[WARNING] `build_dependencies` is redundant with `build-dependencies`, preferring `build-dependencies` in the `foo` package
952952
",
953953
)
954954
.run();
@@ -1006,7 +1006,7 @@ fn lib_crate_type2_conflict() {
10061006
p.cargo("check")
10071007
.with_stderr_contains(
10081008
"\
1009-
[WARNING] unused manifest key `crate_type` in the `foo` library target
1009+
[WARNING] `crate_type` is redundant with `crate-type`, preferring `crate-type` in the `foo` library target
10101010
",
10111011
)
10121012
.run();
@@ -1101,8 +1101,8 @@ fn examples_crate_type2_conflict() {
11011101
p.cargo("check")
11021102
.with_stderr_contains(
11031103
"\
1104-
[WARNING] unused manifest key `crate_type` in the `ex` example target
1105-
[WARNING] unused manifest key `crate_type` in the `goodbye` example target
1104+
[WARNING] `crate_type` is redundant with `crate-type`, preferring `crate-type` in the `ex` example target
1105+
[WARNING] `crate_type` is redundant with `crate-type`, preferring `crate-type` in the `goodbye` example target
11061106
",
11071107
)
11081108
.run();
@@ -1183,7 +1183,7 @@ fn cargo_platform_build_dependencies2_conflict() {
11831183
p.cargo("check")
11841184
.with_stderr_contains(format!(
11851185
"\
1186-
[WARNING] unused manifest key `build_dependencies` in the `{host}` platform target
1186+
[WARNING] `build_dependencies` is redundant with `build-dependencies`, preferring `build-dependencies` in the `{host}` platform target
11871187
"
11881188
))
11891189
.run();
@@ -1262,7 +1262,7 @@ fn cargo_platform_dev_dependencies2_conflict() {
12621262
p.cargo("check")
12631263
.with_stderr_contains(format!(
12641264
"\
1265-
[WARNING] unused manifest key `dev_dependencies` in the `{host}` platform target
1265+
[WARNING] `dev_dependencies` is redundant with `dev-dependencies`, preferring `dev-dependencies` in the `{host}` platform target
12661266
"
12671267
))
12681268
.run();
@@ -1349,7 +1349,7 @@ fn default_features2_conflict() {
13491349
p.cargo("check")
13501350
.with_stderr_contains(
13511351
"\
1352-
[WARNING] unused manifest key `default_features` in the `a` dependency
1352+
[WARNING] `default_features` is redundant with `default-features`, preferring `default-features` in the `a` dependency
13531353
",
13541354
)
13551355
.run();
@@ -1403,7 +1403,7 @@ fn proc_macro2_conflict() {
14031403
foo.cargo("check")
14041404
.with_stderr_contains(
14051405
"\
1406-
[WARNING] unused manifest key `proc_macro` in the `foo` library target
1406+
[WARNING] `proc_macro` is redundant with `proc-macro`, preferring `proc-macro` in the `foo` library target
14071407
",
14081408
)
14091409
.run();

0 commit comments

Comments
 (0)