[ethash] use static_assertions crate (#10860)
This commit is contained in:
parent
141f6a047e
commit
88e0cfe5ca
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -790,6 +790,7 @@ dependencies = [
|
|||||||
"primal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"primal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"static_assertions 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -3907,6 +3908,11 @@ name = "static_assertions"
|
|||||||
version = "0.2.5"
|
version = "0.2.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "static_assertions"
|
||||||
|
version = "0.3.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stats"
|
name = "stats"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@ -5067,6 +5073,7 @@ dependencies = [
|
|||||||
"checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55"
|
"checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55"
|
||||||
"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"
|
"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"
|
||||||
"checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5"
|
"checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5"
|
||||||
|
"checksum static_assertions 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4f8de36da215253eb5f24020bfaa0646613b48bf7ebe36cdfa37c3b3b33b241"
|
||||||
"checksum stream-cipher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8861bc80f649f5b4c9bd38b696ae9af74499d479dbfb327f0607de6b326a36bc"
|
"checksum stream-cipher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8861bc80f649f5b4c9bd38b696ae9af74499d479dbfb327f0607de6b326a36bc"
|
||||||
"checksum string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00caf261d6f90f588f8450b8e1230fa0d5be49ee6140fdfbcb55335aff350970"
|
"checksum string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00caf261d6f90f588f8450b8e1230fa0d5be49ee6140fdfbcb55335aff350970"
|
||||||
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
|
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
|
||||||
|
@ -13,6 +13,7 @@ log = "0.4"
|
|||||||
memmap = "0.6"
|
memmap = "0.6"
|
||||||
parking_lot = "0.8"
|
parking_lot = "0.8"
|
||||||
primal = "0.2.3"
|
primal = "0.2.3"
|
||||||
|
static_assertions = "0.3.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = "0.2"
|
criterion = "0.2"
|
||||||
|
@ -24,6 +24,8 @@ extern crate primal;
|
|||||||
extern crate crunchy;
|
extern crate crunchy;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate static_assertions;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
extern crate rustc_hex;
|
extern crate rustc_hex;
|
||||||
|
@ -69,34 +69,7 @@ pub type NodeBytes = [u8; NODE_BYTES];
|
|||||||
pub type NodeWords = [u32; NODE_WORDS];
|
pub type NodeWords = [u32; NODE_WORDS];
|
||||||
pub type NodeDwords = [u64; NODE_DWORDS];
|
pub type NodeDwords = [u64; NODE_DWORDS];
|
||||||
|
|
||||||
macro_rules! static_assert_size_eq {
|
assert_eq_size!(node; Node, NodeBytes, NodeWords, NodeDwords);
|
||||||
(@inner $a:ty, $b:ty, $($rest:ty),*) => {
|
|
||||||
fn first() {
|
|
||||||
static_assert_size_eq!($a, $b);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn second() {
|
|
||||||
static_assert_size_eq!($b, $($rest),*);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
(@inner $a:ty, $b:ty) => {
|
|
||||||
unsafe {
|
|
||||||
let val: $b = ::std::mem::uninitialized();
|
|
||||||
let _: $a = ::std::mem::transmute(val);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
($($rest:ty),*) => {
|
|
||||||
static_assert_size_eq!(size_eq: $($rest),*);
|
|
||||||
};
|
|
||||||
($name:ident : $($rest:ty),*) => {
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn $name() {
|
|
||||||
static_assert_size_eq!(@inner $($rest),*);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static_assert_size_eq!(Node, NodeBytes, NodeWords, NodeDwords);
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub union Node {
|
pub union Node {
|
||||||
|
Loading…
Reference in New Issue
Block a user