From 02dd9175117fd34aa172a45d7b360f17865f1f54 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 17 Oct 2023 12:44:05 -0500 Subject: [PATCH] fix(add): Add back in some auto-formatting This moves the auto-format to the correct place so it takes effect. --- src/cargo/util/toml_mut/manifest.rs | 9 ++++++--- .../overwrite_git_with_path/out/primary/Cargo.toml | 2 +- .../out/Cargo.toml | 4 ++-- .../overwrite_optional_with_no_optional/out/Cargo.toml | 4 ++-- .../overwrite_preserves_inline_table/out/Cargo.toml | 2 +- .../cargo_add/overwrite_version_with_git/out/Cargo.toml | 2 +- .../overwrite_version_with_path/out/primary/Cargo.toml | 2 +- .../out/primary/Cargo.toml | 2 +- .../cargo_add/preserve_features_table/out/Cargo.toml | 2 +- tests/testsuite/cargo_add/require_weak/out/Cargo.toml | 2 +- 10 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/cargo/util/toml_mut/manifest.rs b/src/cargo/util/toml_mut/manifest.rs index 7d51f6b5c05..a5050752995 100644 --- a/src/cargo/util/toml_mut/manifest.rs +++ b/src/cargo/util/toml_mut/manifest.rs @@ -349,13 +349,16 @@ impl LocalManifest { .get_key_value_mut(dep_key) { dep.update_toml(&crate_root, &mut dep_key, dep_item); + if let Some(table) = dep_item.as_inline_table_mut() { + // So long as we don't have `Cargo.toml` auto-formatting and inline-tables can only + // be on one line, there isn't really much in the way of interesting formatting to + // include (no comments), so let's just wipe it clean + table.fmt(); + } } else { let new_dependency = dep.to_toml(&crate_root); table[dep_key] = new_dependency; } - if let Some(t) = table.as_inline_table_mut() { - t.fmt() - } Ok(()) } diff --git a/tests/testsuite/cargo_add/overwrite_git_with_path/out/primary/Cargo.toml b/tests/testsuite/cargo_add/overwrite_git_with_path/out/primary/Cargo.toml index 0bc5aba3c50..ad120548123 100644 --- a/tests/testsuite/cargo_add/overwrite_git_with_path/out/primary/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_git_with_path/out/primary/Cargo.toml @@ -5,4 +5,4 @@ name = "cargo-list-test-fixture" version = "0.0.0" [dependencies] -cargo-list-test-fixture-dependency = { optional = true , path = "../dependency", version = "0.0.0" } +cargo-list-test-fixture-dependency = { optional = true, path = "../dependency", version = "0.0.0" } diff --git a/tests/testsuite/cargo_add/overwrite_no_default_features_with_default_features/out/Cargo.toml b/tests/testsuite/cargo_add/overwrite_no_default_features_with_default_features/out/Cargo.toml index 422b7878dd1..b9e8985c6d4 100644 --- a/tests/testsuite/cargo_add/overwrite_no_default_features_with_default_features/out/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_no_default_features_with_default_features/out/Cargo.toml @@ -5,5 +5,5 @@ name = "cargo-list-test-fixture" version = "0.0.0" [dependencies] -my-package1 = { version = "99999.0.0"} -my-package2 = { version = "0.4.1"} +my-package1 = { version = "99999.0.0" } +my-package2 = { version = "0.4.1" } diff --git a/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/out/Cargo.toml b/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/out/Cargo.toml index edba3898acb..bf6c52963b8 100644 --- a/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/out/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/out/Cargo.toml @@ -9,5 +9,5 @@ default = [] other = ["your-face/nose"] [dependencies] -your-face = { version = "99999.0.0"} -my-package2 = { version = "0.4.1"} +your-face = { version = "99999.0.0" } +my-package2 = { version = "0.4.1" } diff --git a/tests/testsuite/cargo_add/overwrite_preserves_inline_table/out/Cargo.toml b/tests/testsuite/cargo_add/overwrite_preserves_inline_table/out/Cargo.toml index 4ac1ef22ef4..f204a895ee9 100644 --- a/tests/testsuite/cargo_add/overwrite_preserves_inline_table/out/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_preserves_inline_table/out/Cargo.toml @@ -5,4 +5,4 @@ name = "cargo-list-test-fixture" version = "0.0.0" [dependencies] -your-face={version="99999.0.0",features=["eyes", "nose"]} # Hello world +your-face={ version = "99999.0.0", features = ["eyes", "nose"] } # Hello world diff --git a/tests/testsuite/cargo_add/overwrite_version_with_git/out/Cargo.toml b/tests/testsuite/cargo_add/overwrite_version_with_git/out/Cargo.toml index fbed3e86123..26001402414 100644 --- a/tests/testsuite/cargo_add/overwrite_version_with_git/out/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_version_with_git/out/Cargo.toml @@ -5,4 +5,4 @@ name = "cargo-list-test-fixture" version = "0.0.0" [dependencies] -versioned-package = { version = "0.3.0", optional = true , git = "[ROOTURL]/versioned-package" } +versioned-package = { version = "0.3.0", optional = true, git = "[ROOTURL]/versioned-package" } diff --git a/tests/testsuite/cargo_add/overwrite_version_with_path/out/primary/Cargo.toml b/tests/testsuite/cargo_add/overwrite_version_with_path/out/primary/Cargo.toml index 0ea40970e8c..07253670afe 100644 --- a/tests/testsuite/cargo_add/overwrite_version_with_path/out/primary/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_version_with_path/out/primary/Cargo.toml @@ -5,4 +5,4 @@ name = "cargo-list-test-fixture" version = "0.0.0" [dependencies] -cargo-list-test-fixture-dependency = { version = "0.0.0", optional = true , path = "../dependency" } +cargo-list-test-fixture-dependency = { version = "0.0.0", optional = true, path = "../dependency" } diff --git a/tests/testsuite/cargo_add/overwrite_workspace_dep_features/out/primary/Cargo.toml b/tests/testsuite/cargo_add/overwrite_workspace_dep_features/out/primary/Cargo.toml index 763989db273..6f95ded6fc4 100644 --- a/tests/testsuite/cargo_add/overwrite_workspace_dep_features/out/primary/Cargo.toml +++ b/tests/testsuite/cargo_add/overwrite_workspace_dep_features/out/primary/Cargo.toml @@ -3,4 +3,4 @@ name = "bar" version = "0.0.0" [dependencies] -foo = { features = ["test"] , path = "../dependency", version = "0.0.0" } +foo = { features = ["test"], path = "../dependency", version = "0.0.0" } diff --git a/tests/testsuite/cargo_add/preserve_features_table/out/Cargo.toml b/tests/testsuite/cargo_add/preserve_features_table/out/Cargo.toml index 0e6e1a47f5b..39acd101601 100644 --- a/tests/testsuite/cargo_add/preserve_features_table/out/Cargo.toml +++ b/tests/testsuite/cargo_add/preserve_features_table/out/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -your-face = { version = "99999.0.0"} +your-face = { version = "99999.0.0" } [features] default = [ diff --git a/tests/testsuite/cargo_add/require_weak/out/Cargo.toml b/tests/testsuite/cargo_add/require_weak/out/Cargo.toml index 3d5680fcf47..a0e4b9753bc 100644 --- a/tests/testsuite/cargo_add/require_weak/out/Cargo.toml +++ b/tests/testsuite/cargo_add/require_weak/out/Cargo.toml @@ -8,4 +8,4 @@ version = "0.0.0" eyes = ["your-face/eyes"] [dependencies] -your-face = { version = "99999.0.0"} +your-face = { version = "99999.0.0" }