From ce0907e46e8e1aa23ee39f69e4f628f68bfbb0d7 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Thu, 11 Sep 2014 17:07:49 +1200 Subject: Add enum variants to the type namespace Change to resolve and update compiler and libs for uses. [breaking-change] Enum variants are now in both the value and type namespaces. This means that if you have a variant with the same name as a type in scope in a module, you will get a name clash and thus an error. The solution is to either rename the type or the variant. --- src/librustrt/local_data.rs | 62 ++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'src/librustrt') diff --git a/src/librustrt/local_data.rs b/src/librustrt/local_data.rs index c71f86bb063..ba5a4dc3f21 100644 --- a/src/librustrt/local_data.rs +++ b/src/librustrt/local_data.rs @@ -67,7 +67,7 @@ use task::{Task, LocalStorage}; pub type Key = &'static KeyValue; #[allow(missing_doc)] -pub enum KeyValue { Key } +pub enum KeyValue { KeyValueKey } // The task-local-map stores all TLD information for the currently running // task. It is stored as an owned pointer into the runtime, and it's only @@ -417,7 +417,7 @@ mod tests { #[test] fn test_tls_multitask() { - static my_key: Key = &Key; + static my_key: Key = &KeyValueKey; my_key.replace(Some("parent data".to_string())); task::spawn(proc() { // TLD shouldn't carry over. @@ -435,7 +435,7 @@ mod tests { #[test] fn test_tls_overwrite() { - static my_key: Key = &Key; + static my_key: Key = &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"); @@ -443,7 +443,7 @@ mod tests { #[test] fn test_tls_pop() { - static my_key: Key = &Key; + static my_key: Key = &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. @@ -458,7 +458,7 @@ 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 = &Key; + static my_key: Key = &KeyValueKey; task::spawn(proc() { my_key.replace(Some("hax".to_string())); }); @@ -466,9 +466,9 @@ mod tests { #[test] fn test_tls_multiple_types() { - static str_key: Key = &Key; - static box_key: Key> = &Key; - static int_key: Key = &Key; + static str_key: Key = &KeyValueKey; + static box_key: Key> = &KeyValueKey; + static int_key: Key = &KeyValueKey; task::spawn(proc() { str_key.replace(Some("string data".to_string())); box_key.replace(Some(box(GC) ())); @@ -478,9 +478,9 @@ mod tests { #[test] fn test_tls_overwrite_multiple_types() { - static str_key: Key = &Key; - static box_key: Key> = &Key; - static int_key: Key = &Key; + static str_key: Key = &KeyValueKey; + static box_key: Key> = &KeyValueKey; + static int_key: Key = &KeyValueKey; task::spawn(proc() { str_key.replace(Some("string data".to_string())); str_key.replace(Some("string data 2".to_string())); @@ -497,9 +497,9 @@ mod tests { #[test] #[should_fail] fn test_tls_cleanup_on_failure() { - static str_key: Key = &Key; - static box_key: Key> = &Key; - static int_key: Key = &Key; + static str_key: Key = &KeyValueKey; + static box_key: Key> = &KeyValueKey; + static int_key: Key = &KeyValueKey; str_key.replace(Some("parent data".to_string())); box_key.replace(Some(box(GC) ())); task::spawn(proc() { @@ -524,7 +524,7 @@ mod tests { self.tx.send(()); } } - static key: Key = &Key; + static key: Key = &KeyValueKey; let _ = task::try(proc() { key.replace(Some(Dropper{ tx: tx })); }); @@ -535,14 +535,14 @@ mod tests { #[test] fn test_static_pointer() { - static key: Key<&'static int> = &Key; + static key: Key<&'static int> = &KeyValueKey; static VALUE: int = 0; key.replace(Some(&VALUE)); } #[test] fn test_owned() { - static key: Key> = &Key; + static key: Key> = &KeyValueKey; key.replace(Some(box 1)); { @@ -559,11 +559,11 @@ mod tests { #[test] fn test_same_key_type() { - static key1: Key = &Key; - static key2: Key = &Key; - static key3: Key = &Key; - static key4: Key = &Key; - static key5: Key = &Key; + static key1: Key = &KeyValueKey; + static key2: Key = &KeyValueKey; + static key3: Key = &KeyValueKey; + static key4: Key = &KeyValueKey; + static key5: Key = &KeyValueKey; key1.replace(Some(1)); key2.replace(Some(2)); key3.replace(Some(3)); @@ -580,7 +580,7 @@ mod tests { #[test] #[should_fail] fn test_nested_get_set1() { - static key: Key = &Key; + static key: Key = &KeyValueKey; assert_eq!(key.replace(Some(4)), None); let _k = key.get(); @@ -602,7 +602,7 @@ mod tests { #[bench] fn bench_replace_none(b: &mut test::Bencher) { - static key: Key = &Key; + static key: Key = &KeyValueKey; let _clear = ClearKey(key); key.replace(None); b.iter(|| { @@ -612,7 +612,7 @@ mod tests { #[bench] fn bench_replace_some(b: &mut test::Bencher) { - static key: Key = &Key; + static key: Key = &KeyValueKey; let _clear = ClearKey(key); key.replace(Some(1u)); b.iter(|| { @@ -622,7 +622,7 @@ mod tests { #[bench] fn bench_replace_none_some(b: &mut test::Bencher) { - static key: Key = &Key; + static key: Key = &KeyValueKey; let _clear = ClearKey(key); key.replace(Some(0u)); b.iter(|| { @@ -634,7 +634,7 @@ mod tests { #[bench] fn bench_100_keys_replace_last(b: &mut test::Bencher) { - static keys: [KeyValue, ..100] = [Key, ..100]; + static keys: [KeyValue, ..100] = [KeyValueKey, ..100]; let _clear = keys.iter().map(ClearKey).collect::>>(); for (i, key) in keys.iter().enumerate() { key.replace(Some(i)); @@ -647,7 +647,7 @@ mod tests { #[bench] fn bench_1000_keys_replace_last(b: &mut test::Bencher) { - static keys: [KeyValue, ..1000] = [Key, ..1000]; + static keys: [KeyValue, ..1000] = [KeyValueKey, ..1000]; let _clear = keys.iter().map(ClearKey).collect::>>(); for (i, key) in keys.iter().enumerate() { key.replace(Some(i)); @@ -661,7 +661,7 @@ mod tests { #[bench] fn bench_get(b: &mut test::Bencher) { - static key: Key = &Key; + static key: Key = &KeyValueKey; let _clear = ClearKey(key); key.replace(Some(42)); b.iter(|| { @@ -671,7 +671,7 @@ mod tests { #[bench] fn bench_100_keys_get_last(b: &mut test::Bencher) { - static keys: [KeyValue, ..100] = [Key, ..100]; + static keys: [KeyValue, ..100] = [KeyValueKey, ..100]; let _clear = keys.iter().map(ClearKey).collect::>>(); for (i, key) in keys.iter().enumerate() { key.replace(Some(i)); @@ -684,7 +684,7 @@ mod tests { #[bench] fn bench_1000_keys_get_last(b: &mut test::Bencher) { - static keys: [KeyValue, ..1000] = [Key, ..1000]; + static keys: [KeyValue, ..1000] = [KeyValueKey, ..1000]; let _clear = keys.iter().map(ClearKey).collect::>>(); for (i, key) in keys.iter().enumerate() { key.replace(Some(i)); -- cgit 1.4.1-3-g733a5