]> git.lizzy.rs Git - rust.git/commitdiff
Replace Freeze bounds with Share bounds
authorFlavio Percoco <flaper87@gmail.com>
Fri, 7 Mar 2014 17:57:35 +0000 (18:57 +0100)
committerFlavio Percoco <flaper87@gmail.com>
Thu, 20 Mar 2014 09:16:55 +0000 (10:16 +0100)
22 files changed:
src/libsync/arc.rs
src/libsyntax/ast.rs
src/libsyntax/util/interner.rs
src/test/auxiliary/issue-2526.rs
src/test/compile-fail/builtin-superkinds-double-superkind.rs
src/test/compile-fail/builtin-superkinds-self-type.rs
src/test/compile-fail/builtin-superkinds-typaram-not-send.rs
src/test/compile-fail/cant-implement-builtin-kinds.rs
src/test/compile-fail/comm-not-freeze.rs
src/test/compile-fail/issue-2611-4.rs
src/test/compile-fail/marker-no-freeze.rs [deleted file]
src/test/compile-fail/marker-no-share.rs [new file with mode: 0644]
src/test/compile-fail/mut-not-freeze.rs
src/test/compile-fail/no_freeze-enum.rs [deleted file]
src/test/compile-fail/no_freeze-rc.rs [deleted file]
src/test/compile-fail/no_freeze-struct.rs [deleted file]
src/test/compile-fail/no_share-enum.rs [new file with mode: 0644]
src/test/compile-fail/no_share-rc.rs [new file with mode: 0644]
src/test/compile-fail/no_share-struct.rs [new file with mode: 0644]
src/test/run-pass/const-bound.rs
src/test/run-pass/issue-2611-3.rs
src/test/run-pass/trait-bounds-in-arc.rs

index 1d49771ed386aab895da7ecfa196685062f100f2..71adab71734b99d889ea4b9f7c4b576a610c0ddf 100644 (file)
@@ -54,6 +54,9 @@
 use std::sync::arc::UnsafeArc;
 use std::task;
 
+#[cfg(stage0)]
+use std::kinds::Share;
+
 /// As sync::condvar, a mechanism for unlock-and-descheduling and
 /// signaling, for use with the Arc types.
 pub struct ArcCondvar<'a> {
@@ -122,7 +125,7 @@ pub struct Arc<T> { priv x: UnsafeArc<T> }
  * Access the underlying data in an atomically reference counted
  * wrapper.
  */
-impl<T:Freeze+Send> Arc<T> {
+impl<T: Share + Send> Arc<T> {
     /// Create an atomically reference counted wrapper.
     #[inline]
     pub fn new(data: T) -> Arc<T> {
@@ -135,7 +138,7 @@ pub fn get<'a>(&'a self) -> &'a T {
     }
 }
 
