Skip to content

A few fixes to lints and error messages #17215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 3, 2014
63 changes: 33 additions & 30 deletions src/libnum/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,12 @@ pub mod BigDigit {
use super::DoubleBigDigit;

// `DoubleBigDigit` size dependent
#[allow(non_uppercase_statics)]
pub static bits: uint = 32;

#[allow(non_uppercase_statics)]
pub static base: DoubleBigDigit = 1 << bits;
#[allow(non_uppercase_statics)]
static lo_mask: DoubleBigDigit = (-1 as DoubleBigDigit) >> bits;

#[inline]
Expand Down Expand Up @@ -1841,7 +1844,7 @@ mod biguint_tests {
BigInt::from_biguint(Plus, BigUint::new(vec!(1,2,3))));
}

static sum_triples: &'static [(&'static [BigDigit],
static SUM_TRIPLES: &'static [(&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit])] = &[
(&[], &[], &[]),
Expand All @@ -1857,7 +1860,7 @@ mod biguint_tests {

#[test]
fn test_add() {
for elm in sum_triples.iter() {
for elm in SUM_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
Expand All @@ -1870,7 +1873,7 @@ mod biguint_tests {

#[test]
fn test_sub() {
for elm in sum_triples.iter() {
for elm in SUM_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
Expand All @@ -1888,7 +1891,7 @@ mod biguint_tests {
a - b;
}

static mul_triples: &'static [(&'static [BigDigit],
static MUL_TRIPLES: &'static [(&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit])] = &[
(&[], &[], &[]),
Expand All @@ -1914,7 +1917,7 @@ mod biguint_tests {
(&[ 0, 0, 1], &[ 0, 0, 0, 1], &[0, 0, 0, 0, 0, 1])
];

static div_rem_quadruples: &'static [(&'static [BigDigit],
static DIV_REM_QUADRUPLES: &'static [(&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit])]
Expand All @@ -1928,7 +1931,7 @@ mod biguint_tests {

#[test]
fn test_mul() {
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
Expand All @@ -1938,7 +1941,7 @@ mod biguint_tests {
assert!(b * a == c);
}

for elm in div_rem_quadruples.iter() {
for elm in DIV_REM_QUADRUPLES.iter() {
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
Expand All @@ -1952,7 +1955,7 @@ mod biguint_tests {

#[test]
fn test_div_rem() {
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
Expand All @@ -1966,7 +1969,7 @@ mod biguint_tests {
}
}

for elm in div_rem_quadruples.iter() {
for elm in DIV_REM_QUADRUPLES.iter() {
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
Expand All @@ -1979,7 +1982,7 @@ mod biguint_tests {

#[test]
fn test_checked_add() {
for elm in sum_triples.iter() {
for elm in SUM_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
Expand All @@ -1992,7 +1995,7 @@ mod biguint_tests {

#[test]
fn test_checked_sub() {
for elm in sum_triples.iter() {
for elm in SUM_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
Expand All @@ -2012,7 +2015,7 @@ mod biguint_tests {

#[test]
fn test_checked_mul() {
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
Expand All @@ -2022,7 +2025,7 @@ mod biguint_tests {
assert!(b.checked_mul(&a).unwrap() == c);
}

for elm in div_rem_quadruples.iter() {
for elm in DIV_REM_QUADRUPLES.iter() {
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
Expand All @@ -2036,7 +2039,7 @@ mod biguint_tests {

#[test]
fn test_checked_div() {
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
Expand Down Expand Up @@ -2440,7 +2443,7 @@ mod bigint_tests {
assert_eq!(negative.to_biguint(), None);
}

static sum_triples: &'static [(&'static [BigDigit],
static SUM_TRIPLES: &'static [(&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit])] = &[
(&[], &[], &[]),
Expand All @@ -2456,7 +2459,7 @@ mod bigint_tests {

#[test]
fn test_add() {
for elm in sum_triples.iter() {
for elm in SUM_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
Expand All @@ -2475,7 +2478,7 @@ mod bigint_tests {

#[test]
fn test_sub() {
for elm in sum_triples.iter() {
for elm in SUM_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
Expand All @@ -2492,7 +2495,7 @@ mod bigint_tests {
}
}

static mul_triples: &'static [(&'static [BigDigit],
static MUL_TRIPLES: &'static [(&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit])] = &[
(&[], &[], &[]),
Expand All @@ -2518,7 +2521,7 @@ mod bigint_tests {
(&[ 0, 0, 1], &[ 0, 0, 0, 1], &[0, 0, 0, 0, 0, 1])
];

static div_rem_quadruples: &'static [(&'static [BigDigit],
static DIV_REM_QUADRUPLES: &'static [(&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit],
&'static [BigDigit])]
Expand All @@ -2532,7 +2535,7 @@ mod bigint_tests {

#[test]
fn test_mul() {
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
Expand All @@ -2545,7 +2548,7 @@ mod bigint_tests {
assert!((-b) * a == -c);
}

for elm in div_rem_quadruples.iter() {
for elm in DIV_REM_QUADRUPLES.iter() {
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
Expand Down Expand Up @@ -2584,7 +2587,7 @@ mod bigint_tests {
}
}

for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
Expand All @@ -2594,7 +2597,7 @@ mod bigint_tests {
if !b.is_zero() { check(&c, &b, &a, &Zero::zero()); }
}

for elm in div_rem_quadruples.iter() {
for elm in DIV_REM_QUADRUPLES.iter() {
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
Expand Down Expand Up @@ -2627,7 +2630,7 @@ mod bigint_tests {
check_sub(&a.neg(), b, &q.neg(), &r.neg());
check_sub(&a.neg(), &b.neg(), q, &r.neg());
}
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
Expand All @@ -2637,7 +2640,7 @@ mod bigint_tests {
if !b.is_zero() { check(&c, &b, &a, &Zero::zero()); }
}

for elm in div_rem_quadruples.iter() {
for elm in DIV_REM_QUADRUPLES.iter() {
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
Expand All @@ -2652,7 +2655,7 @@ mod bigint_tests {

#[test]
fn test_checked_add() {
for elm in sum_triples.iter() {
for elm in SUM_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
Expand All @@ -2671,7 +2674,7 @@ mod bigint_tests {

#[test]
fn test_checked_sub() {
for elm in sum_triples.iter() {
for elm in SUM_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
Expand All @@ -2690,7 +2693,7 @@ mod bigint_tests {

#[test]
fn test_checked_mul() {
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
Expand All @@ -2703,7 +2706,7 @@ mod bigint_tests {
assert!((-b).checked_mul(&a).unwrap() == -c);
}

for elm in div_rem_quadruples.iter() {
for elm in DIV_REM_QUADRUPLES.iter() {
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
Expand All @@ -2716,7 +2719,7 @@ mod bigint_tests {
}
#[test]
fn test_checked_div() {
for elm in mul_triples.iter() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
Expand Down
3 changes: 3 additions & 0 deletions src/libnum/rational.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,13 @@ mod test {
pub static _2: Rational = Ratio { numer: 2, denom: 1};
pub static _1_2: Rational = Ratio { numer: 1, denom: 2};
pub static _3_2: Rational = Ratio { numer: 3, denom: 2};
#[allow(non_uppercase_statics)]
pub static _neg1_2: Rational = Ratio { numer: -1, denom: 2};
pub static _1_3: Rational = Ratio { numer: 1, denom: 3};
#[allow(non_uppercase_statics)]
pub static _neg1_3: Rational = Ratio { numer: -1, denom: 3};
pub static _2_3: Rational = Ratio { numer: 2, denom: 3};
#[allow(non_uppercase_statics)]
pub static _neg2_3: Rational = Ratio { numer: -2, denom: 3};

pub fn to_big(n: Rational) -> BigRational {
Expand Down
6 changes: 3 additions & 3 deletions src/librand/reseeding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,15 @@ mod test {
assert_eq!(string1, string2);
}

static fill_bytes_v_len: uint = 13579;
static FILL_BYTES_V_LEN: uint = 13579;
#[test]
fn test_rng_fill_bytes() {
let mut v = Vec::from_elem(fill_bytes_v_len, 0u8);
let mut v = Vec::from_elem(FILL_BYTES_V_LEN, 0u8);
::test::rng().fill_bytes(v.as_mut_slice());

// Sanity test: if we've gotten here, `fill_bytes` has not infinitely
// recursed.
assert_eq!(v.len(), fill_bytes_v_len);
assert_eq!(v.len(), FILL_BYTES_V_LEN);

// To test that `fill_bytes` actually did something, check that the
// average of `v` is not 0.
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/driver/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ pub fn get_os(triple: &str) -> Option<abi::Os> {
}
None
}
#[allow(non_uppercase_statics)]
static os_names : &'static [(&'static str, abi::Os)] = &[
("mingw32", abi::OsWindows),
("win32", abi::OsWindows),
Expand All @@ -511,6 +512,7 @@ pub fn get_arch(triple: &str) -> Option<abi::Architecture> {
}
None
}
#[allow(non_uppercase_statics)]
static architecture_abis : &'static [(&'static str, abi::Architecture)] = &[
("i386", abi::X86),
("i486", abi::X86),
Expand Down
Loading