Skip to content
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

Uppercase statics lint #7523

Merged
merged 2 commits into from
Jul 3, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -1107,20 +1107,20 @@ The derived types are borrowed pointers with the `'static` lifetime,
fixed-size arrays, tuples, and structs.

~~~~
static bit1: uint = 1 << 0;
static bit2: uint = 1 << 1;
static BIT1: uint = 1 << 0;
static BIT2: uint = 1 << 1;

static bits: [uint, ..2] = [bit1, bit2];
static string: &'static str = "bitstring";
static BITS: [uint, ..2] = [BIT1, BIT2];
static STRING: &'static str = "bitstring";

struct BitsNStrings<'self> {
mybits: [uint, ..2],
mystring: &'self str
}

static bits_n_strings: BitsNStrings<'static> = BitsNStrings {
mybits: bits,
mystring: string
mybits: BITS,
mystring: STRING
};
~~~~

Expand Down
4 changes: 2 additions & 2 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ can specify a variable's type by following it with a colon, then the type
name. Static items, on the other hand, always require a type annotation.

~~~~
static monster_factor: float = 57.8;
let monster_size = monster_factor * 10.0;
static MONSTER_FACTOR: float = 57.8;
let monster_size = MONSTER_FACTOR * 10.0;
let monster_size: int = 50;
~~~~

Expand Down
8 changes: 4 additions & 4 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ fn run_rfail_test(config: &config, props: &TestProps, testfile: &Path) {
};

