335: Clean up some warnings r=cuviper a=cuviper
This commit is contained in:
bors[bot] 2017-09-22 00:38:06 +00:00
commit 741a5a6207
7 changed files with 56 additions and 53 deletions

View File

@ -123,7 +123,6 @@ pub fn div_rem_digit(mut a: BigUint, b: BigDigit) -> (BigUint, BigDigit) {
} }
// Only for the Add impl: // Only for the Add impl:
#[must_use]
#[inline] #[inline]
pub fn __add2(a: &mut [BigDigit], b: &[BigDigit]) -> BigDigit { pub fn __add2(a: &mut [BigDigit], b: &[BigDigit]) -> BigDigit {
debug_assert!(a.len() >= b.len()); debug_assert!(a.len() >= b.len());

View File

@ -1757,7 +1757,7 @@ fn twos_complement<'a, I>(digits: I)
where I: IntoIterator<Item = &'a mut u8> where I: IntoIterator<Item = &'a mut u8>
{ {
let mut carry = true; let mut carry = true;
for mut d in digits { for d in digits {
*d = d.not(); *d = d.not();
if carry { if carry {
*d = d.wrapping_add(1); *d = d.wrapping_add(1);

View File

@ -1,3 +1,5 @@
#![allow(unknown_lints)] // older rustc doesn't know `unused_macros`
#![allow(unused_macros)]
macro_rules! forward_val_val_binop { macro_rules! forward_val_val_binop {
(impl $imp:ident for $res:ty, $method:ident) => { (impl $imp:ident for $res:ty, $method:ident) => {

View File

@ -77,6 +77,8 @@ for_each_tuple!(bounded_tuple);
bounded_impl!(f64, f64::MIN, f64::MAX); bounded_impl!(f64, f64::MIN, f64::MAX);
#[test]
fn wrapping_bounded() {
macro_rules! test_wrapping_bounded { macro_rules! test_wrapping_bounded {
($($t:ty)+) => { ($($t:ty)+) => {
$( $(
@ -86,8 +88,6 @@ macro_rules! test_wrapping_bounded {
}; };
} }
#[test]
fn wrapping_bounded() {
test_wrapping_bounded!(usize u8 u16 u32 u64 isize i8 i16 i32 i64); test_wrapping_bounded!(usize u8 u16 u32 u64 isize i8 i16 i32 i64);
} }

View File

@ -466,6 +466,8 @@ fn to_primitive_float() {
assert!((f64::NAN).to_f32().map_or(false, |f| f.is_nan())); assert!((f64::NAN).to_f32().map_or(false, |f| f.is_nan()));
} }
#[test]
fn wrapping_to_primitive() {
macro_rules! test_wrapping_to_primitive { macro_rules! test_wrapping_to_primitive {
($($t:ty)+) => { ($($t:ty)+) => {
$({ $({
@ -487,8 +489,6 @@ macro_rules! test_wrapping_to_primitive {
}; };
} }
#[test]
fn wrapping_to_primitive() {
test_wrapping_to_primitive!(usize u8 u16 u32 u64 isize i8 i16 i32 i64); test_wrapping_to_primitive!(usize u8 u16 u32 u64 isize i8 i16 i32 i64);
} }

View File

@ -120,6 +120,8 @@ impl<T: One> One for Wrapping<T> where Wrapping<T>: Mul<Output=Wrapping<T>> {
#[inline(always)] pub fn one<T: One>() -> T { One::one() } #[inline(always)] pub fn one<T: One>() -> T { One::one() }
#[test]
fn wrapping_identities() {
macro_rules! test_wrapping_identities { macro_rules! test_wrapping_identities {
($($t:ty)+) => { ($($t:ty)+) => {
$( $(
@ -131,8 +133,6 @@ macro_rules! test_wrapping_identities {
}; };
} }
#[test]
fn wrapping_identities() {
test_wrapping_identities!(isize i8 i16 i32 i64 usize u8 u16 u32 u64); test_wrapping_identities!(isize i8 i16 i32 i64 usize u8 u16 u32 u64);
} }

View File

@ -361,6 +361,15 @@ fn from_str_radix_unwrap() {
assert_eq!(f, 0.0); assert_eq!(f, 0.0);
} }
#[test]
fn wrapping_is_num() {
fn require_num<T: Num>(_: &T) {}
require_num(&Wrapping(42_u32));
require_num(&Wrapping(-42));
}
#[test]
fn wrapping_from_str_radix() {
macro_rules! test_wrapping_from_str_radix { macro_rules! test_wrapping_from_str_radix {
($($t:ty)+) => { ($($t:ty)+) => {
$( $(
@ -371,14 +380,7 @@ macro_rules! test_wrapping_from_str_radix {
)+ )+
}; };
} }
#[test]
fn wrapping_is_num() {
fn require_num<T: Num>(_: &T) {}
require_num(&Wrapping(42_u32));
require_num(&Wrapping(-42));
}
#[test]
fn wrapping_from_str_radix() {
test_wrapping_from_str_radix!(usize u8 u16 u32 u64 isize i8 i16 i32 i64); test_wrapping_from_str_radix!(usize u8 u16 u32 u64 isize i8 i16 i32 i64);
} }