about summary refs log tree commit diff
path: root/src/libextra
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-07-03 04:31:50 -0700
committerbors <bors@rust-lang.org>2013-07-03 04:31:50 -0700
commit55f155521d2f604794d2ab1de2a8d439440af4a8 (patch)
tree69ef091fd4237ad3109b7e05e99421b97a576b0f /src/libextra
parent6caaa34dedc45543e4d2c7600f952e042d9258df (diff)
parentc437a16c5d8c00b39dc6c5e36011def997d77224 (diff)
auto merge of #7523 : huonw/rust/uppercase-statics-lint, r=cmr
Adds a lint for `static some_lowercase_name: uint = 1;`. Warning by default since it causes confusion, e.g. `static a: uint = 1; ... let a = 2;` => `error: only refutable patterns allowed here`.
Diffstat (limited to 'src/libextra')
-rw-r--r--src/libextra/bitv.rs16
-rw-r--r--src/libextra/deque.rs4
-rw-r--r--src/libextra/ebml.rs4
-rw-r--r--src/libextra/flate.rs10
-rw-r--r--src/libextra/num/bigint.rs1
-rw-r--r--src/libextra/num/complex.rs2
-rw-r--r--src/libextra/par.rs8
-rw-r--r--src/libextra/rope.rs32
-rw-r--r--src/libextra/term.rs34
-rw-r--r--src/libextra/terminfo/parser/compiled.rs2
-rw-r--r--src/libextra/test.rs14
-rw-r--r--src/libextra/time.rs8
12 files changed, 70 insertions, 65 deletions
diff --git a/src/libextra/bitv.rs b/src/libextra/bitv.rs
index 30541f83238..72b6e6dc650 100644
--- a/src/libextra/bitv.rs
+++ b/src/libextra/bitv.rs
@@ -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() {
@@ -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);
         }
     }
 
@@ -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);
         }
diff --git a/src/libextra/deque.rs b/src/libextra/deque.rs
index f834860a4f7..e89c12e5848 100644
--- a/src/libextra/deque.rs
+++ b/src/libextra/deque.rs
@@ -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> {
@@ -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
diff --git a/src/libextra/ebml.rs b/src/libextra/ebml.rs
index c79b012cfc5..502e45e1d47 100644
--- a/src/libextra/ebml.rs
+++ b/src/libextra/ebml.rs
@@ -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
@@ -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) }
         }
     }
 
diff --git a/src/libextra/flate.rs b/src/libextra/flate.rs
index 92f9f834f52..f249feeb440 100644
--- a/src/libextra/flate.rs
+++ b/src/libextra/flate.rs
@@ -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| {
@@ -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);
diff --git a/src/libextra/num/bigint.rs b/src/libextra/num/bigint.rs
index 9422ad0c9f2..25aeccdcbed 100644
--- a/src/libextra/num/bigint.rs
+++ b/src/libextra/num/bigint.rs
@@ -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;
diff --git a/src/libextra/num/complex.rs b/src/libextra/num/complex.rs
index 915523443fb..00224f8b06d 100644
--- a/src/libextra/num/complex.rs
+++ b/src/libextra/num/complex.rs
@@ -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};
 
diff --git a/src/libextra/par.rs b/src/libextra/par.rs
index 2878a3ee122..2d827365681 100644
--- a/src/libextra/par.rs
+++ b/src/libextra/par.rs
@@ -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
@@ -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;
 
diff --git a/src/libextra/rope.rs b/src/libextra/rope.rs
index 8374c1a86e3..dd3f08917fd 100644
--- a/src/libextra/rope.rs
+++ b/src/libextra/rope.rs
@@ -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.
@@ -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 {
@@ -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);
@@ -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
      *
@@ -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);
diff --git a/src/libextra/term.rs b/src/libextra/term.rs
index e21e5c5fb58..55626622775 100644
--- a/src/libextra/term.rs
+++ b/src/libextra/term.rs
@@ -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"))]
diff --git a/src/libextra/terminfo/parser/compiled.rs b/src/libextra/terminfo/parser/compiled.rs
index 063d26d1424..e16297e3871 100644
--- a/src/libextra/terminfo/parser/compiled.rs
+++ b/src/libextra/terminfo/parser/compiled.rs
@@ -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))
 
 
diff --git a/src/libextra/test.rs b/src/libextra/test.rs
index 1e1e53de9e8..59aed0055d8 100644
--- a/src/libextra/test.rs
+++ b/src/libextra/test.rs
@@ -331,19 +331,19 @@ pub fn run_tests_console(opts: &TestOpts,
     }
 
     fn write_ok(out: @io::Writer, use_color: bool) {
-        write_pretty(out, "ok", term::color::green, use_color);
+        write_pretty(out, "ok", term::color::GREEN, use_color);
     }
 
     fn write_failed(out: @io::Writer, use_color: bool) {
-        write_pretty(out, "FAILED", term::color::red, use_color);
+        write_pretty(out, "FAILED", term::color::RED, use_color);
     }
 
     fn write_ignored(out: @io::Writer, use_color: bool) {
-        write_pretty(out, "ignored", term::color::yellow, use_color);
+        write_pretty(out, "ignored", term::color::YELLOW, use_color);
     }
 
     fn write_bench(out: @io::Writer, use_color: bool) {
-        write_pretty(out, "bench", term::color::cyan, use_color);
+        write_pretty(out, "bench", term::color::CYAN, use_color);
     }
 
     fn write_pretty(out: @io::Writer,
@@ -487,16 +487,16 @@ fn run_tests(opts: &TestOpts,
 
 // Windows tends to dislike being overloaded with threads.
 #[cfg(windows)]
-static sched_overcommit : uint = 1;
+static SCHED_OVERCOMMIT : uint = 1;
 
 #[cfg(unix)]
-static sched_overcommit : uint = 4u;
+static SCHED_OVERCOMMIT : uint = 4u;
 
 fn get_concurrency() -> uint {
     unsafe {
         let threads = rustrt::rust_sched_threads() as uint;
         if threads == 1 { 1 }
-        else { threads * sched_overcommit }
+        else { threads * SCHED_OVERCOMMIT }
     }
 }
 
diff --git a/src/libextra/time.rs b/src/libextra/time.rs
index e1f42934b39..a64b2374328 100644
--- a/src/libextra/time.rs
+++ b/src/libextra/time.rs
@@ -868,20 +868,20 @@ mod tests {
     use std::str;
 
     fn test_get_time() {
-        static some_recent_date: i64 = 1325376000i64; // 2012-01-01T00:00:00Z
-        static some_future_date: i64 = 1577836800i64; // 2020-01-01T00:00:00Z
+        static SOME_RECENT_DATE: i64 = 1325376000i64; // 2012-01-01T00:00:00Z
+        static SOME_FUTURE_DATE: i64 = 1577836800i64; // 2020-01-01T00:00:00Z
 
         let tv1 = get_time();
         debug!("tv1=%? sec + %? nsec", tv1.sec as uint, tv1.nsec as uint);
 
-        assert!(tv1.sec > some_recent_date);
+        assert!(tv1.sec > SOME_RECENT_DATE);
         assert!(tv1.nsec < 1000000000i32);
 
         let tv2 = get_time();
         debug!("tv2=%? sec + %? nsec", tv2.sec as uint, tv2.nsec as uint);
 
         assert!(tv2.sec >= tv1.sec);
-        assert!(tv2.sec < some_future_date);
+        assert!(tv2.sec < SOME_FUTURE_DATE);
         assert!(tv2.nsec < 1000000000i32);
         if tv2.sec == tv1.sec {
             assert!(tv2.nsec >= tv1.nsec);