From 57b4ab90a622b3193a1f74225fd37480ffe03fe6 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 26 Apr 2024 10:53:28 -0500 Subject: [PATCH] refactor(toml): Consolidate field name conversion --- src/cargo/util/toml/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index b6f97b29c68..96720937a92 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -2331,16 +2331,14 @@ fn deprecated_underscore( edition: Edition, warnings: &mut Vec, ) -> CargoResult<()> { + let old_path = new_path.replace("-", "_"); if old.is_some() && Edition::Edition2024 <= edition { - let old_path = new_path.replace("-", "_"); anyhow::bail!("`{old_path}` is unsupported as of the 2024 edition; instead use `{new_path}`\n(in the `{name}` {kind})"); } else if old.is_some() && new.is_some() { - let old_path = new_path.replace("-", "_"); warnings.push(format!( "`{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("-", "_"); 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})" ))