diff options
| author | P1start <rewi-github@whanau.org> | 2014-09-13 13:55:37 +1200 |
|---|---|---|
| committer | P1start <rewi-github@whanau.org> | 2014-10-03 20:39:56 +1300 |
| commit | 94bcd3539c761b4ecf423800bce21057c4e961fa (patch) | |
| tree | 51c0030bfc0a527ce57da49f0987f726ea0ed912 /src/librustrt | |
| parent | aa034cd3bac3155e0f6c74c399314b5ee32f88fc (diff) | |
| download | rust-94bcd3539c761b4ecf423800bce21057c4e961fa.tar.gz rust-94bcd3539c761b4ecf423800bce21057c4e961fa.zip | |
Set the `non_uppercase_statics` lint to warn by default
Diffstat (limited to 'src/librustrt')
| -rw-r--r-- | src/librustrt/c_str.rs | 30 | ||||
| -rw-r--r-- | src/librustrt/libunwind.rs | 1 | ||||
| -rw-r--r-- | src/librustrt/local_data.rs | 214 | ||||
| -rw-r--r-- | src/librustrt/mutex.rs | 8 | ||||
| -rw-r--r-- | src/librustrt/util.rs | 2 |
5 files changed, 129 insertions, 126 deletions
diff --git a/src/librustrt/c_str.rs b/src/librustrt/c_str.rs index 04a4e96ecc4..934fb0ddd3c 100644 --- a/src/librustrt/c_str.rs +++ b/src/librustrt/c_str.rs @@ -733,9 +733,9 @@ mod bench { } } - static s_short: &'static str = "Mary"; - static s_medium: &'static str = "Mary had a little lamb"; - static s_long: &'static str = "\ + static S_SHORT: &'static str = "Mary"; + static S_MEDIUM: &'static str = "Mary had a little lamb"; + static S_LONG: &'static str = "\ Mary had a little lamb, Little lamb Mary had a little lamb, Little lamb Mary had a little lamb, Little lamb @@ -752,17 +752,17 @@ mod bench { #[bench] fn bench_to_c_str_short(b: &mut Bencher) { - bench_to_string(b, s_short) + bench_to_string(b, S_SHORT) } #[bench] fn bench_to_c_str_medium(b: &mut Bencher) { - bench_to_string(b, s_medium) + bench_to_string(b, S_MEDIUM) } #[bench] fn bench_to_c_str_long(b: &mut Bencher) { - bench_to_string(b, s_long) + bench_to_string(b, S_LONG) } fn bench_to_c_str_unchecked(b: &mut Bencher, s: &str) { @@ -774,17 +774,17 @@ mod bench { #[bench] fn bench_to_c_str_unchecked_short(b: &mut Bencher) { - bench_to_c_str_unchecked(b, s_short) + bench_to_c_str_unchecked(b, S_SHORT) } #[bench] fn bench_to_c_str_unchecked_medium(b: &mut Bencher) { - bench_to_c_str_unchecked(b, s_medium) + bench_to_c_str_unchecked(b, S_MEDIUM) } #[bench] fn bench_to_c_str_unchecked_long(b: &mut Bencher) { - bench_to_c_str_unchecked(b, s_long) + bench_to_c_str_unchecked(b, S_LONG) } fn bench_with_c_str(b: &mut Bencher, s: &str) { @@ -795,17 +795,17 @@ mod bench { #[bench] fn bench_with_c_str_short(b: &mut Bencher) { - bench_with_c_str(b, s_short) + bench_with_c_str(b, S_SHORT) } #[bench] fn bench_with_c_str_medium(b: &mut Bencher) { - bench_with_c_str(b, s_medium) + bench_with_c_str(b, S_MEDIUM) } #[bench] fn bench_with_c_str_long(b: &mut Bencher) { - bench_with_c_str(b, s_long) + bench_with_c_str(b, S_LONG) } fn bench_with_c_str_unchecked(b: &mut Bencher, s: &str) { @@ -818,16 +818,16 @@ mod bench { #[bench] fn bench_with_c_str_unchecked_short(b: &mut Bencher) { - bench_with_c_str_unchecked(b, s_short) + bench_with_c_str_unchecked(b, S_SHORT) } #[bench] fn bench_with_c_str_unchecked_medium(b: &mut Bencher) { - bench_with_c_str_unchecked(b, s_medium) + bench_with_c_str_unchecked(b, S_MEDIUM) } #[bench] fn bench_with_c_str_unchecked_long(b: &mut Bencher) { - bench_with_c_str_unchecked(b, s_long) + bench_with_c_str_unchecked(b, S_LONG) } } diff --git a/src/librustrt/libunwind.rs b/src/librustrt/libunwind.rs index 2e7408d9159..bb7a1227e0e 100644 --- a/src/librustrt/libunwind.rs +++ b/src/librustrt/libunwind.rs @@ -10,6 +10,7 @@ //! Unwind library interface +#![allow(non_uppercase_statics)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(dead_code)] // these are just bindings diff --git a/src/librustrt/local_data.rs b/src/librustrt/local_data.rs index fcef5981f0a..8d5c49d767f 100644 --- a/src/librustrt/local_data.rs +++ b/src/librustrt/local_data.rs @@ -416,37 +416,37 @@ mod tests { #[test] fn test_tls_multitask() { - static my_key: Key<String> = &KeyValueKey; - my_key.replace(Some("parent data".to_string())); + static MY_KEY: Key<String> = &KeyValueKey; + MY_KEY.replace(Some("parent data".to_string())); task::spawn(proc() { // TLD shouldn't carry over. - assert!(my_key.get().is_none()); - my_key.replace(Some("child data".to_string())); - assert!(my_key.get().as_ref().unwrap().as_slice() == "child data"); + assert!(MY_KEY.get().is_none()); + MY_KEY.replace(Some("child data".to_string())); + assert!(MY_KEY.get().as_ref().unwrap().as_slice() == "child data"); // should be cleaned up for us }); // Must work multiple times - assert!(my_key.get().unwrap().as_slice() == "parent data"); - assert!(my_key.get().unwrap().as_slice() == "parent data"); - assert!(my_key.get().unwrap().as_slice() == "parent data"); + assert!(MY_KEY.get().unwrap().as_slice() == "parent data"); + assert!(MY_KEY.get().unwrap().as_slice() == "parent data"); + assert!(MY_KEY.get().unwrap().as_slice() == "parent data"); } #[test] fn test_tls_overwrite() { - static my_key: Key<String> = &KeyValueKey; - my_key.replace(Some("first data".to_string())); - my_key.replace(Some("next data".to_string())); // Shouldn't leak. - assert!(my_key.get().unwrap().as_slice() == "next data"); + static MY_KEY: Key<String> = &KeyValueKey; + MY_KEY.replace(Some("first data".to_string())); + MY_KEY.replace(Some("next data".to_string())); // Shouldn't leak. + assert!(MY_KEY.get().unwrap().as_slice() == "next data"); } #[test] fn test_tls_pop() { - static my_key: Key<String> = &KeyValueKey; - my_key.replace(Some("weasel".to_string())); - assert!(my_key.replace(None).unwrap() == "weasel".to_string()); + static MY_KEY: Key<String> = &KeyValueKey; + MY_KEY.replace(Some("weasel".to_string())); + assert!(MY_KEY.replace(None).unwrap() == "weasel".to_string()); // Pop must remove the data from the map. - assert!(my_key.replace(None).is_none()); + assert!(MY_KEY.replace(None).is_none()); } #[test] @@ -457,58 +457,58 @@ mod tests { // to get recorded as something within a rust stack segment. Then a // subsequent upcall (esp. for logging, think vsnprintf) would run on // a stack smaller than 1 MB. - static my_key: Key<String> = &KeyValueKey; + static MY_KEY: Key<String> = &KeyValueKey; task::spawn(proc() { - my_key.replace(Some("hax".to_string())); + MY_KEY.replace(Some("hax".to_string())); }); } #[test] fn test_tls_multiple_types() { - static str_key: Key<String> = &KeyValueKey; - static box_key: Key<Box<int>> = &KeyValueKey; - static int_key: Key<int> = &KeyValueKey; + static STR_KEY: Key<String> = &KeyValueKey; + static BOX_KEY: Key<Box<int>> = &KeyValueKey; + static INT_KEY: Key<int> = &KeyValueKey; task::spawn(proc() { - str_key.replace(Some("string data".to_string())); - box_key.replace(Some(box 0)); - int_key.replace(Some(42)); + STR_KEY.replace(Some("string data".to_string())); + BOX_KEY.replace(Some(box 0)); + INT_KEY.replace(Some(42)); }); } #[test] fn test_tls_overwrite_multiple_types() { - static str_key: Key<String> = &KeyValueKey; - static box_key: Key<Box<int>> = &KeyValueKey; - static int_key: Key<int> = &KeyValueKey; + static STR_KEY: Key<String> = &KeyValueKey; + static BOX_KEY: Key<Box<int>> = &KeyValueKey; + static INT_KEY: Key<int> = &KeyValueKey; task::spawn(proc() { - str_key.replace(Some("string data".to_string())); - str_key.replace(Some("string data 2".to_string())); - box_key.replace(Some(box 0)); - box_key.replace(Some(box 1)); - int_key.replace(Some(42)); + STR_KEY.replace(Some("string data".to_string())); + STR_KEY.replace(Some("string data 2".to_string())); + BOX_KEY.replace(Some(box 0)); + BOX_KEY.replace(Some(box 1)); + INT_KEY.replace(Some(42)); // This could cause a segfault if overwriting-destruction is done // with the crazy polymorphic transmute rather than the provided // finaliser. - int_key.replace(Some(31337)); + INT_KEY.replace(Some(31337)); }); } #[test] #[should_fail] fn test_tls_cleanup_on_failure() { - static str_key: Key<String> = &KeyValueKey; - static box_key: Key<Box<int>> = &KeyValueKey; - static int_key: Key<int> = &KeyValueKey; - str_key.replace(Some("parent data".to_string())); - box_key.replace(Some(box 0)); + static STR_KEY: Key<String> = &KeyValueKey; + static BOX_KEY: Key<Box<int>> = &KeyValueKey; + static INT_KEY: Key<int> = &KeyValueKey; + STR_KEY.replace(Some("parent data".to_string())); + BOX_KEY.replace(Some(box 0)); task::spawn(proc() { - str_key.replace(Some("string data".to_string())); - box_key.replace(Some(box 2)); - int_key.replace(Some(42)); + STR_KEY.replace(Some("string data".to_string())); + BOX_KEY.replace(Some(box 2)); + INT_KEY.replace(Some(42)); fail!(); }); // Not quite nondeterministic. - int_key.replace(Some(31337)); + INT_KEY.replace(Some(31337)); fail!(); } @@ -523,9 +523,9 @@ mod tests { self.tx.send(()); } } - static key: Key<Dropper> = &KeyValueKey; + static KEY: Key<Dropper> = &KeyValueKey; let _ = task::try(proc() { - key.replace(Some(Dropper{ tx: tx })); + KEY.replace(Some(Dropper{ tx: tx })); }); // At this point the task has been cleaned up and the TLD dropped. // If the channel doesn't have a value now, then the Sender was leaked. @@ -534,56 +534,56 @@ mod tests { #[test] fn test_static_pointer() { - static key: Key<&'static int> = &KeyValueKey; + static KEY: Key<&'static int> = &KeyValueKey; static VALUE: int = 0; - key.replace(Some(&VALUE)); + KEY.replace(Some(&VALUE)); } #[test] fn test_owned() { - static key: Key<Box<int>> = &KeyValueKey; - key.replace(Some(box 1)); + static KEY: Key<Box<int>> = &KeyValueKey; + KEY.replace(Some(box 1)); { - let k1 = key.get().unwrap(); - let k2 = key.get().unwrap(); - let k3 = key.get().unwrap(); + let k1 = KEY.get().unwrap(); + let k2 = KEY.get().unwrap(); + let k3 = KEY.get().unwrap(); assert_eq!(**k1, 1); assert_eq!(**k2, 1); assert_eq!(**k3, 1); } - key.replace(Some(box 2)); - assert_eq!(**key.get().unwrap(), 2); + KEY.replace(Some(box 2)); + assert_eq!(**KEY.get().unwrap(), 2); } #[test] fn test_same_key_type() { - static key1: Key<int> = &KeyValueKey; - static key2: Key<int> = &KeyValueKey; - static key3: Key<int> = &KeyValueKey; - static key4: Key<int> = &KeyValueKey; - static key5: Key<int> = &KeyValueKey; - key1.replace(Some(1)); - key2.replace(Some(2)); - key3.replace(Some(3)); - key4.replace(Some(4)); - key5.replace(Some(5)); - - assert_eq!(*key1.get().unwrap(), 1); - assert_eq!(*key2.get().unwrap(), 2); - assert_eq!(*key3.get().unwrap(), 3); - assert_eq!(*key4.get().unwrap(), 4); - assert_eq!(*key5.get().unwrap(), 5); + static KEY1: Key<int> = &KeyValueKey; + static KEY2: Key<int> = &KeyValueKey; + static KEY3: Key<int> = &KeyValueKey; + static KEY4: Key<int> = &KeyValueKey; + static KEY5: Key<int> = &KeyValueKey; + KEY1.replace(Some(1)); + KEY2.replace(Some(2)); + KEY3.replace(Some(3)); + KEY4.replace(Some(4)); + KEY5.replace(Some(5)); + + assert_eq!(*KEY1.get().unwrap(), 1); + assert_eq!(*KEY2.get().unwrap(), 2); + assert_eq!(*KEY3.get().unwrap(), 3); + assert_eq!(*KEY4.get().unwrap(), 4); + assert_eq!(*KEY5.get().unwrap(), 5); } #[test] #[should_fail] fn test_nested_get_set1() { - static key: Key<int> = &KeyValueKey; - assert_eq!(key.replace(Some(4)), None); + static KEY: Key<int> = &KeyValueKey; + assert_eq!(KEY.replace(Some(4)), None); - let _k = key.get(); - key.replace(Some(4)); + let _k = KEY.get(); + KEY.replace(Some(4)); } // ClearKey is a RAII class that ensures the keys are cleared from the map. @@ -601,95 +601,95 @@ mod tests { #[bench] fn bench_replace_none(b: &mut test::Bencher) { - static key: Key<uint> = &KeyValueKey; - let _clear = ClearKey(key); - key.replace(None); + static KEY: Key<uint> = &KeyValueKey; + let _clear = ClearKey(KEY); + KEY.replace(None); b.iter(|| { - key.replace(None) + KEY.replace(None) }); } #[bench] fn bench_replace_some(b: &mut test::Bencher) { - static key: Key<uint> = &KeyValueKey; - let _clear = ClearKey(key); - key.replace(Some(1u)); + static KEY: Key<uint> = &KeyValueKey; + let _clear = ClearKey(KEY); + KEY.replace(Some(1u)); b.iter(|| { - key.replace(Some(2)) + KEY.replace(Some(2)) }); } #[bench] fn bench_replace_none_some(b: &mut test::Bencher) { - static key: Key<uint> = &KeyValueKey; - let _clear = ClearKey(key); - key.replace(Some(0u)); + static KEY: Key<uint> = &KeyValueKey; + let _clear = ClearKey(KEY); + KEY.replace(Some(0u)); b.iter(|| { - let old = key.replace(None).unwrap(); + let old = KEY.replace(None).unwrap(); let new = old + 1; - key.replace(Some(new)) + KEY.replace(Some(new)) }); } #[bench] fn bench_100_keys_replace_last(b: &mut test::Bencher) { - static keys: [KeyValue<uint>, ..100] = [KeyValueKey, ..100]; - let _clear = keys.iter().map(ClearKey).collect::<Vec<ClearKey<uint>>>(); - for (i, key) in keys.iter().enumerate() { + static KEYS: [KeyValue<uint>, ..100] = [KeyValueKey, ..100]; + let _clear = KEYS.iter().map(ClearKey).collect::<Vec<ClearKey<uint>>>(); + for (i, key) in KEYS.iter().enumerate() { key.replace(Some(i)); } b.iter(|| { - let key: Key<uint> = &keys[99]; + let key: Key<uint> = &KEYS[99]; key.replace(Some(42)) }); } #[bench] fn bench_1000_keys_replace_last(b: &mut test::Bencher) { - static keys: [KeyValue<uint>, ..1000] = [KeyValueKey, ..1000]; - let _clear = keys.iter().map(ClearKey).collect::<Vec<ClearKey<uint>>>(); - for (i, key) in keys.iter().enumerate() { + static KEYS: [KeyValue<uint>, ..1000] = [KeyValueKey, ..1000]; + let _clear = KEYS.iter().map(ClearKey).collect::<Vec<ClearKey<uint>>>(); + for (i, key) in KEYS.iter().enumerate() { key.replace(Some(i)); } b.iter(|| { - let key: Key<uint> = &keys[999]; + let key: Key<uint> = &KEYS[999]; key.replace(Some(42)) }); - for key in keys.iter() { key.clear(); } + for key in KEYS.iter() { key.clear(); } } #[bench] fn bench_get(b: &mut test::Bencher) { - static key: Key<uint> = &KeyValueKey; - let _clear = ClearKey(key); - key.replace(Some(42)); + static KEY: Key<uint> = &KeyValueKey; + let _clear = ClearKey(KEY); + KEY.replace(Some(42)); b.iter(|| { - key.get() + KEY.get() }); } #[bench] fn bench_100_keys_get_last(b: &mut test::Bencher) { - static keys: [KeyValue<uint>, ..100] = [KeyValueKey, ..100]; - let _clear = keys.iter().map(ClearKey).collect::<Vec<ClearKey<uint>>>(); - for (i, key) in keys.iter().enumerate() { + static KEYS: [KeyValue<uint>, ..100] = [KeyValueKey, ..100]; + let _clear = KEYS.iter().map(ClearKey).collect::<Vec<ClearKey<uint>>>(); + for (i, key) in KEYS.iter().enumerate() { key.replace(Some(i)); } b.iter(|| { - let key: Key<uint> = &keys[99]; + let key: Key<uint> = &KEYS[99]; key.get() }); } #[bench] fn bench_1000_keys_get_last(b: &mut test::Bencher) { - static keys: [KeyValue<uint>, ..1000] = [KeyValueKey, ..1000]; - let _clear = keys.iter().map(ClearKey).collect::<Vec<ClearKey<uint>>>(); - for (i, key) in keys.iter().enumerate() { + static KEYS: [KeyValue<uint>, ..1000] = [KeyValueKey, ..1000]; + let _clear = KEYS.iter().map(ClearKey).collect::<Vec<ClearKey<uint>>>(); + for (i, key) in KEYS.iter().enumerate() { key.replace(Some(i)); } b.iter(|| { - let key: Key<uint> = &keys[999]; + let key: Key<uint> = &KEYS[999]; key.get() }); } diff --git a/src/librustrt/mutex.rs b/src/librustrt/mutex.rs index 86dc9b85a79..28b0256f2e6 100644 --- a/src/librustrt/mutex.rs +++ b/src/librustrt/mutex.rs @@ -376,8 +376,8 @@ mod imp { #[cfg(target_arch = "arm")] static __PTHREAD_COND_SIZE__: uint = 24; - static _PTHREAD_MUTEX_SIG_init: libc::c_long = 0x32AAABA7; - static _PTHREAD_COND_SIG_init: libc::c_long = 0x3CB0B1BB; + static _PTHREAD_MUTEX_SIG_INIT: libc::c_long = 0x32AAABA7; + static _PTHREAD_COND_SIG_INIT: libc::c_long = 0x3CB0B1BB; #[repr(C)] pub struct pthread_mutex_t { @@ -391,11 +391,11 @@ mod imp { } pub static PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - __sig: _PTHREAD_MUTEX_SIG_init, + __sig: _PTHREAD_MUTEX_SIG_INIT, __opaque: [0, ..__PTHREAD_MUTEX_SIZE__], }; pub static PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - __sig: _PTHREAD_COND_SIG_init, + __sig: _PTHREAD_COND_SIG_INIT, __opaque: [0, ..__PTHREAD_COND_SIZE__], }; } diff --git a/src/librustrt/util.rs b/src/librustrt/util.rs index 77e3e25eb0e..9fbf4d09cd6 100644 --- a/src/librustrt/util.rs +++ b/src/librustrt/util.rs @@ -28,7 +28,9 @@ pub static ENFORCE_SANITY: bool = true || !cfg!(rtopt) || cfg!(rtdebug) || pub struct Stdio(libc::c_int); +#[allow(non_uppercase_statics)] pub static Stdout: Stdio = Stdio(libc::STDOUT_FILENO); +#[allow(non_uppercase_statics)] pub static Stderr: Stdio = Stdio(libc::STDERR_FILENO); impl fmt::FormatWriter for Stdio { |
