]> git.proxmox.com Git - cargo.git/commitdiff
fix(install): Keep v1 file formatting the same
authorEd Page <eopage@gmail.com>
Mon, 31 Jan 2022 13:21:44 +0000 (07:21 -0600)
committerEd Page <eopage@gmail.com>
Mon, 31 Jan 2022 16:42:05 +0000 (10:42 -0600)
Inspired by #10345, I looked for other cases where
`toml_edit::easy::to_string` is used (which outputs inline tables) to
see if we should switch to `to_string_pretty`.  The crates v1 file was
the only case I found.

As a side effect, we can no longer elide the empty `dev-dependencies`
table in published manifests.  This was the behavior before `toml_edit`,
so not much of a loss.

src/cargo/ops/common_for_install_and_uninstall.rs
tests/testsuite/install.rs

index a529e19e7e182f71a36ae0b5e020a92d6e00a6da..834137715e16a6255042f731a7497e0b3744dcd7 100644 (file)
@@ -356,7 +356,7 @@ impl CrateListingV1 {
         let mut file = lock.file();
         file.seek(SeekFrom::Start(0))?;
         file.set_len(0)?;
-        let data = toml::to_string(self)?;
+        let data = toml::to_string_pretty(self)?;
         file.write_all(data.as_bytes())?;
         Ok(())
     }
index 5442c1884c927c4aaa65baa81d7c4755759a11da..4ba58c9a3d30d031594b6af09ea976855265425a 100644 (file)
@@ -990,7 +990,7 @@ Caused by:
 Caused by:
   TOML parse error at line 1, column 1
     |
-  1 | [..] = { \"foo 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)\" = [\"foo[EXE]\"] }
+  1 | [..]
     | ^
   Unexpected `[..]`
   Expected key or end of input