-impl<T:Freeze + Send> Clone for Arc<T> {
+impl<T: Share + Send> Clone for Arc<T> {
     /**
     * Duplicate an atomically reference counted wrapper.
     *
@@ -295,19 +298,21 @@ struct RWArcInner<T> { lock: RWLock, failed: bool, data: T }
 pub struct RWArc<T> {
     priv x: UnsafeArc<RWArcInner<T>>,
     priv marker: marker::NoFreeze,
+    priv marker1: marker::NoShare,
 }
 
-impl<T:Freeze + Send> Clone for RWArc<T> {
+impl<T: Share + Send> Clone for RWArc<T> {
     /// Duplicate a rwlock-protected Arc. See arc::clone for more details.
     #[inline]
     fn clone(&self) -> RWArc<T> {
         RWArc { x: self.x.clone(),
-                marker: marker::NoFreeze, }
+                marker: marker::NoFreeze,
+                marker1: marker::NoShare, }
     }
 
 }
 
-impl<T:Freeze + Send> RWArc<T> {
+impl<T: Share + Send> RWArc<T> {
     /// Create a reader/writer Arc with the supplied data.
     pub fn new(user_data: T) -> RWArc<T> {
         RWArc::new_with_condvars(user_data, 1)
@@ -323,7 +328,8 @@ pub fn new_with_condvars(user_data: T, num_condvars: uint) -> RWArc<T> {
             failed: false, data: user_data
         };
         RWArc { x: UnsafeArc::new(data),
-                marker: marker::NoFreeze, }
+                marker: marker::NoFreeze,
+                marker1: marker::NoShare, }
     }
 
     /**
@@ -454,7 +460,7 @@ pub fn downgrade<'a>(&self, token: RWWriteMode<'a, T>)
 // lock it. This wraps the unsafety, with the justification that the 'lock'
 // field is never overwritten; only 'failed' and 'data'.
 #[doc(hidden)]
-fn borrow_rwlock<T:Freeze + Send>(state: *mut RWArcInner<T>) -> *RWLock {
+fn borrow_rwlock<T: Share + Send>(state: *mut RWArcInner<T>) -> *RWLock {
     unsafe { cast::transmute(&(*state).lock) }
 }
 
@@ -471,7 +477,7 @@ pub struct RWReadMode<'a, T> {
     priv token: sync::RWLockReadMode<'a>,
 }
 
-impl<'a, T:Freeze + Send> RWWriteMode<'a, T> {
+impl<'a, T: Share + Send> RWWriteMode<'a, T> {
     /// Access the pre-downgrade RWArc in write mode.
     pub fn write<U>(&mut self, blk: |x: &mut T| -> U) -> U {
         match *self {
@@ -510,7 +516,7 @@ pub fn write_cond<U>(&mut self,
     }
 }
 
-impl<'a, T:Freeze + Send> RWReadMode<'a, T> {
+impl<'a, T: Share + Send> RWReadMode<'a, T> {
     /// Access the post-downgrade rwlock in read mode.
     pub fn read<U>(&self, blk: |x: &T| -> U) -> U {
         match *self {
@@ -534,7 +540,7 @@ pub struct CowArc<T> { priv x: UnsafeArc<T> }
 /// mutation of the contents if there is only a single reference to
 /// the data. If there are multiple references the data is automatically
 /// cloned and the task modifies the cloned data in place of the shared data.
-impl<T:Clone+Send+Freeze> CowArc<T> {
+impl<T: Clone + Send + Share> CowArc<T> {
     /// Create a copy-on-write atomically reference counted wrapper
     #[inline]
     pub fn new(data: T) -> CowArc<T> {
@@ -558,7 +564,7 @@ pub fn get_mut<'a>(&'a mut self) -> &'a mut T {
     }
 }
 
-impl<T:Clone+Send+Freeze> Clone for CowArc<T> {
+impl<T: Clone + Send + Share> Clone for CowArc<T> {
     /// Duplicate a Copy-on-write Arc. See arc::clone for more details.
     fn clone(&self) -> CowArc<T> {
         CowArc { x: self.x.clone() }
index 77b0d4b5c9da5f425d8fcc584b0c0930d3175a46..0f982741fc16188b3978296ce41d6564f1f4a043 100644 (file)
@@ -1159,12 +1159,12 @@ mod test {
 
     use std::vec_ng::Vec;
 
-    fn is_freeze<T: Freeze>() {}
+    fn is_share<T: Share>() {}
 
-    // Assert that the AST remains Freeze (#10693).
+    // Assert that the AST remains sharable.
     #[test]
-    fn ast_is_freeze() {
-        is_freeze::<Item>();
+    fn ast_is_share() {
+        is_share::<Item>();
     }
 
     // are ASTs encodable?
index c1ed96fe4de48543643acaddb0472546954a088c..e290932a3033218582aaafcd9a870c9a57f00827 100644 (file)
 use std::rc::Rc;
 use std::vec_ng::Vec;
 
+#[cfg(stage0)]
+use std::kinds::Share;
+
 pub struct Interner<T> {
     priv map: RefCell<HashMap<T, Name>>,
     priv vect: RefCell<Vec<T> >,
 }
 
 // when traits can extend traits, we should extend index<Name,T> to get []
-impl<T:Eq + Hash + Freeze + Clone + 'static> Interner<T> {
+impl<T: Eq + Hash + Share + Clone + 'static> Interner<T> {
     pub fn new() -> Interner<T> {
         Interner {
             map: RefCell::new(HashMap::new()),
index ef5c141a3d5082a0f9f9cf2e0624309c6b324057..51bbb59b77eca84f73502c27c84539a2b67efa6d 100644 (file)
@@ -16,17 +16,17 @@ struct arc_destruct<T> {
 }
 
 #[unsafe_destructor]
-impl<T:Freeze> Drop for arc_destruct<T> {
+impl<T: Share> Drop for arc_destruct<T> {
     fn drop(&mut self) {}
 }
 
-fn arc_destruct<T:Freeze>(data: int) -> arc_destruct<T> {
+fn arc_destruct<T: Share>(data: int) -> arc_destruct<T> {
     arc_destruct {
         _data: data
     }
 }
 
-fn arc<T:Freeze>(_data: T) -> arc_destruct<T> {
+fn arc<T: Share>(_data: T) -> arc_destruct<T> {
     arc_destruct(0)
 }
 
index 15fa0b6643381f60a63124111666509f461cd8f8..7de38e6173be1ee3628fb07ccd76a092870ef29b 100644 (file)
 // Test for traits that inherit from multiple builtin kinds at once,
 // testing that all such kinds must be present on implementing types.
 
-trait Foo : Send+Freeze { }
+trait Foo : Send+Share { }
 
-impl <T: Freeze> Foo for (T,) { } //~ ERROR cannot implement this trait
+impl <T: Share> Foo for (T,) { } //~ ERROR cannot implement this trait
 
 impl <T: Send> Foo for (T,T) { } //~ ERROR cannot implement this trait
 
-impl <T: Send+Freeze> Foo for (T,T,T) { } // (ok)
+impl <T: Send+Share> Foo for (T,T,T) { } // (ok)
 
 fn main() { }
index 074c5d7bb761a06fa7ca5a7c0e11ca68f0f1a0aa..0d5a71559e8678317d1464fa7f13b3b6ba72e093 100644 (file)
 // Tests (negatively) the ability for the Self type in default methods
 // to use capabilities granted by builtin kinds as supertraits.
 
-trait Foo : Freeze {
+trait Foo : Share {
     fn foo(self, mut chan: Sender<Self>) {
         chan.send(self); //~ ERROR does not fulfill `Send`
     }
 }
 
-impl <T: Freeze> Foo for T { }
+impl <T: Share> Foo for T { }
 
 fn main() {
     let (tx, rx) = channel();
index 2a3d3c7df6132ff8d95678216ba16c62ba2f6911..bc0ad6dbb2938a2329b03dc953cc0ff6367de290 100644 (file)
@@ -12,6 +12,6 @@
 
 trait Foo : Send { }
 
-impl <T: Freeze> Foo for T { } //~ ERROR cannot implement this trait
+impl <T: Share> Foo for T { } //~ ERROR cannot implement this trait
 
 fn main() { }
index c35ca098372d351f6e013043fb38070acaff3315..6bedac6d12d6c026b73b7d4189e77df8f215ed19 100644 (file)
@@ -14,6 +14,6 @@
 
 impl <T> Send for X<T> { } //~ ERROR cannot provide an explicit implementation for a builtin kind
 impl <T> Sized for X<T> { } //~ ERROR cannot provide an explicit implementation for a builtin kind
-impl <T> Freeze for X<T> { } //~ ERROR cannot provide an explicit implementation for a builtin kind
+impl <T> Share for X<T> { } //~ ERROR cannot provide an explicit implementation for a builtin kind
 
 fn main() { }
index b7b87b2826440d03c8111f789c6532b1aab37a9f..3550922dc1462e97d5aadd1f37335e003b8bbbf2 100644 (file)
@@ -8,10 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn test<T: Freeze>() {}
+fn test<T: Share>() {}
 
 fn main() {
-    test::<Sender<int>>();        //~ ERROR: does not fulfill `Freeze`
-    test::<Receiver<int>>();        //~ ERROR: does not fulfill `Freeze`
-    test::<Sender<int>>();  //~ ERROR: does not fulfill `Freeze`
+    test::<Sender<int>>();        //~ ERROR: does not fulfill `Share`
+    test::<Receiver<int>>();        //~ ERROR: does not fulfill `Share`
+    test::<Sender<int>>();  //~ ERROR: does not fulfill `Share`
 }
index c62c28745253d157977417675c3758126fcdf2e8..b159337765e5f5844447a045e6902f86a1822e58 100644 (file)
@@ -20,7 +20,7 @@ struct E {
 }
 
 impl A for E {
-  fn b<F:Freeze,G>(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Freeze`
+  fn b<F: Share, G>(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Share`
 }
 
 fn main() {}
diff --git a/src/test/compile-fail/marker-no-freeze.rs b/src/test/compile-fail/marker-no-freeze.rs
deleted file mode 100644 (file)
index 85f4f4f..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::kinds::marker;
-
-fn foo<P:Freeze>(p: P) { }
-
-fn main()
-{
-    foo(marker::NoFreeze); //~ ERROR does not fulfill `Freeze`
-}
diff --git a/src/test/compile-fail/marker-no-share.rs b/src/test/compile-fail/marker-no-share.rs
new file mode 100644 (file)
index 0000000..84e856f
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::kinds::marker;
+
+fn foo<P: Share>(p: P) { }
+
+fn main()
+{
+    foo(marker::NoShare); //~ ERROR does not fulfill `Share`
+}
index 97fe49ca087f544e52f89607f3bcd6b72833f169..f1e7ef216c32c6982b31445c677f2bb2ae4f1ad8 100644 (file)
@@ -10,9 +10,9 @@
 
 use std::cell::RefCell;
 
-fn f<T: Freeze>(_: T) {}
+fn f<T: Share>(_: T) {}
 
 fn main() {
     let x = RefCell::new(0);
-    f(x); //~ ERROR: which does not fulfill `Freeze`
+    f(x); //~ ERROR: which does not fulfill `Share`
 }
diff --git a/src/test/compile-fail/no_freeze-enum.rs b/src/test/compile-fail/no_freeze-enum.rs
deleted file mode 100644 (file)
index e27b9dd..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::kinds::marker;
-
-enum Foo { A(marker::NoFreeze) }
-
-fn bar<T: Freeze>(_: T) {}
-
-fn main() {
-    let x = A(marker::NoFreeze);
-    bar(x);
-    //~^ ERROR instantiating a type parameter with an incompatible type `Foo`,
-    //         which does not fulfill `Freeze`
-}
diff --git a/src/test/compile-fail/no_freeze-rc.rs b/src/test/compile-fail/no_freeze-rc.rs
deleted file mode 100644 (file)
index b814a71..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::rc::Rc;
-use std::cell::RefCell;
-
-fn bar<T: Freeze>(_: T) {}
-
-fn main() {
-    let x = Rc::new(RefCell::new(5));
-    bar(x);
-    //~^ ERROR instantiating a type parameter with an incompatible type
-    //         `std::rc::Rc<std::cell::RefCell<int>>`, which does not fulfill `Freeze`
-}
diff --git a/src/test/compile-fail/no_freeze-struct.rs b/src/test/compile-fail/no_freeze-struct.rs
deleted file mode 100644 (file)
index c855744..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use std::kinds::marker;
-
-struct Foo { a: int, m: marker::NoFreeze }
-
-fn bar<T: Freeze>(_: T) {}
-
-fn main() {
-    let x = Foo { a: 5, m: marker::NoFreeze };
-    bar(x);
-    //~^ ERROR instantiating a type parameter with an incompatible type `Foo`,
-    //         which does not fulfill `Freeze`
-}
diff --git a/src/test/compile-fail/no_share-enum.rs b/src/test/compile-fail/no_share-enum.rs
new file mode 100644 (file)
index 0000000..e68274f
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::kinds::marker;
+
+enum Foo { A(marker::NoShare) }
+
+fn bar<T: Share>(_: T) {}
+
+fn main() {
+    let x = A(marker::NoShare);
+    bar(x);
+    //~^ ERROR instantiating a type parameter with an incompatible type `Foo`,
+    //         which does not fulfill `Share`
+}
diff --git a/src/test/compile-fail/no_share-rc.rs b/src/test/compile-fail/no_share-rc.rs
new file mode 100644 (file)
index 0000000..ad79d03
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::rc::Rc;
+use std::cell::RefCell;
+
+fn bar<T: Share>(_: T) {}
+
+fn main() {
+    let x = Rc::new(RefCell::new(5));
+    bar(x);
+    //~^ ERROR instantiating a type parameter with an incompatible type
+    //         `std::rc::Rc<std::cell::RefCell<int>>`, which does not fulfill `Share`
+}
diff --git a/src/test/compile-fail/no_share-struct.rs b/src/test/compile-fail/no_share-struct.rs
new file mode 100644 (file)
index 0000000..7bb7d86
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::kinds::marker;
+
+struct Foo { a: int, m: marker::NoShare }
+
+fn bar<T: Share>(_: T) {}
+
+fn main() {
+    let x = Foo { a: 5, m: marker::NoShare };
+    bar(x);
+    //~^ ERROR instantiating a type parameter with an incompatible type `Foo`,
+    //         which does not fulfill `Share`
+}
index 635ae704e4194df134ac6841d4bd73e2d00d27c3..c8c2a11d8d649916bfb153f97df736407f3362c9 100644 (file)
@@ -12,7 +12,7 @@
 // are const.
 
 
-fn foo<T:Freeze>(x: T) -> T { x }
+fn foo<T: Share>(x: T) -> T { x }
 
 struct F { field: int }
 
index a3d51bb9014e88d1157106366284ba6a0cbac1c0..f48a49a15eb3d805ffa0dbd6c11d6f526d425426 100644 (file)
@@ -12,7 +12,7 @@
 // than the traits require.
 
 trait A {
-  fn b<C:Freeze,D>(x: C) -> C;
+  fn b<C:Share,D>(x: C) -> C;
 }
 
 struct E {
index f157f8ea95c829476e69b1c33c7113134cd3f58d..0ed4fdb2c054d528fb9bfde5d371710ffbbd35fd 100644 (file)
@@ -65,10 +65,10 @@ pub fn main() {
     let dogge1 = Dogge { bark_decibels: 100, tricks_known: 42, name: ~"alan_turing" };
     let dogge2 = Dogge { bark_decibels: 55,  tricks_known: 11, name: ~"albert_einstein" };
     let fishe = Goldfyshe { swim_speed: 998, name: ~"alec_guinness" };
-    let arc = Arc::new(~[~catte  as ~Pet:Freeze+Send,
-                         ~dogge1 as ~Pet:Freeze+Send,
-                         ~fishe  as ~Pet:Freeze+Send,
-                         ~dogge2 as ~Pet:Freeze+Send]);
+    let arc = Arc::new(~[~catte  as ~Pet:Share+Send,
+                         ~dogge1 as ~Pet:Share+Send,
+                         ~fishe  as ~Pet:Share+Send,
+                         ~dogge2 as ~Pet:Share+Send]);
     let (tx1, rx1) = channel();
     let arc1 = arc.clone();
     task::spawn(proc() { check_legs(arc1); tx1.send(()); });
@@ -83,21 +83,21 @@ pub fn main() {
     rx3.recv();
 }
 
-fn check_legs(arc: Arc<~[~Pet:Freeze+Send]>) {
+fn check_legs(arc: Arc<~[~Pet:Share+Send]>) {
     let mut legs = 0;
     for pet in arc.get().iter() {
         legs += pet.num_legs();
     }
     assert!(legs == 12);
 }
-fn check_names(arc: Arc<~[~Pet:Freeze+Send]>) {
+fn check_names(arc: Arc<~[~Pet:Share+Send]>) {
     for pet in arc.get().iter() {
         pet.name(|name| {
             assert!(name[0] == 'a' as u8 && name[1] == 'l' as u8);
         })
     }
 }
-fn check_pedigree(arc: Arc<~[~Pet:Freeze+Send]>) {
+fn check_pedigree(arc: Arc<~[~Pet:Share+Send]>) {
     for pet in arc.get().iter() {
         assert!(pet.of_good_pedigree());
     }