diff --git a/src/libsync/arc.rs b/src/libsync/arc.rs index 1d49771ed38..71adab71734 100644 --- a/src/libsync/arc.rs +++ b/src/libsync/arc.rs @@ -54,6 +54,9 @@ use std::kinds::marker; 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 { priv x: UnsafeArc } * Access the underlying data in an atomically reference counted * wrapper. */ -impl Arc { +impl Arc { /// Create an atomically reference counted wrapper. #[inline] pub fn new(data: T) -> Arc { @@ -135,7 +138,7 @@ impl Arc { } } -impl Clone for Arc { +impl Clone for Arc { /** * Duplicate an atomically reference counted wrapper. * @@ -295,19 +298,21 @@ struct RWArcInner { lock: RWLock, failed: bool, data: T } pub struct RWArc { priv x: UnsafeArc>, priv marker: marker::NoFreeze, + priv marker1: marker::NoShare, } -impl Clone for RWArc { +impl Clone for RWArc { /// Duplicate a rwlock-protected Arc. See arc::clone for more details. #[inline] fn clone(&self) -> RWArc { RWArc { x: self.x.clone(), - marker: marker::NoFreeze, } + marker: marker::NoFreeze, + marker1: marker::NoShare, } } } -impl RWArc { +impl RWArc { /// Create a reader/writer Arc with the supplied data. pub fn new(user_data: T) -> RWArc { RWArc::new_with_condvars(user_data, 1) @@ -323,7 +328,8 @@ impl RWArc { failed: false, data: user_data }; RWArc { x: UnsafeArc::new(data), - marker: marker::NoFreeze, } + marker: marker::NoFreeze, + marker1: marker::NoShare, } } /** @@ -454,7 +460,7 @@ impl RWArc { // 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(state: *mut RWArcInner) -> *RWLock { +fn borrow_rwlock(state: *mut RWArcInner) -> *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(&mut self, blk: |x: &mut T| -> U) -> U { match *self { @@ -510,7 +516,7 @@ impl<'a, T:Freeze + Send> RWWriteMode<'a, T> { } } -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(&self, blk: |x: &T| -> U) -> U { match *self { @@ -534,7 +540,7 @@ pub struct CowArc { priv x: UnsafeArc } /// 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 CowArc { +impl CowArc { /// Create a copy-on-write atomically reference counted wrapper #[inline] pub fn new(data: T) -> CowArc { @@ -558,7 +564,7 @@ impl CowArc { } } -impl Clone for CowArc { +impl Clone for CowArc { /// Duplicate a Copy-on-write Arc. See arc::clone for more details. fn clone(&self) -> CowArc { CowArc { x: self.x.clone() } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 77b0d4b5c9d..0f982741fc1 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1159,12 +1159,12 @@ mod test { use std::vec_ng::Vec; - fn is_freeze() {} + fn is_share() {} - // Assert that the AST remains Freeze (#10693). + // Assert that the AST remains sharable. #[test] - fn ast_is_freeze() { - is_freeze::(); + fn ast_is_share() { + is_share::(); } // are ASTs encodable? diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index c1ed96fe4de..e290932a303 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -23,13 +23,16 @@ use std::hash::Hash; use std::rc::Rc; use std::vec_ng::Vec; +#[cfg(stage0)] +use std::kinds::Share; + pub struct Interner { priv map: RefCell>, priv vect: RefCell >, } // when traits can extend traits, we should extend index to get [] -impl Interner { +impl Interner { pub fn new() -> Interner { Interner { map: RefCell::new(HashMap::new()), diff --git a/src/test/auxiliary/issue-2526.rs b/src/test/auxiliary/issue-2526.rs index ef5c141a3d5..51bbb59b77e 100644 --- a/src/test/auxiliary/issue-2526.rs +++ b/src/test/auxiliary/issue-2526.rs @@ -16,17 +16,17 @@ struct arc_destruct { } #[unsafe_destructor] -impl Drop for arc_destruct { +impl Drop for arc_destruct { fn drop(&mut self) {} } -fn arc_destruct(data: int) -> arc_destruct { +fn arc_destruct(data: int) -> arc_destruct { arc_destruct { _data: data } } -fn arc(_data: T) -> arc_destruct { +fn arc(_data: T) -> arc_destruct { arc_destruct(0) } diff --git a/src/test/compile-fail/builtin-superkinds-double-superkind.rs b/src/test/compile-fail/builtin-superkinds-double-superkind.rs index 15fa0b66433..7de38e6173b 100644 --- a/src/test/compile-fail/builtin-superkinds-double-superkind.rs +++ b/src/test/compile-fail/builtin-superkinds-double-superkind.rs @@ -11,12 +11,12 @@ // 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 Foo for (T,) { } //~ ERROR cannot implement this trait +impl Foo for (T,) { } //~ ERROR cannot implement this trait impl Foo for (T,T) { } //~ ERROR cannot implement this trait -impl Foo for (T,T,T) { } // (ok) +impl Foo for (T,T,T) { } // (ok) fn main() { } diff --git a/src/test/compile-fail/builtin-superkinds-self-type.rs b/src/test/compile-fail/builtin-superkinds-self-type.rs index 074c5d7bb76..0d5a71559e8 100644 --- a/src/test/compile-fail/builtin-superkinds-self-type.rs +++ b/src/test/compile-fail/builtin-superkinds-self-type.rs @@ -11,13 +11,13 @@ // 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) { chan.send(self); //~ ERROR does not fulfill `Send` } } -impl Foo for T { } +impl Foo for T { } fn main() { let (tx, rx) = channel(); diff --git a/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs b/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs index 2a3d3c7df61..bc0ad6dbb29 100644 --- a/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs +++ b/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs @@ -12,6 +12,6 @@ trait Foo : Send { } -impl Foo for T { } //~ ERROR cannot implement this trait +impl Foo for T { } //~ ERROR cannot implement this trait fn main() { } diff --git a/src/test/compile-fail/cant-implement-builtin-kinds.rs b/src/test/compile-fail/cant-implement-builtin-kinds.rs index c35ca098372..6bedac6d12d 100644 --- a/src/test/compile-fail/cant-implement-builtin-kinds.rs +++ b/src/test/compile-fail/cant-implement-builtin-kinds.rs @@ -14,6 +14,6 @@ struct X(T); impl Send for X { } //~ ERROR cannot provide an explicit implementation for a builtin kind impl Sized for X { } //~ ERROR cannot provide an explicit implementation for a builtin kind -impl Freeze for X { } //~ ERROR cannot provide an explicit implementation for a builtin kind +impl Share for X { } //~ ERROR cannot provide an explicit implementation for a builtin kind fn main() { } diff --git a/src/test/compile-fail/comm-not-freeze.rs b/src/test/compile-fail/comm-not-freeze.rs index b7b87b28264..3550922dc14 100644 --- a/src/test/compile-fail/comm-not-freeze.rs +++ b/src/test/compile-fail/comm-not-freeze.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn test() {} +fn test() {} fn main() { - test::>(); //~ ERROR: does not fulfill `Freeze` - test::>(); //~ ERROR: does not fulfill `Freeze` - test::>(); //~ ERROR: does not fulfill `Freeze` + test::>(); //~ ERROR: does not fulfill `Share` + test::>(); //~ ERROR: does not fulfill `Share` + test::>(); //~ ERROR: does not fulfill `Share` } diff --git a/src/test/compile-fail/issue-2611-4.rs b/src/test/compile-fail/issue-2611-4.rs index c62c2874525..b159337765e 100644 --- a/src/test/compile-fail/issue-2611-4.rs +++ b/src/test/compile-fail/issue-2611-4.rs @@ -20,7 +20,7 @@ struct E { } impl A for E { - fn b(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Freeze` + fn b(_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-share.rs similarity index 84% rename from src/test/compile-fail/marker-no-freeze.rs rename to src/test/compile-fail/marker-no-share.rs index 85f4f4fefd4..84e856f5ac9 100644 --- a/src/test/compile-fail/marker-no-freeze.rs +++ b/src/test/compile-fail/marker-no-share.rs @@ -10,9 +10,9 @@ use std::kinds::marker; -fn foo(p: P) { } +fn foo(p: P) { } fn main() { - foo(marker::NoFreeze); //~ ERROR does not fulfill `Freeze` + foo(marker::NoShare); //~ ERROR does not fulfill `Share` } diff --git a/src/test/compile-fail/mut-not-freeze.rs b/src/test/compile-fail/mut-not-freeze.rs index 97fe49ca087..f1e7ef216c3 100644 --- a/src/test/compile-fail/mut-not-freeze.rs +++ b/src/test/compile-fail/mut-not-freeze.rs @@ -10,9 +10,9 @@ use std::cell::RefCell; -fn f(_: T) {} +fn f(_: 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_share-enum.rs similarity index 81% rename from src/test/compile-fail/no_freeze-enum.rs rename to src/test/compile-fail/no_share-enum.rs index e27b9dd85b4..e68274fcb79 100644 --- a/src/test/compile-fail/no_freeze-enum.rs +++ b/src/test/compile-fail/no_share-enum.rs @@ -10,13 +10,13 @@ use std::kinds::marker; -enum Foo { A(marker::NoFreeze) } +enum Foo { A(marker::NoShare) } -fn bar(_: T) {} +fn bar(_: T) {} fn main() { - let x = A(marker::NoFreeze); + let x = A(marker::NoShare); bar(x); //~^ ERROR instantiating a type parameter with an incompatible type `Foo`, - // which does not fulfill `Freeze` + // which does not fulfill `Share` } diff --git a/src/test/compile-fail/no_freeze-rc.rs b/src/test/compile-fail/no_share-rc.rs similarity index 93% rename from src/test/compile-fail/no_freeze-rc.rs rename to src/test/compile-fail/no_share-rc.rs index b814a71dcbe..ad79d038212 100644 --- a/src/test/compile-fail/no_freeze-rc.rs +++ b/src/test/compile-fail/no_share-rc.rs @@ -11,11 +11,11 @@ use std::rc::Rc; use std::cell::RefCell; -fn bar(_: T) {} +fn bar(_: T) {} fn main() { let x = Rc::new(RefCell::new(5)); bar(x); //~^ ERROR instantiating a type parameter with an incompatible type - // `std::rc::Rc>`, which does not fulfill `Freeze` + // `std::rc::Rc>`, which does not fulfill `Share` } diff --git a/src/test/compile-fail/no_freeze-struct.rs b/src/test/compile-fail/no_share-struct.rs similarity index 78% rename from src/test/compile-fail/no_freeze-struct.rs rename to src/test/compile-fail/no_share-struct.rs index c85574438ba..7bb7d86e8d8 100644 --- a/src/test/compile-fail/no_freeze-struct.rs +++ b/src/test/compile-fail/no_share-struct.rs @@ -10,13 +10,13 @@ use std::kinds::marker; -struct Foo { a: int, m: marker::NoFreeze } +struct Foo { a: int, m: marker::NoShare } -fn bar(_: T) {} +fn bar(_: T) {} fn main() { - let x = Foo { a: 5, m: marker::NoFreeze }; + let x = Foo { a: 5, m: marker::NoShare }; bar(x); //~^ ERROR instantiating a type parameter with an incompatible type `Foo`, - // which does not fulfill `Freeze` + // which does not fulfill `Share` } diff --git a/src/test/run-pass/const-bound.rs b/src/test/run-pass/const-bound.rs index 635ae704e41..c8c2a11d8d6 100644 --- a/src/test/run-pass/const-bound.rs +++ b/src/test/run-pass/const-bound.rs @@ -12,7 +12,7 @@ // are const. -fn foo(x: T) -> T { x } +fn foo(x: T) -> T { x } struct F { field: int } diff --git a/src/test/run-pass/issue-2611-3.rs b/src/test/run-pass/issue-2611-3.rs index a3d51bb9014..f48a49a15eb 100644 --- a/src/test/run-pass/issue-2611-3.rs +++ b/src/test/run-pass/issue-2611-3.rs @@ -12,7 +12,7 @@ // than the traits require. trait A { - fn b(x: C) -> C; + fn b(x: C) -> C; } struct E { diff --git a/src/test/run-pass/trait-bounds-in-arc.rs b/src/test/run-pass/trait-bounds-in-arc.rs index f157f8ea95c..0ed4fdb2c05 100644 --- a/src/test/run-pass/trait-bounds-in-arc.rs +++ b/src/test/run-pass/trait-bounds-in-arc.rs @@ -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()); }