diff --git a/ethbloom/src/lib.rs b/ethbloom/src/lib.rs index 682a0d247..5cc5b8119 100644 --- a/ethbloom/src/lib.rs +++ b/ethbloom/src/lib.rs @@ -8,22 +8,22 @@ //! use std::str::FromStr; //! let bloom = Bloom::from_str( //! "00000000000000000000000000000000\ -//! 00000000100000000000000000000000\ -//! 00000000000000000000000000000000\ -//! 00000000000000000000000000000000\ -//! 00000000000000000000000000000000\ -//! 00000000000000000000000000000000\ -//! 00000002020000000000000000000000\ -//! 00000000000000000000000800000000\ -//! 10000000000000000000000000000000\ -//! 00000000000000000000001000000000\ -//! 00000000000000000000000000000000\ -//! 00000000000000000000000000000000\ -//! 00000000000000000000000000000000\ -//! 00000000000000000000000000000000\ -//! 00000000000000000000000000000000\ -//! 00000000000000000000000000000000" -//! ).unwrap(); +//! 00000000100000000000000000000000\ +//! 00000000000000000000000000000000\ +//! 00000000000000000000000000000000\ +//! 00000000000000000000000000000000\ +//! 00000000000000000000000000000000\ +//! 00000002020000000000000000000000\ +//! 00000000000000000000000800000000\ +//! 10000000000000000000000000000000\ +//! 00000000000000000000001000000000\ +//! 00000000000000000000000000000000\ +//! 00000000000000000000000000000000\ +//! 00000000000000000000000000000000\ +//! 00000000000000000000000000000000\ +//! 00000000000000000000000000000000\ +//! 00000000000000000000000000000000" +//! ).unwrap(); //! let address = hex!("ef2d6d194084c2de36e0dabfce45d046b37d1106"); //! let topic = hex!("02c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc"); //! diff --git a/fixed-hash/Cargo.toml b/fixed-hash/Cargo.toml index 8672c6d31..e494fedd2 100644 --- a/fixed-hash/Cargo.toml +++ b/fixed-hash/Cargo.toml @@ -18,7 +18,7 @@ rand = { version = "0.7", optional = true, default-features = false } rustc-hex = { version = "2.0", optional = true, default-features = false } quickcheck = { version = "0.9", optional = true } byteorder = { version = "1.2", optional = true, default-features = false } -static_assertions = "0.3" +static_assertions = "1.0.0" [dev-dependencies] rand_xorshift = "0.2.0" diff --git a/fixed-hash/src/hash.rs b/fixed-hash/src/hash.rs index f8ffcb426..393b4cc93 100644 --- a/fixed-hash/src/hash.rs +++ b/fixed-hash/src/hash.rs @@ -779,7 +779,6 @@ macro_rules! impl_ops_for_hash { macro_rules! impl_fixed_hash_conversions { ($large_ty:ident, $small_ty:ident) => { $crate::static_assertions::const_assert!( - VALID_SIZES; $crate::core_::mem::size_of::<$small_ty>() < $crate::core_::mem::size_of::<$large_ty>() ); diff --git a/keccak-hash/src/lib.rs b/keccak-hash/src/lib.rs index 1b8926be1..77a3767e0 100644 --- a/keccak-hash/src/lib.rs +++ b/keccak-hash/src/lib.rs @@ -107,7 +107,7 @@ mod tests { keccak([0x41u8; 32]), H256([ 0x59, 0xca, 0xd5, 0x94, 0x86, 0x73, 0x62, 0x2c, - 0x1d, 0x64, 0xe2, 0x32, 0x24, 0x88, 0xbf, 0x01, + 0x1d, 0x64, 0xe2, 0x32, 0x24, 0x88, 0xbf, 0x01, 0x61, 0x9f, 0x7f, 0xf4, 0x57, 0x89, 0x74, 0x1b, 0x15, 0xa9, 0xf7, 0x82, 0xce, 0x92, 0x90, 0xa8 ]), diff --git a/parity-crypto/benches/bench.rs b/parity-crypto/benches/bench.rs index bdc9fd16d..6e739adb6 100644 --- a/parity-crypto/benches/bench.rs +++ b/parity-crypto/benches/bench.rs @@ -40,7 +40,7 @@ fn input_len(c: &mut Criterion) { let mut dest = vec![0; *size]; let k = [0; 16]; let iv = [0; 16]; - + b.iter(||{ parity_crypto::aes::encrypt_128_ctr(&k[..], &iv[..], &data[..], &mut dest[..]).unwrap(); // same as encrypt but add it just in case diff --git a/parity-crypto/src/aes.rs b/parity-crypto/src/aes.rs index dc62674d4..e13300524 100644 --- a/parity-crypto/src/aes.rs +++ b/parity-crypto/src/aes.rs @@ -66,14 +66,14 @@ impl AesCtr256 { )) } - /// In place encrypt a content without padding, the content length must be a multiple + /// In place encrypt a content without padding, the content length must be a multiple /// of the block size. pub fn encrypt(&mut self, content: &mut[u8]) -> Result<(), SymmError> { self.0.try_apply_keystream(content)?; Ok(()) } - /// In place decrypt a content without padding, the content length must be a multiple + /// In place decrypt a content without padding, the content length must be a multiple /// of the block size. pub fn decrypt(&mut self, content: &mut[u8]) -> Result<(), SymmError> { self.0.try_apply_keystream(content)?; diff --git a/uint/Cargo.toml b/uint/Cargo.toml index e35d809b6..cf6a88d03 100644 --- a/uint/Cargo.toml +++ b/uint/Cargo.toml @@ -14,6 +14,7 @@ byteorder = { version = "1", default-features = false } rustc-hex = { version = "2.0", default-features = false } quickcheck = { version = "0.6", optional = true } crunchy = { version = "0.2", default-features = true } +static_assertions = "1.0.0" [features] default = ["std"] diff --git a/uint/src/lib.rs b/uint/src/lib.rs index 5f803a271..1ef540d85 100644 --- a/uint/src/lib.rs +++ b/uint/src/lib.rs @@ -26,6 +26,8 @@ pub use rustc_hex; pub use quickcheck; #[doc(hidden)] +pub use static_assertions; + pub use crunchy::unroll; #[macro_use] diff --git a/uint/src/uint.rs b/uint/src/uint.rs index 5006bbd38..49dfcf07f 100644 --- a/uint/src/uint.rs +++ b/uint/src/uint.rs @@ -74,39 +74,37 @@ macro_rules! impl_try_from_for_primitive { #[doc(hidden)] macro_rules! uint_overflowing_binop { ($name:ident, $n_words: tt, $self_expr: expr, $other: expr, $fn:expr) => ({ + use $crate::{core_ as core}; let $name(ref me) = $self_expr; let $name(ref you) = $other; - let mut ret = unsafe { $crate::core_::mem::uninitialized() }; + let mut ret = [0u64; $n_words]; let ret_ptr = &mut ret as *mut [u64; $n_words] as *mut u64; let mut carry = 0u64; + $crate::static_assertions::const_assert!(core::isize::MAX as usize / core::mem::size_of::() > $n_words); // `unroll!` is recursive, but doesn’t use `$crate::unroll`, so we need to ensure that it // is in scope unqualified. use $crate::unroll; unroll! { for i in 0..$n_words { - use $crate::core_::ptr; + use core::ptr; if carry != 0 { let (res1, overflow1) = ($fn)(me[i], you[i]); let (res2, overflow2) = ($fn)(res1, carry); unsafe { - ptr::write( - ret_ptr.offset(i as _), - res2 - ); + // SAFETY: `i` is within bounds and `i * size_of::() < isize::MAX` + *ret_ptr.offset(i as _) = res2 } carry = (overflow1 as u8 + overflow2 as u8) as u64; } else { let (res, overflow) = ($fn)(me[i], you[i]); unsafe { - ptr::write( - ret_ptr.offset(i as _), - res - ); + // SAFETY: `i` is within bounds and `i * size_of::() < isize::MAX` + *ret_ptr.offset(i as _) = res } carry = overflow as u64;