# HG changeset patch # User Simon Sapin # Date 2021-04-09 10:02:51 # Node ID 6d5a26e94d9ee9816f1b9a45b22f55ed1b2b7ab0 # Parent 37f49d46239448523e6dfbbe9bc07b71150b3317 unit-tests: Fix `cargo test` on 32-bit platforms Fixes https://bz.mercurial-scm.org/show_bug.cgi?id=6506 This makes `IndexEntryBuilder::build`, which is only used in unit tests, use `u32` or `u64` instead of platform-dependent `usize` when packing binary data to be used at test input. To run Rust unit tests in 32-bit mode in a x86-64 environment, use: rustup target add i686-unknown-linux-gnu # Once (cd rust && cargo test --target i686-unknown-linux-gnu) Differential Revision: https://phab.mercurial-scm.org/D10351 diff --git a/rust/hg-core/src/revlog/index.rs b/rust/hg-core/src/revlog/index.rs --- a/rust/hg-core/src/revlog/index.rs +++ b/rust/hg-core/src/revlog/index.rs @@ -300,12 +300,12 @@ mod tests { // Remaining offset bytes. bytes.extend(&[0u8; 2]); } else { - // Offset is only 6 bytes will usize is 8. - bytes.extend(&self.offset.to_be_bytes()[2..]); + // Offset stored on 48 bits (6 bytes) + bytes.extend(&(self.offset as u64).to_be_bytes()[2..]); } bytes.extend(&[0u8; 2]); // Revision flags. - bytes.extend(&self.compressed_len.to_be_bytes()[4..]); - bytes.extend(&self.uncompressed_len.to_be_bytes()[4..]); + bytes.extend(&(self.compressed_len as u32).to_be_bytes()); + bytes.extend(&(self.uncompressed_len as u32).to_be_bytes()); bytes.extend(&self.base_revision.to_be_bytes()); bytes }