Merge pull request #260 from tcharding/clippy

Clear clippy warnings
This commit is contained in:
Andrew Poelstra 2020-12-22 02:18:24 +00:00 committed by GitHub
commit 1a818ea099
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 11 deletions

View File

@ -43,6 +43,7 @@ pub const SECP256K1_START_VERIFY: c_uint = 1 | (1 << 8);
/// Flag for context to enable signing precomputation /// Flag for context to enable signing precomputation
pub const SECP256K1_START_SIGN: c_uint = 1 | (1 << 9); pub const SECP256K1_START_SIGN: c_uint = 1 | (1 << 9);
/// Flag for keys to indicate uncompressed serialization format /// Flag for keys to indicate uncompressed serialization format
#[allow(unused_parens)]
pub const SECP256K1_SER_UNCOMPRESSED: c_uint = (1 << 1); pub const SECP256K1_SER_UNCOMPRESSED: c_uint = (1 << 1);
/// Flag for keys to indicate compressed serialization format /// Flag for keys to indicate compressed serialization format
pub const SECP256K1_SER_COMPRESSED: c_uint = (1 << 1) | (1 << 8); pub const SECP256K1_SER_COMPRESSED: c_uint = (1 << 1) | (1 << 8);
@ -629,7 +630,8 @@ pub unsafe extern "C" fn rustsecp256k1_v0_3_1_default_error_callback_fn(message:
panic!("[libsecp256k1] internal consistency check failed {}", msg); panic!("[libsecp256k1] internal consistency check failed {}", msg);
} }
#[no_mangle]
#[cfg(not(feature = "external-symbols"))]
unsafe fn strlen(mut str_ptr: *const c_char) -> usize { unsafe fn strlen(mut str_ptr: *const c_char) -> usize {
let mut ctr = 0; let mut ctr = 0;
while *str_ptr != '\0' as c_char { while *str_ptr != '\0' as c_char {
@ -1160,11 +1162,13 @@ pub use self::fuzz_dummy::*;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#[no_mangle]
#[cfg(not(feature = "external-symbols"))]
#[test]
fn test_strlen() {
use std::ffi::CString; use std::ffi::CString;
use super::strlen; use super::strlen;
#[test]
fn test_strlen() {
let orig = "test strlen \t \n"; let orig = "test strlen \t \n";
let test = CString::new(orig).unwrap(); let test = CString::new(orig).unwrap();

View File

@ -34,13 +34,6 @@ macro_rules! impl_array_newtype {
dat.as_mut_ptr() dat.as_mut_ptr()
} }
#[inline]
/// Gets a reference to the underlying array
pub fn as_ref(&self) -> &[$ty; $len] {
let &$thing(ref dat) = self;
dat
}
#[inline] #[inline]
/// Returns the length of the object as an array /// Returns the length of the object as an array
pub fn len(&self) -> usize { $len } pub fn len(&self) -> usize { $len }
@ -50,6 +43,15 @@ macro_rules! impl_array_newtype {
pub fn is_empty(&self) -> bool { false } pub fn is_empty(&self) -> bool { false }
} }
impl AsRef<[$ty; $len]> for $thing {
#[inline]
/// Gets a reference to the underlying array
fn as_ref(&self) -> &[$ty; $len] {
let &$thing(ref dat) = self;
dat
}
}
impl PartialEq for $thing { impl PartialEq for $thing {
#[inline] #[inline]
fn eq(&self, other: &$thing) -> bool { fn eq(&self, other: &$thing) -> bool {

View File

@ -40,6 +40,7 @@ impl AlignedType {
} }
} }
#[cfg(all(feature = "std", not(feature = "external-symbols")))]
pub(crate) const ALIGN_TO: usize = mem::align_of::<AlignedType>(); pub(crate) const ALIGN_TO: usize = mem::align_of::<AlignedType>();