Skip to content

Commit 24defcb

Browse files
committed
fix(install): Keep v1 file formatting the same
Inspired by rust-lang#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.
1 parent 641a515 commit 24defcb

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/cargo/ops/common_for_install_and_uninstall.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ impl CrateListingV1 {
356356
let mut file = lock.file();
357357
file.seek(SeekFrom::Start(0))?;
358358
file.set_len(0)?;
359-
let data = toml::to_string(self)?;
359+
let data = toml::to_string_pretty(self)?;
360360
file.write_all(data.as_bytes())?;
361361
Ok(())
362362
}

tests/testsuite/install.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ Caused by:
990990
Caused by:
991991
TOML parse error at line 1, column 1
992992
|
993-
1 | [..] = { \"foo 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)\" = [\"foo[EXE]\"] }
993+
1 | [..]
994994
| ^
995995
Unexpected `[..]`
996996
Expected key or end of input

0 commit comments

Comments
 (0)