about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-12-22 11:21:36 -0800
committerbors <bors@rust-lang.org>2013-12-22 11:21:36 -0800
commit2e4cd83a0aff0fed5281c01cbae7aa74a1a53dee (patch)
tree689945c57fae5a834d75e079ac408544f40d573e /src
parent9b1e7db71c3a71c7a9f89f765e9d500c48539bfe (diff)
parent6f16df4aa3b5de7529ff209c909118d7ed1d962d (diff)
downloadrust-2e4cd83a0aff0fed5281c01cbae7aa74a1a53dee.tar.gz
rust-2e4cd83a0aff0fed5281c01cbae7aa74a1a53dee.zip
auto merge of #11082 : brson/rust/noat, r=alexcrichton
Diffstat (limited to 'src')
-rw-r--r--src/libstd/local_data.rs98
-rw-r--r--src/libstd/option.rs18
-rw-r--r--src/libstd/vec.rs49
3 files changed, 89 insertions, 76 deletions
diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs
index ad624f71d0c..69f1bfe9395 100644
--- a/src/libstd/local_data.rs
+++ b/src/libstd/local_data.rs
@@ -353,56 +353,56 @@ mod tests {
 
     #[test]
     fn test_tls_multitask() {
-        static my_key: Key<@~str> = &Key;
-        set(my_key, @~"parent data");
+        static my_key: Key<~str> = &Key;
+        set(my_key, ~"parent data");
         do task::spawn {
             // TLS shouldn't carry over.
-            assert!(get(my_key, |k| k.map(|k| *k)).is_none());
-            set(my_key, @~"child data");
-            assert!(*(get(my_key, |k| k.map(|k| *k)).unwrap()) ==
+            assert!(get(my_key, |k| k.map(|k| (*k).clone())).is_none());
+            set(my_key, ~"child data");
+            assert!(get(my_key, |k| k.map(|k| (*k).clone())).unwrap() ==
                     ~"child data");
             // should be cleaned up for us
         }
         // Must work multiple times
-        assert!(*(get(my_key, |k| k.map(|k| *k)).unwrap()) == ~"parent data");
-        assert!(*(get(my_key, |k| k.map(|k| *k)).unwrap()) == ~"parent data");
-        assert!(*(get(my_key, |k| k.map(|k| *k)).unwrap()) == ~"parent data");
+        assert!(get(my_key, |k| k.map(|k| (*k).clone())).unwrap() == ~"parent data");
+        assert!(get(my_key, |k| k.map(|k| (*k).clone())).unwrap() == ~"parent data");
+        assert!(get(my_key, |k| k.map(|k| (*k).clone())).unwrap() == ~"parent data");
     }
 
     #[test]
     fn test_tls_overwrite() {
-        static my_key: Key<@~str> = &Key;
-        set(my_key, @~"first data");
-        set(my_key, @~"next data"); // Shouldn't leak.
-        assert!(*(get(my_key, |k| k.map(|k| *k)).unwrap()) == ~"next data");
+        static my_key: Key<~str> = &Key;
+        set(my_key, ~"first data");
+        set(my_key, ~"next data"); // Shouldn't leak.
+        assert!(get(my_key, |k| k.map(|k| (*k).clone())).unwrap() == ~"next data");
     }
 
     #[test]
     fn test_tls_pop() {
-        static my_key: Key<@~str> = &Key;
-        set(my_key, @~"weasel");
-        assert!(*(pop(my_key).unwrap()) == ~"weasel");
+        static my_key: Key<~str> = &Key;
+        set(my_key, ~"weasel");
+        assert!(pop(my_key).unwrap() == ~"weasel");
         // Pop must remove the data from the map.
         assert!(pop(my_key).is_none());
     }
 
     #[test]
     fn test_tls_modify() {
-        static my_key: Key<@~str> = &Key;
+        static my_key: Key<~str> = &Key;
         modify(my_key, |data| {
             match data {
-                Some(@ref val) => fail!("unwelcome value: {}", *val),
-                None           => Some(@~"first data")
+                Some(ref val) => fail!("unwelcome value: {}", *val),
+                None           => Some(~"first data")
             }
         });
         modify(my_key, |data| {
             match data {
-                Some(@~"first data") => Some(@~"next data"),
-                Some(@ref val)       => fail!("wrong value: {}", *val),
+                Some(~"first data") => Some(~"next data"),
+                Some(ref val)       => fail!("wrong value: {}", *val),
                 None                 => fail!("missing value")
             }
         });
-        assert!(*(pop(my_key).unwrap()) == ~"next data");
+        assert!(pop(my_key).unwrap() == ~"next data");
     }
 
     #[test]
@@ -413,67 +413,67 @@ 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<@~str> = &Key;
+        static my_key: Key<~str> = &Key;
         do task::spawn {
-            set(my_key, @~"hax");
+            set(my_key, ~"hax");
         }
     }
 
     #[test]
     fn test_tls_multiple_types() {
-        static str_key: Key<@~str> = &Key;
-        static box_key: Key<@@()> = &Key;
-        static int_key: Key<@int> = &Key;
+        static str_key: Key<~str> = &Key;
+        static box_key: Key<@()> = &Key;
+        static int_key: Key<int> = &Key;
         do task::spawn {
-            set(str_key, @~"string data");
-            set(box_key, @@());
-            set(int_key, @42);
+            set(str_key, ~"string data");
+            set(box_key, @());
+            set(int_key, 42);
         }
     }
 
     #[test]
     fn test_tls_overwrite_multiple_types() {
-        static str_key: Key<@~str> = &Key;
-        static box_key: Key<@@()> = &Key;
-        static int_key: Key<@int> = &Key;
+        static str_key: Key<~str> = &Key;
+        static box_key: Key<@()> = &Key;
+        static int_key: Key<int> = &Key;
         do task::spawn {
-            set(str_key, @~"string data");
-            set(str_key, @~"string data 2");
-            set(box_key, @@());
-            set(box_key, @@());
-            set(int_key, @42);
+            set(str_key, ~"string data");
+            set(str_key, ~"string data 2");
+            set(box_key, @());
+            set(box_key, @());
+            set(int_key, 42);
             // This could cause a segfault if overwriting-destruction is done
             // with the crazy polymorphic transmute rather than the provided
             // finaliser.
-            set(int_key, @31337);
+            set(int_key, 31337);
         }
     }
 
     #[test]
     #[should_fail]
     fn test_tls_cleanup_on_failure() {
-        static str_key: Key<@~str> = &Key;
-        static box_key: Key<@@()> = &Key;
-        static int_key: Key<@int> = &Key;
-        set(str_key, @~"parent data");
-        set(box_key, @@());
+        static str_key: Key<~str> = &Key;
+        static box_key: Key<@()> = &Key;
+        static int_key: Key<int> = &Key;
+        set(str_key, ~"parent data");
+        set(box_key, @());
         do task::spawn {
             // spawn_linked
-            set(str_key, @~"string data");
-            set(box_key, @@());
-            set(int_key, @42);
+            set(str_key, ~"string data");
+            set(box_key, @());
+            set(int_key, 42);
             fail!();
         }
         // Not quite nondeterministic.
-        set(int_key, @31337);
+        set(int_key, 31337);
         fail!();
     }
 
     #[test]
     fn test_static_pointer() {
-        static key: Key<@&'static int> = &Key;
+        static key: Key<&'static int> = &Key;
         static VALUE: int = 0;
-        let v: @&'static int = @&VALUE;
+        let v: &'static int = &VALUE;
         set(key, v);
     }
 
diff --git a/src/libstd/option.rs b/src/libstd/option.rs
index 5067f6eb127..0e55ad732d7 100644
--- a/src/libstd/option.rs
+++ b/src/libstd/option.rs
@@ -445,28 +445,34 @@ mod tests {
 
     #[test]
     fn test_get_resource() {
+        use rc::Rc;
+        use cell::RefCell;
+
         struct R {
-           i: @mut int,
+           i: Rc<RefCell<int>>,
         }
 
         #[unsafe_destructor]
         impl ::ops::Drop for R {
-           fn drop(&mut self) { *(self.i) += 1; }
+           fn drop(&mut self) {
+                let ii = self.i.borrow();
+                ii.set(ii.get() + 1);
+            }
         }
 
-        fn R(i: @mut int) -> R {
+        fn R(i: Rc<RefCell<int>>) -> R {
             R {
                 i: i
             }
         }
 
-        let i = @mut 0;
+        let i = Rc::from_send(RefCell::new(0));
         {
-            let x = R(i);
+            let x = R(i.clone());
             let opt = Some(x);
             let _y = opt.unwrap();
         }
-        assert_eq!(*i, 1);
+        assert_eq!(i.borrow().get(), 1);
     }
 
     #[test]
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index e52243d6724..487f6749e3e 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -3254,7 +3254,7 @@ mod tests {
 
     #[test]
     fn test_truncate() {
-        let mut v = ~[@6,@5,@4];
+        let mut v = ~[~6,~5,~4];
         v.truncate(1);
         assert_eq!(v.len(), 1);
         assert_eq!(*(v[0]), 6);
@@ -3263,7 +3263,7 @@ mod tests {
 
     #[test]
     fn test_clear() {
-        let mut v = ~[@6,@5,@4];
+        let mut v = ~[~6,~5,~4];
         v.clear();
         assert_eq!(v.len(), 0);
         // If the unsafe block didn't drop things properly, we blow up here.
@@ -3302,14 +3302,14 @@ mod tests {
 
     #[test]
     fn test_dedup_shared() {
-        let mut v0 = ~[@1, @1, @2, @3];
+        let mut v0 = ~[~1, ~1, ~2, ~3];
         v0.dedup();
-        let mut v1 = ~[@1, @2, @2, @3];
+        let mut v1 = ~[~1, ~2, ~2, ~3];
         v1.dedup();
-        let mut v2 = ~[@1, @2, @3, @3];
+        let mut v2 = ~[~1, ~2, ~3, ~3];
         v2.dedup();
         /*
-         * If the @pointers were leaked or otherwise misused, valgrind and/or
+         * If the pointers were leaked or otherwise misused, valgrind and/or
          * rustrt should raise errors.
          */
     }
@@ -3694,7 +3694,7 @@ mod tests {
     fn test_from_fn_fail() {
         from_fn(100, |v| {
             if v == 50 { fail!() }
-            (~0, @0)
+            ~0
         });
     }
 
@@ -3702,10 +3702,11 @@ mod tests {
     #[should_fail]
     fn test_from_elem_fail() {
         use cast;
+        use rc::Rc;
 
         struct S {
             f: int,
-            boxes: (~int, @int)
+            boxes: (~int, Rc<int>)
         }
 
         impl Clone for S {
@@ -3717,18 +3718,19 @@ mod tests {
             }
         }
 
-        let s = S { f: 0, boxes: (~0, @0) };
+        let s = S { f: 0, boxes: (~0, Rc::new(0)) };
         let _ = from_elem(100, s);
     }
 
     #[test]
     #[should_fail]
     fn test_build_fail() {
+        use rc::Rc;
         build(None, |push| {
-            push((~0, @0));
-            push((~0, @0));
-            push((~0, @0));
-            push((~0, @0));
+            push((~0, Rc::new(0)));
+            push((~0, Rc::new(0)));
+            push((~0, Rc::new(0)));
+            push((~0, Rc::new(0)));
             fail!();
         });
     }
@@ -3736,47 +3738,51 @@ mod tests {
     #[test]
     #[should_fail]
     fn test_grow_fn_fail() {
+        use rc::Rc;
         let mut v = ~[];
         v.grow_fn(100, |i| {
             if i == 50 {
                 fail!()
             }
-            (~0, @0)
+            (~0, Rc::new(0))
         })
     }
 
     #[test]
     #[should_fail]
     fn test_map_fail() {
-        let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
+        use rc::Rc;
+        let v = [(~0, Rc::new(0)), (~0, Rc::new(0)), (~0, Rc::new(0)), (~0, Rc::new(0))];
         let mut i = 0;
         v.map(|_elt| {
             if i == 2 {
                 fail!()
             }
             i += 1;
-            ~[(~0, @0)]
+            ~[(~0, Rc::new(0))]
         });
     }
 
     #[test]
     #[should_fail]
     fn test_flat_map_fail() {
-        let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
+        use rc::Rc;
+        let v = [(~0, Rc::new(0)), (~0, Rc::new(0)), (~0, Rc::new(0)), (~0, Rc::new(0))];
         let mut i = 0;
         flat_map(v, |_elt| {
             if i == 2 {
                 fail!()
             }
             i += 1;
-            ~[(~0, @0)]
+            ~[(~0, Rc::new(0))]
         });
     }
 
     #[test]
     #[should_fail]
     fn test_permute_fail() {
-        let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
+        use rc::Rc;
+        let v = [(~0, Rc::new(0)), (~0, Rc::new(0)), (~0, Rc::new(0)), (~0, Rc::new(0))];
         let mut i = 0;
         for _ in v.permutations() {
             if i == 2 {
@@ -4114,9 +4120,10 @@ mod tests {
     #[test]
     #[should_fail]
     fn test_overflow_does_not_cause_segfault_managed() {
-        let mut v = ~[@1];
+        use rc::Rc;
+        let mut v = ~[Rc::new(1)];
         v.reserve(-1);
-        v.push(@2);
+        v.push(Rc::new(2));
     }
 
     #[test]