// The value our Makefile configures valgrind to return on failure
static valgrind_err: int = 100;
if ProcRes.status == valgrind_err {
static VALGRIND_ERR: int = 100;
if ProcRes.status == VALGRIND_ERR {
fatal_ProcRes(~"run-fail test isn't valgrind-clean!", &ProcRes);
}

Expand All @@ -102,8 +102,8 @@ fn run_rfail_test(config: &config, props: &TestProps, testfile: &Path) {

fn check_correct_failure_status(ProcRes: &ProcRes) {
// The value the rust runtime returns on failure
static rust_err: int = 101;
if ProcRes.status != rust_err {
static RUST_ERR: int = 101;
if ProcRes.status != RUST_ERR {
fatal_ProcRes(
fmt!("failure produced the wrong error code: %d",
ProcRes.status),
Expand Down
1 change: 1 addition & 0 deletions src/etc/unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ def emit_decomp_module(f, canon, compat):
// The following code was generated by "src/etc/unicode.py"

#[allow(missing_doc)];
#[allow(non_uppercase_statics)];

''')

Expand Down
16 changes: 8 additions & 8 deletions src/libextra/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ mod tests {
use std::rand;
use std::rand::Rng;

static bench_bits : uint = 1 << 14;
static BENCH_BITS : uint = 1 << 14;

#[test]
fn test_to_str() {
Expand Down Expand Up @@ -1452,19 +1452,19 @@ mod tests {
fn bench_big_bitv_big(b: &mut BenchHarness) {
let mut r = rng();
let mut storage = ~[];
storage.grow(bench_bits / uint::bits, &0);
storage.grow(BENCH_BITS / uint::bits, &0);
let mut bitv = BigBitv::new(storage);
do b.iter {
bitv.set((r.next() as uint) % bench_bits, true);
bitv.set((r.next() as uint) % BENCH_BITS, true);
}
}

#[bench]
fn bench_bitv_big(b: &mut BenchHarness) {
let mut r = rng();
let mut bitv = Bitv::new(bench_bits, false);
let mut bitv = Bitv::new(BENCH_BITS, false);
do b.iter {
bitv.set((r.next() as uint) % bench_bits, true);
bitv.set((r.next() as uint) % BENCH_BITS, true);
}
}

Expand All @@ -1491,14 +1491,14 @@ mod tests {
let mut r = rng();
let mut bitv = BitvSet::new();
do b.iter {
bitv.insert((r.next() as uint) % bench_bits);
bitv.insert((r.next() as uint) % BENCH_BITS);
}
}

#[bench]
fn bench_bitv_big_union(b: &mut BenchHarness) {
let mut b1 = Bitv::new(bench_bits, false);
let b2 = Bitv::new(bench_bits, false);
let mut b1 = Bitv::new(BENCH_BITS, false);
let b2 = Bitv::new(BENCH_BITS, false);
do b.iter {
b1.union(&b2);
}
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::util::replace;
use std::vec;
use std::cast::transmute;

static initial_capacity: uint = 32u; // 2^5
static INITIAL_CAPACITY: uint = 32u; // 2^5

#[allow(missing_doc)]
pub struct Deque<T> {
Expand Down Expand Up @@ -47,7 +47,7 @@ impl<T> Deque<T> {
/// Create an empty Deque
pub fn new() -> Deque<T> {
Deque{nelts: 0, lo: 0, hi: 0,
elts: vec::from_fn(initial_capacity, |_| None)}
elts: vec::from_fn(INITIAL_CAPACITY, |_| None)}
}

/// Return a reference to the first element in the deque
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/ebml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ pub mod writer {

// Set to true to generate more debugging in EBML code.
// Totally lame approach.
static debug: bool = true;
static DEBUG: bool = true;

impl Encoder {
// used internally to emit things like the vector length and so on
Expand All @@ -764,7 +764,7 @@ pub mod writer {
// efficiency. When debugging, though, we can emit such
// labels and then they will be checked by decoder to
// try and check failures more quickly.
if debug { self.wr_tagged_str(EsLabel as uint, label) }
if DEBUG { self.wr_tagged_str(EsLabel as uint, label) }
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/libextra/flate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ pub mod rustrt {
}
}

static lz_none : c_int = 0x0; // Huffman-coding only.
static lz_fast : c_int = 0x1; // LZ with only one probe
static lz_norm : c_int = 0x80; // LZ with 128 probes, "normal"
static lz_best : c_int = 0xfff; // LZ with 4095 probes, "best"
static LZ_NONE : c_int = 0x0; // Huffman-coding only.
static LZ_FAST : c_int = 0x1; // LZ with only one probe
static LZ_NORM : c_int = 0x80; // LZ with 128 probes, "normal"
static LZ_BEST : c_int = 0xfff; // LZ with 4095 probes, "best"

pub fn deflate_bytes(bytes: &[u8]) -> ~[u8] {
do vec::as_imm_buf(bytes) |b, len| {
Expand All @@ -52,7 +52,7 @@ pub fn deflate_bytes(bytes: &[u8]) -> ~[u8] {
rustrt::tdefl_compress_mem_to_heap(b as *c_void,
len as size_t,
&mut outsz,
lz_norm);
LZ_NORM);
assert!(res as int != 0);
let out = vec::raw::from_buf_raw(res as *u8,
outsz as uint);
Expand Down
1 change: 1 addition & 0 deletions src/libextra/num/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ A BigInt is a combination of BigUint and Sign.
*/

#[allow(missing_doc)];
#[allow(non_uppercase_statics)];

use std::cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
use std::int;
Expand Down
2 changes: 2 additions & 0 deletions src/libextra/num/complex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ impl<T: ToStrRadix + Num + Ord> ToStrRadix for Cmplx<T> {

#[cfg(test)]
mod test {
#[allow(non_uppercase_statics)];

use super::*;
use std::num::{Zero,One,Real};

Expand Down
8 changes: 4 additions & 4 deletions src/libextra/par.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ use future_spawn = future::spawn;
* The maximum number of tasks this module will spawn for a single
* operation.
*/
static max_tasks : uint = 32u;
static MAX_TASKS : uint = 32u;

/// The minimum number of elements each task will process.
static min_granularity : uint = 1024u;
static MIN_GRANULARITY : uint = 1024u;

/**
* An internal helper to map a function over a large vector and
Expand All @@ -38,13 +38,13 @@ fn map_slices<A:Copy + Send,B:Copy + Send>(
-> ~[B] {

let len = xs.len();
if len < min_granularity {
if len < MIN_GRANULARITY {
info!("small slice");
// This is a small vector, fall back on the normal map.
~[f()(0u, xs)]
}
else {
let num_tasks = uint::min(max_tasks, len / min_granularity);
let num_tasks = uint::min(MAX_TASKS, len / MIN_GRANULARITY);

let items_per_task = len / num_tasks;

Expand Down
32 changes: 16 additions & 16 deletions src/libextra/rope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,14 +632,14 @@ pub mod node {
*
* This is not a strict value
*/
pub static hint_max_leaf_char_len: uint = 256u;
pub static HINT_MAX_LEAF_CHAR_LEN: uint = 256u;

/**
* The maximal height that _should_ be permitted in a tree.
*
* This is not a strict value
*/
pub static hint_max_node_height: uint = 16u;
pub static HINT_MAX_NODE_HEIGHT: uint = 16u;

/**
* Adopt a string as a node.
Expand Down Expand Up @@ -707,26 +707,26 @@ pub mod node {
char_len: char_len,
content: str,
});
if char_len <= hint_max_leaf_char_len {
if char_len <= HINT_MAX_LEAF_CHAR_LEN {
return candidate;
} else {
//Firstly, split `str` in slices of hint_max_leaf_char_len
let mut leaves = uint::div_ceil(char_len, hint_max_leaf_char_len);
//Firstly, split `str` in slices of HINT_MAX_LEAF_CHAR_LEN
let mut leaves = uint::div_ceil(char_len, HINT_MAX_LEAF_CHAR_LEN);
//Number of leaves
let mut nodes = vec::from_elem(leaves, candidate);

let mut i = 0u;
let mut offset = byte_start;
let first_leaf_char_len =
if char_len%hint_max_leaf_char_len == 0u {
hint_max_leaf_char_len
if char_len%HINT_MAX_LEAF_CHAR_LEN == 0u {
HINT_MAX_LEAF_CHAR_LEN
} else {
char_len%hint_max_leaf_char_len
char_len%HINT_MAX_LEAF_CHAR_LEN
};
while i < leaves {
let chunk_char_len: uint =
if i == 0u { first_leaf_char_len }
else { hint_max_leaf_char_len };
else { HINT_MAX_LEAF_CHAR_LEN };
let chunk_byte_len =
str.slice_from(offset).slice_chars(0, chunk_char_len).len();
nodes[i] = @Leaf(Leaf {
Expand Down Expand Up @@ -792,22 +792,22 @@ pub mod node {
let right_len= char_len(right);
let mut left_height= height(left);
let mut right_height=height(right);
if left_len + right_len > hint_max_leaf_char_len {
if left_len <= hint_max_leaf_char_len {
if left_len + right_len > HINT_MAX_LEAF_CHAR_LEN {
if left_len <= HINT_MAX_LEAF_CHAR_LEN {
left = flatten(left);
left_height = height(left);
}
if right_len <= hint_max_leaf_char_len {
if right_len <= HINT_MAX_LEAF_CHAR_LEN {
right = flatten(right);
right_height = height(right);
}
}
if left_height >= hint_max_node_height {
if left_height >= HINT_MAX_NODE_HEIGHT {
left = of_substr_unsafer(@serialize_node(left),
0u,byte_len(left),
left_len);
}
if right_height >= hint_max_node_height {
if right_height >= HINT_MAX_NODE_HEIGHT {
right = of_substr_unsafer(@serialize_node(right),
0u,byte_len(right),
right_len);
Expand Down Expand Up @@ -875,7 +875,7 @@ pub mod node {
*
* # Algorithm
*
* * if the node height is smaller than `hint_max_node_height`, do nothing
* * if the node height is smaller than `HINT_MAX_NODE_HEIGHT`, do nothing
* * otherwise, gather all leaves as a forest, rebuild a balanced node,
* concatenating small leaves along the way
*
Expand All @@ -886,7 +886,7 @@ pub mod node {
* as `node` bot lower height and/or fragmentation.
*/
pub fn bal(node: @Node) -> Option<@Node> {
if height(node) < hint_max_node_height { return None; }
if height(node) < HINT_MAX_NODE_HEIGHT { return None; }
//1. Gather all leaves as a forest
let mut forest = ~[];
let mut it = leaf_iterator::start(node);
Expand Down
34 changes: 17 additions & 17 deletions src/libextra/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ use std::io;
pub mod color {
pub type Color = u16;

pub static black: Color = 0u16;
pub static red: Color = 1u16;
pub static green: Color = 2u16;
pub static yellow: Color = 3u16;
pub static blue: Color = 4u16;
pub static magenta: Color = 5u16;
pub static cyan: Color = 6u16;
pub static white: Color = 7u16;

pub static bright_black: Color = 8u16;
pub static bright_red: Color = 9u16;
pub static bright_green: Color = 10u16;
pub static bright_yellow: Color = 11u16;
pub static bright_blue: Color = 12u16;
pub static bright_magenta: Color = 13u16;
pub static bright_cyan: Color = 14u16;
pub static bright_white: Color = 15u16;
pub static BLACK: Color = 0u16;
pub static RED: Color = 1u16;
pub static GREEN: Color = 2u16;
pub static YELLOW: Color = 3u16;
pub static BLUE: Color = 4u16;
pub static MAGENTA: Color = 5u16;
pub static CYAN: Color = 6u16;
pub static WHITE: Color = 7u16;

pub static BRIGHT_BLACK: Color = 8u16;
pub static BRIGHT_RED: Color = 9u16;
pub static BRIGHT_GREEN: Color = 10u16;
pub static BRIGHT_YELLOW: Color = 11u16;
pub static BRIGHT_BLUE: Color = 12u16;
pub static BRIGHT_MAGENTA: Color = 13u16;
pub static BRIGHT_CYAN: Color = 14u16;
pub static BRIGHT_WHITE: Color = 15u16;
}

#[cfg(not(target_os = "win32"))]
Expand Down
2 changes: 2 additions & 0 deletions src/libextra/terminfo/parser/compiled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[allow(non_uppercase_statics)];

/// ncurses-compatible compiled terminfo format parsing (term(5))


Expand Down
Loading