about summary refs log tree commit diff
path: root/src/libstd
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/libstd
parent6caaa34dedc45543e4d2c7600f952e042d9258df (diff)
parentc437a16c5d8c00b39dc6c5e36011def997d77224 (diff)
downloadrust-55f155521d2f604794d2ab1de2a8d439440af4a8.tar.gz
rust-55f155521d2f604794d2ab1de2a8d439440af4a8.zip
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/libstd')
-rw-r--r--src/libstd/gc.rs1
-rw-r--r--src/libstd/libc.rs1
-rw-r--r--src/libstd/num/cmath.rs1
-rw-r--r--src/libstd/num/f32.rs1
-rw-r--r--src/libstd/num/f64.rs1
-rw-r--r--src/libstd/num/float.rs1
-rw-r--r--src/libstd/num/int.rs2
-rw-r--r--src/libstd/num/int_macros.rs2
-rw-r--r--src/libstd/num/strconv.rs14
-rw-r--r--src/libstd/num/uint_macros.rs2
-rw-r--r--src/libstd/rand.rs10
-rw-r--r--src/libstd/str.rs80
-rw-r--r--src/libstd/unicode.rs1
-rw-r--r--src/libstd/unstable/extfmt.rs1
-rw-r--r--src/libstd/unstable/lang.rs8
15 files changed, 70 insertions, 56 deletions
diff --git a/src/libstd/gc.rs b/src/libstd/gc.rs
index c9e33219fa5..f92561edcb0 100644
--- a/src/libstd/gc.rs
+++ b/src/libstd/gc.rs
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 #[doc(hidden)];
+#[allow(non_uppercase_statics)];
 
 /*! Precise garbage collector
 
diff --git a/src/libstd/libc.rs b/src/libstd/libc.rs
index f4ea29b5c05..14e719bc8dd 100644
--- a/src/libstd/libc.rs
+++ b/src/libstd/libc.rs
@@ -64,6 +64,7 @@
 */
 
 #[allow(non_camel_case_types)];
+#[allow(non_uppercase_statics)];
 #[allow(missing_doc)];
 
 // Initial glob-exports mean that all the contents of all the modules
diff --git a/src/libstd/num/cmath.rs b/src/libstd/num/cmath.rs
index 96d3b79e338..c89fc73693c 100644
--- a/src/libstd/num/cmath.rs
+++ b/src/libstd/num/cmath.rs
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 #[allow(missing_doc)];
+#[allow(non_uppercase_statics)];
 
 // function names are almost identical to C's libmath, a few have been
 // renamed, grep for "rename:"
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs
index 0b6eb766b29..a84c27cd918 100644
--- a/src/libstd/num/f32.rs
+++ b/src/libstd/num/f32.rs
@@ -10,6 +10,7 @@
 
 //! Operations and constants for `f32`
 #[allow(missing_doc)];
+#[allow(non_uppercase_statics)];
 
 use libc::c_int;
 use num::{Zero, One, strconv};
diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs
index c39c7a3a57d..216963e0414 100644
--- a/src/libstd/num/f64.rs
+++ b/src/libstd/num/f64.rs
@@ -11,6 +11,7 @@
 //! Operations and constants for `f64`
 
 #[allow(missing_doc)];
+#[allow(non_uppercase_statics)];
 
 use libc::c_int;
 use num::{Zero, One, strconv};
diff --git a/src/libstd/num/float.rs b/src/libstd/num/float.rs
index 7a6e3042e7b..d73ff16c6f7 100644
--- a/src/libstd/num/float.rs
+++ b/src/libstd/num/float.rs
@@ -21,6 +21,7 @@
 // PORT this must match in width according to architecture
 
 #[allow(missing_doc)];
+#[allow(non_uppercase_statics)];
 
 use f64;
 use libc::c_int;
