Skip to content

Commit

Permalink
Auto merge of #13798 - epage:underscore, r=weihanglo
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Apr 24, 2024
2 parents 52dae0c + 034ef3c commit e3d42b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2340,7 +2340,7 @@ fn deprecated_underscore<T>(
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}"
"`{old_path}` is redundant with `{new_path}`, preferring `{new_path}` in the `{name}` {kind}"
))
} else if old.is_some() {
let old_path = new_path.replace("-", "_");
Expand Down
18 changes: 9 additions & 9 deletions tests/testsuite/bad_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ fn dev_dependencies2_conflict() {
p.cargo("check")
.with_stderr_contains(
"\
[WARNING] unused manifest key `dev_dependencies` in the `foo` package
[WARNING] `dev_dependencies` is redundant with `dev-dependencies`, preferring `dev-dependencies` in the `foo` package
",
)
.run();
Expand Down Expand Up @@ -948,7 +948,7 @@ fn build_dependencies2_conflict() {
p.cargo("check")
.with_stderr_contains(
"\
[WARNING] unused manifest key `build_dependencies` in the `foo` package
[WARNING] `build_dependencies` is redundant with `build-dependencies`, preferring `build-dependencies` in the `foo` package
",
)
.run();
Expand Down Expand Up @@ -1006,7 +1006,7 @@ fn lib_crate_type2_conflict() {
p.cargo("check")
.with_stderr_contains(
"\
[WARNING] unused manifest key `crate_type` in the `foo` library target
[WARNING] `crate_type` is redundant with `crate-type`, preferring `crate-type` in the `foo` library target
",
)
.run();
Expand Down Expand Up @@ -1101,8 +1101,8 @@ fn examples_crate_type2_conflict() {
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
[WARNING] `crate_type` is redundant with `crate-type`, preferring `crate-type` in the `ex` example target
[WARNING] `crate_type` is redundant with `crate-type`, preferring `crate-type` in the `goodbye` example target
",
)
.run();
Expand Down Expand Up @@ -1183,7 +1183,7 @@ fn cargo_platform_build_dependencies2_conflict() {
p.cargo("check")
.with_stderr_contains(format!(
"\
[WARNING] unused manifest key `build_dependencies` in the `{host}` platform target
[WARNING] `build_dependencies` is redundant with `build-dependencies`, preferring `build-dependencies` in the `{host}` platform target
"
))
.run();
Expand Down Expand Up @@ -1262,7 +1262,7 @@ fn cargo_platform_dev_dependencies2_conflict() {
p.cargo("check")
.with_stderr_contains(format!(
"\
[WARNING] unused manifest key `dev_dependencies` in the `{host}` platform target
[WARNING] `dev_dependencies` is redundant with `dev-dependencies`, preferring `dev-dependencies` in the `{host}` platform target
"
))
.run();
Expand Down Expand Up @@ -1349,7 +1349,7 @@ fn default_features2_conflict() {
p.cargo("check")
.with_stderr_contains(
"\
[WARNING] unused manifest key `default_features` in the `a` dependency
[WARNING] `default_features` is redundant with `default-features`, preferring `default-features` in the `a` dependency
",
)
.run();
Expand Down Expand Up @@ -1403,7 +1403,7 @@ fn proc_macro2_conflict() {
foo.cargo("check")
.with_stderr_contains(
"\
[WARNING] unused manifest key `proc_macro` in the `foo` library target
[WARNING] `proc_macro` is redundant with `proc-macro`, preferring `proc-macro` in the `foo` library target
",
)
.run();
Expand Down

0 comments on commit e3d42b6

Please sign in to comment.