Skip to content

Commit 57b4ab9

Browse files
committed
refactor(toml): Consolidate field name conversion
1 parent a71b8fe commit 57b4ab9

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,16 +2331,14 @@ fn deprecated_underscore<T>(
23312331
edition: Edition,
23322332
warnings: &mut Vec<String>,
23332333
) -> CargoResult<()> {
2334+
let old_path = new_path.replace("-", "_");
23342335
if old.is_some() && Edition::Edition2024 <= edition {
2335-
let old_path = new_path.replace("-", "_");
23362336
anyhow::bail!("`{old_path}` is unsupported as of the 2024 edition; instead use `{new_path}`\n(in the `{name}` {kind})");
23372337
} else if old.is_some() && new.is_some() {
2338-
let old_path = new_path.replace("-", "_");
23392338
warnings.push(format!(
23402339
"`{old_path}` is redundant with `{new_path}`, preferring `{new_path}` in the `{name}` {kind}"
23412340
))
23422341
} else if old.is_some() {
2343-
let old_path = new_path.replace("-", "_");
23442342
warnings.push(format!(
23452343
"`{old_path}` is deprecated in favor of `{new_path}` and will not work in the 2024 edition\n(in the `{name}` {kind})"
23462344
))

0 commit comments

Comments
 (0)