diff --git a/src/libstd/num/int.rs b/src/libstd/num/int.rs
index d3c2733b47d..d39b4b2b911 100644
--- a/src/libstd/num/int.rs
+++ b/src/libstd/num/int.rs
@@ -10,6 +10,8 @@
 
 //! Operations and constants for `int`
 
+#[allow(non_uppercase_statics)];
+
 use num::BitCount;
 
 pub use self::generated::*;
diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs
index f152d60cb7a..c2eebf9a3e4 100644
--- a/src/libstd/num/int_macros.rs
+++ b/src/libstd/num/int_macros.rs
@@ -14,6 +14,8 @@
 
 macro_rules! int_module (($T:ty, $bits:expr) => (mod generated {
 
+#[allow(non_uppercase_statics)];
+
 use num::{ToStrRadix, FromStrRadix};
 use num::{Zero, One, strconv};
 use prelude::*;
diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs
index f6dff4267b7..337d804ce73 100644
--- a/src/libstd/num/strconv.rs
+++ b/src/libstd/num/strconv.rs
@@ -101,12 +101,12 @@ impl_NumStrConv_Integer!(u64)
 
 
 // Special value strings as [u8] consts.
-static inf_buf:          [u8, ..3] = ['i' as u8, 'n' as u8, 'f' as u8];
-static positive_inf_buf: [u8, ..4] = ['+' as u8, 'i' as u8, 'n' as u8,
+static INF_BUF:          [u8, ..3] = ['i' as u8, 'n' as u8, 'f' as u8];
+static POS_INF_BUF: [u8, ..4] = ['+' as u8, 'i' as u8, 'n' as u8,
                                       'f' as u8];
-static negative_inf_buf: [u8, ..4] = ['-' as u8, 'i' as u8, 'n' as u8,
+static NEG_INF_BUF: [u8, ..4] = ['-' as u8, 'i' as u8, 'n' as u8,
                                       'f' as u8];
-static nan_buf:          [u8, ..3] = ['N' as u8, 'a' as u8, 'N' as u8];
+static NAN_BUF:          [u8, ..3] = ['N' as u8, 'a' as u8, 'N' as u8];
 
 /**
  * Converts an integral number to its string representation as a byte vector.
@@ -506,15 +506,15 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
     }
 
     if special {
-        if buf == inf_buf || buf == positive_inf_buf {
+        if buf == INF_BUF || buf == POS_INF_BUF {
             return NumStrConv::inf();
-        } else if buf == negative_inf_buf {
+        } else if buf == NEG_INF_BUF {
             if negative {
                 return NumStrConv::neg_inf();
             } else {
                 return None;
             }
-        } else if buf == nan_buf {
+        } else if buf == NAN_BUF {
             return NumStrConv::NaN();
         }
     }
diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs
index 25e338fcd0f..d185b2a05a8 100644
--- a/src/libstd/num/uint_macros.rs
+++ b/src/libstd/num/uint_macros.rs
@@ -14,6 +14,8 @@
 
 macro_rules! uint_module (($T:ty, $T_SIGNED:ty, $bits:expr) => (mod generated {
 
+#[allow(non_uppercase_statics)];
+
 use num::BitCount;
 use num::{ToStrRadix, FromStrRadix};
 use num::{Zero, One, strconv};
diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs
index 5f96e38a55a..5782822bc2b 100644
--- a/src/libstd/rand.rs
+++ b/src/libstd/rand.rs
@@ -157,7 +157,7 @@ impl Rand for f32 {
     }
 }
 
-static scale : f64 = (u32::max_value as f64) + 1.0f64;
+static SCALE : f64 = (u32::max_value as f64) + 1.0f64;
 impl Rand for f64 {
     #[inline]
     fn rand<R: Rng>(rng: &mut R) -> f64 {
@@ -165,7 +165,7 @@ impl Rand for f64 {
         let u2 = rng.next() as f64;
         let u3 = rng.next() as f64;
 
-        ((u1 / scale + u2) / scale + u3) / scale
+        ((u1 / SCALE + u2) / SCALE + u3) / SCALE
     }
 }
 
@@ -724,7 +724,7 @@ impl IsaacRng {
         let mut a = self.a;
         let mut b = self.b + self.c;
 
-        static midpoint: uint = RAND_SIZE as uint / 2;
+        static MIDPOINT: uint = RAND_SIZE as uint / 2;
 
         macro_rules! ind (($x:expr) => {
             self.mem[($x >> 2) & (RAND_SIZE - 1)]
@@ -748,9 +748,9 @@ impl IsaacRng {
             }}
         );
 
-        let r = [(0, midpoint), (midpoint, 0)];
+        let r = [(0, MIDPOINT), (MIDPOINT, 0)];
         for r.iter().advance |&(mr_offset, m2_offset)| {
-            for uint::range_step(0, midpoint, 4) |base| {
+            for uint::range_step(0, MIDPOINT, 4) |base| {
                 rngstep!(0, 13);
                 rngstep!(1, -6);
                 rngstep!(2, 2);
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index 4115cad6559..28162cf5117 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -602,7 +602,7 @@ pub fn is_utf8(v: &[u8]) -> bool {
         if i + chsize > total { return false; }
         i += 1u;
         while chsize > 1u {
-            if v[i] & 192u8 != tag_cont_u8 { return false; }
+            if v[i] & 192u8 != TAG_CONT_U8 { return false; }
             i += 1u;
             chsize -= 1u;
         }
@@ -743,18 +743,18 @@ pub struct CharRange {
 }
 
 // UTF-8 tags and ranges
-static tag_cont_u8: u8 = 128u8;
-static tag_cont: uint = 128u;
-static max_one_b: uint = 128u;
-static tag_two_b: uint = 192u;
-static max_two_b: uint = 2048u;
-static tag_three_b: uint = 224u;
-static max_three_b: uint = 65536u;
-static tag_four_b: uint = 240u;
-static max_four_b: uint = 2097152u;
-static tag_five_b: uint = 248u;
-static max_five_b: uint = 67108864u;
-static tag_six_b: uint = 252u;
+static TAG_CONT_U8: u8 = 128u8;
+static TAG_CONT: uint = 128u;
+static MAX_ONE_B: uint = 128u;
+static TAG_TWO_B: uint = 192u;
+static MAX_TWO_B: uint = 2048u;
+static TAG_THREE_B: uint = 224u;
+static MAX_THREE_B: uint = 65536u;
+static TAG_FOUR_B: uint = 240u;
+static MAX_FOUR_B: uint = 2097152u;
+static TAG_FIVE_B: uint = 248u;
+static MAX_FIVE_B: uint = 67108864u;
+static TAG_SIX_B: uint = 252u;
 
 /**
  * A dummy trait to hold all the utility methods that we implement on strings.
@@ -1728,7 +1728,7 @@ impl<'self> StrSlice<'self> for &'self str {
         let mut i = i + 1u;
         while i < end {
             let byte = self[i];
-            assert_eq!(byte & 192u8, tag_cont_u8);
+            assert_eq!(byte & 192u8, TAG_CONT_U8);
             val <<= 6u;
             val += (byte & 63u8) as uint;
             i += 1u;
@@ -1755,7 +1755,7 @@ impl<'self> StrSlice<'self> for &'self str {
         let mut prev = start;
 
         // while there is a previous byte == 10......
-        while prev > 0u && self[prev - 1u] & 192u8 == tag_cont_u8 {
+        while prev > 0u && self[prev - 1u] & 192u8 == TAG_CONT_U8 {
             prev -= 1u;
         }
 
@@ -2071,11 +2071,11 @@ impl OwnedStr for ~str {
     fn push_char(&mut self, c: char) {
         unsafe {
             let code = c as uint;
-            let nb = if code < max_one_b { 1u }
-            else if code < max_two_b { 2u }
-            else if code < max_three_b { 3u }
-            else if code < max_four_b { 4u }
-            else if code < max_five_b { 5u }
+            let nb = if code < MAX_ONE_B { 1u }
+            else if code < MAX_TWO_B { 2u }
+            else if code < MAX_THREE_B { 3u }
+            else if code < MAX_FOUR_B { 4u }
+            else if code < MAX_FIVE_B { 5u }
             else { 6u };
             let len = self.len();
             let new_len = len + nb;
@@ -2088,34 +2088,34 @@ impl OwnedStr for ~str {
                         *ptr::mut_offset(buf, off) = code as u8;
                     }
                     2u => {
-                        *ptr::mut_offset(buf, off) = (code >> 6u & 31u | tag_two_b) as u8;
-                        *ptr::mut_offset(buf, off + 1u) = (code & 63u | tag_cont) as u8;
+                        *ptr::mut_offset(buf, off) = (code >> 6u & 31u | TAG_TWO_B) as u8;
+                        *ptr::mut_offset(buf, off + 1u) = (code & 63u | TAG_CONT) as u8;
                     }
                     3u => {
-                        *ptr::mut_offset(buf, off) = (code >> 12u & 15u | tag_three_b) as u8;
-                        *ptr::mut_offset(buf, off + 1u) = (code >> 6u & 63u | tag_cont) as u8;
-                        *ptr::mut_offset(buf, off + 2u) = (code & 63u | tag_cont) as u8;
+                        *ptr::mut_offset(buf, off) = (code >> 12u & 15u | TAG_THREE_B) as u8;
+                        *ptr::mut_offset(buf, off + 1u) = (code >> 6u & 63u | TAG_CONT) as u8;
+                        *ptr::mut_offset(buf, off + 2u) = (code & 63u | TAG_CONT) as u8;
                     }
                     4u => {
-                        *ptr::mut_offset(buf, off) = (code >> 18u & 7u | tag_four_b) as u8;
-                        *ptr::mut_offset(buf, off + 1u) = (code >> 12u & 63u | tag_cont) as u8;
-                        *ptr::mut_offset(buf, off + 2u) = (code >> 6u & 63u | tag_cont) as u8;
-                        *ptr::mut_offset(buf, off + 3u) = (code & 63u | tag_cont) as u8;
+                        *ptr::mut_offset(buf, off) = (code >> 18u & 7u | TAG_FOUR_B) as u8;
+                        *ptr::mut_offset(buf, off + 1u) = (code >> 12u & 63u | TAG_CONT) as u8;
+                        *ptr::mut_offset(buf, off + 2u) = (code >> 6u & 63u | TAG_CONT) as u8;
+                        *ptr::mut_offset(buf, off + 3u) = (code & 63u | TAG_CONT) as u8;
                     }
                     5u => {
-                        *ptr::mut_offset(buf, off) = (code >> 24u & 3u | tag_five_b) as u8;
-                        *ptr::mut_offset(buf, off + 1u) = (code >> 18u & 63u | tag_cont) as u8;
-                        *ptr::mut_offset(buf, off + 2u) = (code >> 12u & 63u | tag_cont) as u8;
-                        *ptr::mut_offset(buf, off + 3u) = (code >> 6u & 63u | tag_cont) as u8;
-                        *ptr::mut_offset(buf, off + 4u) = (code & 63u | tag_cont) as u8;
+                        *ptr::mut_offset(buf, off) = (code >> 24u & 3u | TAG_FIVE_B) as u8;
+                        *ptr::mut_offset(buf, off + 1u) = (code >> 18u & 63u | TAG_CONT) as u8;
+                        *ptr::mut_offset(buf, off + 2u) = (code >> 12u & 63u | TAG_CONT) as u8;
+                        *ptr::mut_offset(buf, off + 3u) = (code >> 6u & 63u | TAG_CONT) as u8;
+                        *ptr::mut_offset(buf, off + 4u) = (code & 63u | TAG_CONT) as u8;
                     }
                     6u => {
-                        *ptr::mut_offset(buf, off) = (code >> 30u & 1u | tag_six_b) as u8;
-                        *ptr::mut_offset(buf, off + 1u) = (code >> 24u & 63u | tag_cont) as u8;
-                        *ptr::mut_offset(buf, off + 2u) = (code >> 18u & 63u | tag_cont) as u8;
-                        *ptr::mut_offset(buf, off + 3u) = (code >> 12u & 63u | tag_cont) as u8;
-                        *ptr::mut_offset(buf, off + 4u) = (code >> 6u & 63u | tag_cont) as u8;
-                        *ptr::mut_offset(buf, off + 5u) = (code & 63u | tag_cont) as u8;
+                        *ptr::mut_offset(buf, off) = (code >> 30u & 1u | TAG_SIX_B) as u8;
+                        *ptr::mut_offset(buf, off + 1u) = (code >> 24u & 63u | TAG_CONT) as u8;
+                        *ptr::mut_offset(buf, off + 2u) = (code >> 18u & 63u | TAG_CONT) as u8;
+                        *ptr::mut_offset(buf, off + 3u) = (code >> 12u & 63u | TAG_CONT) as u8;
+                        *ptr::mut_offset(buf, off + 4u) = (code >> 6u & 63u | TAG_CONT) as u8;
+                        *ptr::mut_offset(buf, off + 5u) = (code & 63u | TAG_CONT) as u8;
                     }
                     _ => {}
                 }
diff --git a/src/libstd/unicode.rs b/src/libstd/unicode.rs
index 1e2d5c76fea..460c0a847c8 100644
--- a/src/libstd/unicode.rs
+++ b/src/libstd/unicode.rs
@@ -11,6 +11,7 @@
 // The following code was generated by "src/etc/unicode.py"
 
 #[allow(missing_doc)];
+#[allow(non_uppercase_statics)];
 
 pub mod general_category {
 
diff --git a/src/libstd/unstable/extfmt.rs b/src/libstd/unstable/extfmt.rs
index 624062a7ec4..b1df5175c92 100644
--- a/src/libstd/unstable/extfmt.rs
+++ b/src/libstd/unstable/extfmt.rs
@@ -472,6 +472,7 @@ pub mod ct {
 // conditions can be evaluated at compile-time. For now though it's cleaner to
 // implement it this way, I think.
 #[doc(hidden)]
+#[allow(non_uppercase_statics)]
 pub mod rt {
     use float;
     use str;
diff --git a/src/libstd/unstable/lang.rs b/src/libstd/unstable/lang.rs
index fddd847af34..94617b4e49f 100644
--- a/src/libstd/unstable/lang.rs
+++ b/src/libstd/unstable/lang.rs
@@ -197,15 +197,15 @@ impl DebugPrints for io::fd_t {
     fn write_hex(&self, mut i: uint) {
         let letters = ['0', '1', '2', '3', '4', '5', '6', '7', '8',
                        '9', 'a', 'b', 'c', 'd', 'e', 'f'];
-        static uint_nibbles: uint = ::uint::bytes << 1;
-        let mut buffer = [0_u8, ..uint_nibbles+1];
-        let mut c = uint_nibbles;
+        static UINT_NIBBLES: uint = ::uint::bytes << 1;
+        let mut buffer = [0_u8, ..UINT_NIBBLES+1];
+        let mut c = UINT_NIBBLES;
         while c > 0 {
             c -= 1;
             buffer[c] = letters[i & 0xF] as u8;
             i >>= 4;
         }
-        self.write(buffer.slice(0, uint_nibbles));
+        self.write(buffer.slice(0, UINT_NIBBLES));
     }
 
     unsafe fn write_cstr(&self, p: *c_char) {