Skip to content
Snippets Groups Projects
Commit 6d5a26e9 authored by Simon Sapin's avatar Simon Sapin
Browse files

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
parent 37f49d46
No related branches found
No related tags found
No related merge requests found
......@@ -300,7 +300,7 @@
// 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.
......@@ -305,7 +305,7 @@
}
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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment