Skip to content

Commit 12ecafb

Browse files
committed
Replace Freeze bounds with Share bounds
1 parent 21d23ff commit 12ecafb

18 files changed

+63
-54
lines changed

src/libsync/arc.rs

+17-11
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ use std::kinds::marker;
5454
use std::sync::arc::UnsafeArc;
5555
use std::task;
5656

57+
#[cfg(stage0)]
58+
use std::kinds::Share;
59+
5760
/// As sync::condvar, a mechanism for unlock-and-descheduling and
5861
/// signaling, for use with the Arc types.
5962
pub struct ArcCondvar<'a> {
@@ -122,7 +125,7 @@ pub struct Arc<T> { priv x: UnsafeArc<T> }
122125
* Access the underlying data in an atomically reference counted
123126
* wrapper.
124127
*/
125-
impl<T:Freeze+Send> Arc<T> {
128+
impl<T: Share + Send> Arc<T> {
126129
/// Create an atomically reference counted wrapper.
127130
#[inline]
128131
pub fn new(data: T) -> Arc<T> {
@@ -135,7 +138,7 @@ impl<T:Freeze+Send> Arc<T> {
135138
}
136139
}
137140

138-
impl<T:Freeze + Send> Clone for Arc<T> {
141+
impl<T: Share + Send> Clone for Arc<T> {
139142
/**
140143
* Duplicate an atomically reference counted wrapper.
141144
*
@@ -295,19 +298,21 @@ struct RWArcInner<T> { lock: RWLock, failed: bool, data: T }
295298
pub struct RWArc<T> {
296299
priv x: UnsafeArc<RWArcInner<T>>,
297300
priv marker: marker::NoFreeze,
301+
priv marker1: marker::NoShare,
298302
}
299303

300-
impl<T:Freeze + Send> Clone for RWArc<T> {
304+
impl<T: Share + Send> Clone for RWArc<T> {
301305
/// Duplicate a rwlock-protected Arc. See arc::clone for more details.
302306
#[inline]
303307
fn clone(&self) -> RWArc<T> {
304308
RWArc { x: self.x.clone(),
305-
marker: marker::NoFreeze, }
309+
marker: marker::NoFreeze,
310+
marker1: marker::NoShare, }
306311
}
307312

308313
}
309314

310-
impl<T:Freeze + Send> RWArc<T> {
315+
impl<T: Share + Send> RWArc<T> {
311316
/// Create a reader/writer Arc with the supplied data.
312317
pub fn new(user_data: T) -> RWArc<T> {
313318
RWArc::new_with_condvars(user_data, 1)
@@ -323,7 +328,8 @@ impl<T:Freeze + Send> RWArc<T> {
323328
failed: false, data: user_data
324329
};
325330
RWArc { x: UnsafeArc::new(data),
326-
marker: marker::NoFreeze, }
331+
marker: marker::NoFreeze,
332+
marker1: marker::NoShare, }
327333
}
328334

329335
/**
@@ -454,7 +460,7 @@ impl<T:Freeze + Send> RWArc<T> {
454460
// lock it. This wraps the unsafety, with the justification that the 'lock'
455461
// field is never overwritten; only 'failed' and 'data'.
456462
#[doc(hidden)]
457-
fn borrow_rwlock<T:Freeze + Send>(state: *mut RWArcInner<T>) -> *RWLock {
463+
fn borrow_rwlock<T: Share + Send>(state: *mut RWArcInner<T>) -> *RWLock {
458464
unsafe { cast::transmute(&(*state).lock) }
459465
}
460466

@@ -471,7 +477,7 @@ pub struct RWReadMode<'a, T> {
471477
priv token: sync::RWLockReadMode<'a>,
472478
}
473479

474-
impl<'a, T:Freeze + Send> RWWriteMode<'a, T> {
480+
impl<'a, T: Share + Send> RWWriteMode<'a, T> {
475481
/// Access the pre-downgrade RWArc in write mode.
476482
pub fn write<U>(&mut self, blk: |x: &mut T| -> U) -> U {
477483
match *self {
@@ -510,7 +516,7 @@ impl<'a, T:Freeze + Send> RWWriteMode<'a, T> {
510516
}
511517
}
512518

513-
impl<'a, T:Freeze + Send> RWReadMode<'a, T> {
519+
impl<'a, T: Share + Send> RWReadMode<'a, T> {
514520
/// Access the post-downgrade rwlock in read mode.
515521
pub fn read<U>(&self, blk: |x: &T| -> U) -> U {
516522
match *self {
@@ -534,7 +540,7 @@ pub struct CowArc<T> { priv x: UnsafeArc<T> }
534540
/// mutation of the contents if there is only a single reference to
535541
/// the data. If there are multiple references the data is automatically
536542
/// cloned and the task modifies the cloned data in place of the shared data.
537-
impl<T:Clone+Send+Freeze> CowArc<T> {
543+
impl<T: Clone + Send + Share> CowArc<T> {
538544
/// Create a copy-on-write atomically reference counted wrapper
539545
#[inline]
540546
pub fn new(data: T) -> CowArc<T> {
@@ -558,7 +564,7 @@ impl<T:Clone+Send+Freeze> CowArc<T> {
558564
}
559565
}
560566

561-
impl<T:Clone+Send+Freeze> Clone for CowArc<T> {
567+
impl<T: Clone + Send + Share> Clone for CowArc<T> {
562568
/// Duplicate a Copy-on-write Arc. See arc::clone for more details.
563569
fn clone(&self) -> CowArc<T> {
564570
CowArc { x: self.x.clone() }

src/libsyntax/ast.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1159,12 +1159,12 @@ mod test {
11591159

11601160
use std::vec_ng::Vec;
11611161

1162-
fn is_freeze<T: Freeze>() {}
1162+
fn is_share<T: Share>() {}
11631163

1164-
// Assert that the AST remains Freeze (#10693).
1164+
// Assert that the AST remains sharable.
11651165
#[test]
1166-
fn ast_is_freeze() {
1167-
is_freeze::<Item>();
1166+
fn ast_is_share() {
1167+
is_share::<Item>();
11681168
}
11691169

11701170
// are ASTs encodable?

src/libsyntax/util/interner.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ use std::hash::Hash;
2323
use std::rc::Rc;
2424
use std::vec_ng::Vec;
2525

26+
#[cfg(stage0)]
27+
use std::kinds::Share;
28+
2629
pub struct Interner<T> {
2730
priv map: RefCell<HashMap<T, Name>>,
2831
priv vect: RefCell<Vec<T> >,
2932
}
3033

3134
// when traits can extend traits, we should extend index<Name,T> to get []
32-
impl<T:Eq + Hash + Freeze + Clone + 'static> Interner<T> {
35+
impl<T: Eq + Hash + Share + Clone + 'static> Interner<T> {
3336
pub fn new() -> Interner<T> {
3437
Interner {
3538
map: RefCell::new(HashMap::new()),

src/test/auxiliary/issue-2526.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ struct arc_destruct<T> {
1616
}
1717

1818
#[unsafe_destructor]
19-
impl<T:Freeze> Drop for arc_destruct<T> {
19+
impl<T: Share> Drop for arc_destruct<T> {
2020
fn drop(&mut self) {}
2121
}
2222

23-
fn arc_destruct<T:Freeze>(data: int) -> arc_destruct<T> {
23+
fn arc_destruct<T: Share>(data: int) -> arc_destruct<T> {
2424
arc_destruct {
2525
_data: data
2626
}
2727
}
2828

29-
fn arc<T:Freeze>(_data: T) -> arc_destruct<T> {
29+
fn arc<T: Share>(_data: T) -> arc_destruct<T> {
3030
arc_destruct(0)
3131
}
3232

src/test/compile-fail/builtin-superkinds-double-superkind.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
// Test for traits that inherit from multiple builtin kinds at once,
1212
// testing that all such kinds must be present on implementing types.
1313

14-
trait Foo : Send+Freeze { }
14+
trait Foo : Send+Share { }
1515

16-
impl <T: Freeze> Foo for (T,) { } //~ ERROR cannot implement this trait
16+
impl <T: Share> Foo for (T,) { } //~ ERROR cannot implement this trait
1717

1818
impl <T: Send> Foo for (T,T) { } //~ ERROR cannot implement this trait
1919

20-
impl <T: Send+Freeze> Foo for (T,T,T) { } // (ok)
20+
impl <T: Send+Share> Foo for (T,T,T) { } // (ok)
2121

2222
fn main() { }

src/test/compile-fail/builtin-superkinds-self-type.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
// Tests (negatively) the ability for the Self type in default methods
1212
// to use capabilities granted by builtin kinds as supertraits.
1313

14-
trait Foo : Freeze {
14+
trait Foo : Share {
1515
fn foo(self, mut chan: Sender<Self>) {
1616
chan.send(self); //~ ERROR does not fulfill `Send`
1717
}
1818
}
1919

20-
impl <T: Freeze> Foo for T { }
20+
impl <T: Share> Foo for T { }
2121

2222
fn main() {
2323
let (tx, rx) = channel();

src/test/compile-fail/builtin-superkinds-typaram-not-send.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212

1313
trait Foo : Send { }
1414

15-
impl <T: Freeze> Foo for T { } //~ ERROR cannot implement this trait
15+
impl <T: Share> Foo for T { } //~ ERROR cannot implement this trait
1616

1717
fn main() { }

src/test/compile-fail/cant-implement-builtin-kinds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ struct X<T>(T);
1414

1515
impl <T> Send for X<T> { } //~ ERROR cannot provide an explicit implementation for a builtin kind
1616
impl <T> Sized for X<T> { } //~ ERROR cannot provide an explicit implementation for a builtin kind
17-
impl <T> Freeze for X<T> { } //~ ERROR cannot provide an explicit implementation for a builtin kind
17+
impl <T> Share for X<T> { } //~ ERROR cannot provide an explicit implementation for a builtin kind
1818

1919
fn main() { }

src/test/compile-fail/comm-not-freeze.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn test<T: Freeze>() {}
11+
fn test<T: Share>() {}
1212

1313
fn main() {
14-
test::<Sender<int>>(); //~ ERROR: does not fulfill `Freeze`
15-
test::<Receiver<int>>(); //~ ERROR: does not fulfill `Freeze`
16-
test::<Sender<int>>(); //~ ERROR: does not fulfill `Freeze`
14+
test::<Sender<int>>(); //~ ERROR: does not fulfill `Share`
15+
test::<Receiver<int>>(); //~ ERROR: does not fulfill `Share`
16+
test::<Sender<int>>(); //~ ERROR: does not fulfill `Share`
1717
}

src/test/compile-fail/issue-2611-4.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct E {
2020
}
2121

2222
impl A for E {
23-
fn b<F:Freeze,G>(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Freeze`
23+
fn b<F: Share, G>(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Share`
2424
}
2525

2626
fn main() {}

src/test/compile-fail/marker-no-freeze.rs renamed to src/test/compile-fail/marker-no-share.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
use std::kinds::marker;
1212

13-
fn foo<P:Freeze>(p: P) { }
13+
fn foo<P: Share>(p: P) { }
1414

1515
fn main()
1616
{
17-
foo(marker::NoFreeze); //~ ERROR does not fulfill `Freeze`
17+
foo(marker::NoShare); //~ ERROR does not fulfill `Share`
1818
}

src/test/compile-fail/mut-not-freeze.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
use std::cell::RefCell;
1212

13-
fn f<T: Freeze>(_: T) {}
13+
fn f<T: Share>(_: T) {}
1414

1515
fn main() {
1616
let x = RefCell::new(0);
17-
f(x); //~ ERROR: which does not fulfill `Freeze`
17+
f(x); //~ ERROR: which does not fulfill `Share`
1818
}

src/test/compile-fail/no_freeze-enum.rs renamed to src/test/compile-fail/no_share-enum.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
use std::kinds::marker;
1212

13-
enum Foo { A(marker::NoFreeze) }
13+
enum Foo { A(marker::NoShare) }
1414

15-
fn bar<T: Freeze>(_: T) {}
15+
fn bar<T: Share>(_: T) {}
1616

1717
fn main() {
18-
let x = A(marker::NoFreeze);
18+
let x = A(marker::NoShare);
1919
bar(x);
2020
//~^ ERROR instantiating a type parameter with an incompatible type `Foo`,
21-
// which does not fulfill `Freeze`
21+
// which does not fulfill `Share`
2222
}

src/test/compile-fail/no_freeze-rc.rs renamed to src/test/compile-fail/no_share-rc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
use std::rc::Rc;
1212
use std::cell::RefCell;
1313

14-
fn bar<T: Freeze>(_: T) {}
14+
fn bar<T: Share>(_: T) {}
1515

1616
fn main() {
1717
let x = Rc::new(RefCell::new(5));
1818
bar(x);
1919
//~^ ERROR instantiating a type parameter with an incompatible type
20-
// `std::rc::Rc<std::cell::RefCell<int>>`, which does not fulfill `Freeze`
20+
// `std::rc::Rc<std::cell::RefCell<int>>`, which does not fulfill `Share`
2121
}

src/test/compile-fail/no_freeze-struct.rs renamed to src/test/compile-fail/no_share-struct.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
use std::kinds::marker;
1212

13-
struct Foo { a: int, m: marker::NoFreeze }
13+
struct Foo { a: int, m: marker::NoShare }
1414

15-
fn bar<T: Freeze>(_: T) {}
15+
fn bar<T: Share>(_: T) {}
1616

1717
fn main() {
18-
let x = Foo { a: 5, m: marker::NoFreeze };
18+
let x = Foo { a: 5, m: marker::NoShare };
1919
bar(x);
2020
//~^ ERROR instantiating a type parameter with an incompatible type `Foo`,
21-
// which does not fulfill `Freeze`
21+
// which does not fulfill `Share`
2222
}

src/test/run-pass/const-bound.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// are const.
1313

1414

15-
fn foo<T:Freeze>(x: T) -> T { x }
15+
fn foo<T: Share>(x: T) -> T { x }
1616

1717
struct F { field: int }
1818

src/test/run-pass/issue-2611-3.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// than the traits require.
1313

1414
trait A {
15-
fn b<C:Freeze,D>(x: C) -> C;
15+
fn b<C:Share,D>(x: C) -> C;
1616
}
1717

1818
struct E {

src/test/run-pass/trait-bounds-in-arc.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ pub fn main() {
6565
let dogge1 = Dogge { bark_decibels: 100, tricks_known: 42, name: ~"alan_turing" };
6666
let dogge2 = Dogge { bark_decibels: 55, tricks_known: 11, name: ~"albert_einstein" };
6767
let fishe = Goldfyshe { swim_speed: 998, name: ~"alec_guinness" };
68-
let arc = Arc::new(~[~catte as ~Pet:Freeze+Send,
69-
~dogge1 as ~Pet:Freeze+Send,
70-
~fishe as ~Pet:Freeze+Send,
71-
~dogge2 as ~Pet:Freeze+Send]);
68+
let arc = Arc::new(~[~catte as ~Pet:Share+Send,
69+
~dogge1 as ~Pet:Share+Send,
70+
~fishe as ~Pet:Share+Send,
71+
~dogge2 as ~Pet:Share+Send]);
7272
let (tx1, rx1) = channel();
7373
let arc1 = arc.clone();
7474
task::spawn(proc() { check_legs(arc1); tx1.send(()); });
@@ -83,21 +83,21 @@ pub fn main() {
8383
rx3.recv();
8484
}
8585

86-
fn check_legs(arc: Arc<~[~Pet:Freeze+Send]>) {
86+
fn check_legs(arc: Arc<~[~Pet:Share+Send]>) {
8787
let mut legs = 0;
8888
for pet in arc.get().iter() {
8989
legs += pet.num_legs();
9090
}
9191
assert!(legs == 12);
9292
}
93-
fn check_names(arc: Arc<~[~Pet:Freeze+Send]>) {
93+
fn check_names(arc: Arc<~[~Pet:Share+Send]>) {
9494
for pet in arc.get().iter() {
9595
pet.name(|name| {
9696
assert!(name[0] == 'a' as u8 && name[1] == 'l' as u8);
9797
})
9898
}
9999
}
100-
fn check_pedigree(arc: Arc<~[~Pet:Freeze+Send]>) {
100+
fn check_pedigree(arc: Arc<~[~Pet:Share+Send]>) {
101101
for pet in arc.get().iter() {
102102
assert!(pet.of_good_pedigree());
103103
}

0 commit comments

Comments
 (0)