From 79ef676594197cb09a8eee8eb7aff4de6491ee20 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 19 Oct 2026 11:03:38 +0000 Subject: [PATCH 1/2] Update Rust crate serde_json to v1.0.154 --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 099d180..62492ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -271,9 +271,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.151" +version = "1.0.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" dependencies = [ "itoa", "memchr", From fa347906929668b1210411785c8607ad5b117a1f Mon Sep 17 00:00:00 2001 From: Eric J Date: Tue, 20 Oct 2026 10:42:41 -0700 Subject: [PATCH 2/2] Print integer -0 as 0, the way Python does serde_json 1.0.152 keeps `-0` as written under arbitrary_precision, where 1.0.151 turned it into `0`. Python's json reads `-0` as the int 0 and writes `0`, and matching Python's bytes is this crate's contract. A 2.0.77 --dump-data capture has 87 integer `-0` literals. With this change, canonicalising the whole dump on 1.0.154 is byte-identical to 1.0.151. The FactorioTools trim was unaffected either way, since none of its fields carry -0, which is also why CI could not see the change. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EdUbVVSnMbzGbAUT94sk5k --- src/trim/canonical.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/trim/canonical.rs b/src/trim/canonical.rs index 63a9460..342c506 100644 --- a/src/trim/canonical.rs +++ b/src/trim/canonical.rs @@ -28,6 +28,13 @@ pub fn normalise_numbers(value: &Value) -> Value { let literal = number.as_str(); let is_float = literal.contains('.') || literal.contains('e') || literal.contains('E'); if !is_float { + // serde_json 1.0.152 keeps `-0` as written under + // arbitrary_precision, where 1.0.151 turned it into `0`. + // Python reads `-0` as the int 0 and writes `0`, so match it. + // Measured 2026-10-20: 87 `-0` literals in a 2.0.77 dump. + if literal == "-0" { + return Value::Number(0.into()); + } return value.clone(); } match literal.parse::() { @@ -87,6 +94,14 @@ mod tests { assert_eq!(text, "[\n 0.3945,\n 0.49610000000000004\n]\n"); } + #[test] + fn negative_zero_integer_prints_as_python_does() { + // Python reads `-0` as the int 0. `-0.0` stays a float and keeps its sign. + let value: Value = serde_json::from_str("[-0, -0.0, 0]").unwrap(); + let text = to_canonical_json(&normalise_numbers(&value)); + assert_eq!(text, "[\n 0,\n -0.0,\n 0\n]\n"); + } + #[test] fn an_integer_stays_an_integer() { // JSON does not distinguish them but both Python and this tool do, and