Skip to content

Commit

Permalink
Set the non_uppercase_statics lint to warn by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ftxqxd committed Oct 3, 2014
1 parent aa034cd commit 94bcd35
Show file tree
Hide file tree
Showing 37 changed files with 234 additions and 172 deletions.
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
2 changes: 1 addition & 1 deletion src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ impl LintPass for NonSnakeCase {
}
}

declare_lint!(pub NON_UPPERCASE_STATICS, Allow,
declare_lint!(pub NON_UPPERCASE_STATICS, Warn,
"static constants should have uppercase identifiers")

pub struct NonUppercaseStatics;
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ macro_rules! declare_lint (
#[macro_export]
macro_rules! lint_array ( ($( $lint:expr ),*) => (
{
#[allow(non_uppercase_statics)]
static array: LintArray = &[ $( $lint ),* ];
array
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![allow(non_camel_case_types)]
#![allow(non_camel_case_types, non_uppercase_statics)]

use std::mem;
use back::svh::Svh;
Expand Down
1 change: 1 addition & 0 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2028,6 +2028,7 @@ fn encode_dylib_dependency_formats(rbml_w: &mut Encoder, ecx: &EncodeContext) {
}

// NB: Increment this as you change the metadata encoding version.
#[allow(non_uppercase_statics)]
pub static metadata_encoding_version : &'static [u8] = &[b'r', b'u', b's', b't', 0, 0, 0, 1 ];

pub fn encode_metadata(parms: EncodeParams, krate: &Crate) -> Vec<u8> {
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/middle/borrowck/move_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl Clone for MovePathIndex {
}
}

#[allow(non_uppercase_statics)]
static InvalidMovePathIndex: MovePathIndex =
MovePathIndex(uint::MAX);

Expand All @@ -96,6 +97,7 @@ impl MoveIndex {
}
}

#[allow(non_uppercase_statics)]
static InvalidMoveIndex: MoveIndex =
MoveIndex(uint::MAX);

Expand Down

0 comments on commit 94bcd35

Please sign in to comment.