Replace Freeze bounds with Share bounds

This commit is contained in:
Flavio Percoco 2014-03-07 18:57:35 +01:00
parent 21d23ff25b
commit 12ecafb31d
18 changed files with 63 additions and 54 deletions

View 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)
}

View file

@ -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 <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() { }

View file

@ -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<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();

View 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() { }

View file

@ -14,6 +14,6 @@ struct X<T>(T);
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() { }

View 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`
}

View 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() {}

View file

@ -10,9 +10,9 @@
use std::kinds::marker;
fn foo<P:Freeze>(p: P) { }
fn foo<P: Share>(p: P) { }
fn main()
{
foo(marker::NoFreeze); //~ ERROR does not fulfill `Freeze`
foo(marker::NoShare); //~ ERROR does not fulfill `Share`
}

View 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`
}

View file

@ -10,13 +10,13 @@
use std::kinds::marker;
enum Foo { A(marker::NoFreeze) }
enum Foo { A(marker::NoShare) }
fn bar<T: Freeze>(_: T) {}
fn bar<T: Share>(_: 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`
}

View file

@ -11,11 +11,11 @@
use std::rc::Rc;
use std::cell::RefCell;
fn bar<T: Freeze>(_: T) {}
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 `Freeze`
// `std::rc::Rc<std::cell::RefCell<int>>`, which does not fulfill `Share`
}

View file

@ -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: Freeze>(_: T) {}
fn bar<T: Share>(_: 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`
}

View 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 }

View 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 {

View 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());
}