Skip to content

Commit 741a5a6

Browse files
committed
Merge #335
335: Clean up some warnings r=cuviper a=cuviper
2 parents 4896746 + 2f8f952 commit 741a5a6

File tree

7 files changed

+56
-53
lines changed

7 files changed

+56
-53
lines changed

bigint/src/algorithms.rs

-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ pub fn div_rem_digit(mut a: BigUint, b: BigDigit) -> (BigUint, BigDigit) {
123123
}
124124

125125
// Only for the Add impl:
126-
#[must_use]
127126
#[inline]
128127
pub fn __add2(a: &mut [BigDigit], b: &[BigDigit]) -> BigDigit {
129128
debug_assert!(a.len() >= b.len());

bigint/src/bigint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,7 @@ fn twos_complement<'a, I>(digits: I)
17571757
where I: IntoIterator<Item = &'a mut u8>
17581758
{
17591759
let mut carry = true;
1760-
for mut d in digits {
1760+
for d in digits {
17611761
*d = d.not();
17621762
if carry {
17631763
*d = d.wrapping_add(1);

bigint/src/macros.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(unknown_lints)] // older rustc doesn't know `unused_macros`
2+
#![allow(unused_macros)]
13

24
macro_rules! forward_val_val_binop {
35
(impl $imp:ident for $res:ty, $method:ident) => {

traits/src/bounds.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,17 @@ for_each_tuple!(bounded_tuple);
7777
bounded_impl!(f64, f64::MIN, f64::MAX);
7878

7979

80-
macro_rules! test_wrapping_bounded {
81-
($($t:ty)+) => {
82-
$(
83-
assert_eq!(Wrapping::<$t>::min_value().0, <$t>::min_value());
84-
assert_eq!(Wrapping::<$t>::max_value().0, <$t>::max_value());
85-
)+
86-
};
87-
}
88-
8980
#[test]
9081
fn wrapping_bounded() {
82+
macro_rules! test_wrapping_bounded {
83+
($($t:ty)+) => {
84+
$(
85+
assert_eq!(Wrapping::<$t>::min_value().0, <$t>::min_value());
86+
assert_eq!(Wrapping::<$t>::max_value().0, <$t>::max_value());
87+
)+
88+
};
89+
}
90+
9191
test_wrapping_bounded!(usize u8 u16 u32 u64 isize i8 i16 i32 i64);
9292
}
9393

traits/src/cast.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -466,29 +466,29 @@ fn to_primitive_float() {
466466
assert!((f64::NAN).to_f32().map_or(false, |f| f.is_nan()));
467467
}
468468

469-
macro_rules! test_wrapping_to_primitive {
470-
($($t:ty)+) => {
471-
$({
472-
let i: $t = 0;
473-
let w = Wrapping(i);
474-
assert_eq!(i.to_u8(), w.to_u8());
475-
assert_eq!(i.to_u16(), w.to_u16());
476-
assert_eq!(i.to_u32(), w.to_u32());
477-
assert_eq!(i.to_u64(), w.to_u64());
478-
assert_eq!(i.to_usize(), w.to_usize());
479-
assert_eq!(i.to_i8(), w.to_i8());
480-
assert_eq!(i.to_i16(), w.to_i16());
481-
assert_eq!(i.to_i32(), w.to_i32());
482-
assert_eq!(i.to_i64(), w.to_i64());
483-
assert_eq!(i.to_isize(), w.to_isize());
484-
assert_eq!(i.to_f32(), w.to_f32());
485-
assert_eq!(i.to_f64(), w.to_f64());
486-
})+
487-
};
488-
}
489-
490469
#[test]
491470
fn wrapping_to_primitive() {
471+
macro_rules! test_wrapping_to_primitive {
472+
($($t:ty)+) => {
473+
$({
474+
let i: $t = 0;
475+
let w = Wrapping(i);
476+
assert_eq!(i.to_u8(), w.to_u8());
477+
assert_eq!(i.to_u16(), w.to_u16());
478+
assert_eq!(i.to_u32(), w.to_u32());
479+
assert_eq!(i.to_u64(), w.to_u64());
480+
assert_eq!(i.to_usize(), w.to_usize());
481+
assert_eq!(i.to_i8(), w.to_i8());
482+
assert_eq!(i.to_i16(), w.to_i16());
483+
assert_eq!(i.to_i32(), w.to_i32());
484+
assert_eq!(i.to_i64(), w.to_i64());
485+
assert_eq!(i.to_isize(), w.to_isize());
486+
assert_eq!(i.to_f32(), w.to_f32());
487+
assert_eq!(i.to_f64(), w.to_f64());
488+
})+
489+
};
490+
}
491+
492492
test_wrapping_to_primitive!(usize u8 u16 u32 u64 isize i8 i16 i32 i64);
493493
}
494494

traits/src/identities.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,19 @@ impl<T: One> One for Wrapping<T> where Wrapping<T>: Mul<Output=Wrapping<T>> {
120120
#[inline(always)] pub fn one<T: One>() -> T { One::one() }
121121

122122

123-
macro_rules! test_wrapping_identities {
124-
($($t:ty)+) => {
125-
$(
126-
assert_eq!(zero::<$t>(), zero::<Wrapping<$t>>().0);
127-
assert_eq!(one::<$t>(), one::<Wrapping<$t>>().0);
128-
assert_eq!((0 as $t).is_zero(), Wrapping(0 as $t).is_zero());
129-
assert_eq!((1 as $t).is_zero(), Wrapping(1 as $t).is_zero());
130-
)+
131-
};
132-
}
133-
134123
#[test]
135124
fn wrapping_identities() {
125+
macro_rules! test_wrapping_identities {
126+
($($t:ty)+) => {
127+
$(
128+
assert_eq!(zero::<$t>(), zero::<Wrapping<$t>>().0);
129+
assert_eq!(one::<$t>(), one::<Wrapping<$t>>().0);
130+
assert_eq!((0 as $t).is_zero(), Wrapping(0 as $t).is_zero());
131+
assert_eq!((1 as $t).is_zero(), Wrapping(1 as $t).is_zero());
132+
)+
133+
};
134+
}
135+
136136
test_wrapping_identities!(isize i8 i16 i32 i64 usize u8 u16 u32 u64);
137137
}
138138

traits/src/lib.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -361,24 +361,26 @@ fn from_str_radix_unwrap() {
361361
assert_eq!(f, 0.0);
362362
}
363363

364-
macro_rules! test_wrapping_from_str_radix {
365-
($($t:ty)+) => {
366-
$(
367-
for &(s, r) in &[("42", 10), ("42", 2), ("-13.0", 10), ("foo", 10)] {
368-
let w = Wrapping::<$t>::from_str_radix(s, r).map(|w| w.0);
369-
assert_eq!(w, <$t as Num>::from_str_radix(s, r));
370-
}
371-
)+
372-
};
373-
}
374364
#[test]
375365
fn wrapping_is_num() {
376366
fn require_num<T: Num>(_: &T) {}
377367
require_num(&Wrapping(42_u32));
378368
require_num(&Wrapping(-42));
379369
}
370+
380371
#[test]
381372
fn wrapping_from_str_radix() {
373+
macro_rules! test_wrapping_from_str_radix {
374+
($($t:ty)+) => {
375+
$(
376+
for &(s, r) in &[("42", 10), ("42", 2), ("-13.0", 10), ("foo", 10)] {
377+
let w = Wrapping::<$t>::from_str_radix(s, r).map(|w| w.0);
378+
assert_eq!(w, <$t as Num>::from_str_radix(s, r));
379+
}
380+
)+
381+
};
382+
}
383+
382384
test_wrapping_from_str_radix!(usize u8 u16 u32 u64 isize i8 i16 i32 i64);
383385
}
384386

0 commit comments

Comments
 (0)