auto merge of #16285 : alexcrichton/rust/rename-share, r=huonw

This leaves the `Share` trait at `std::kinds` via a `#[deprecated]` `pub use`
statement, but the `NoShare` struct is no longer part of `std::kinds::marker`
due to #12660 (the build cannot bootstrap otherwise).

All code referencing the `Share` trait should now reference the `Sync` trait,
and all code referencing the `NoShare` type should now reference the `NoSync`
type. The functionality and meaning of this trait have not changed, only the
naming.

Closes #16281
[breaking-change]
This commit is contained in:
bors 2014-08-08 03:51:15 +00:00
commit aae7901a78
59 changed files with 199 additions and 190 deletions

View file

@ -18,17 +18,17 @@ struct arc_destruct<T> {
}
#[unsafe_destructor]
impl<T: Share> Drop for arc_destruct<T> {
impl<T: Sync> Drop for arc_destruct<T> {
fn drop(&mut self) {}
}
fn arc_destruct<T: Share>(data: int) -> arc_destruct<T> {
fn arc_destruct<T: Sync>(data: int) -> arc_destruct<T> {
arc_destruct {
_data: data
}
}
fn arc<T: Share>(_data: T) -> arc_destruct<T> {
fn arc<T: Sync>(_data: T) -> arc_destruct<T> {
arc_destruct(0)
}

View file

@ -13,6 +13,6 @@
#![crate_type="lib"]
pub trait RequiresShare : Share { }
pub trait RequiresShare : Sync { }
pub trait RequiresRequiresShareAndSend : RequiresShare + Send { }
pub trait RequiresCopy : Copy { }

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+Share { }
trait Foo : Send+Sync { }
impl <T: Share> Foo for (T,) { } //~ ERROR cannot implement this trait
impl <T: Sync> Foo for (T,) { } //~ ERROR cannot implement this trait
impl <T: Send> Foo for (T,T) { } //~ ERROR cannot implement this trait
impl <T: Send+Share> Foo for (T,T,T) { } // (ok)
impl <T: Send+Sync> Foo for (T,T,T) { } // (ok)
fn main() { }

View file

@ -19,8 +19,8 @@ use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare};
struct X<T>(T);
impl <T:Share> RequiresShare for X<T> { }
impl <T:Sync> RequiresShare for X<T> { }
impl <T:Share> RequiresRequiresShareAndSend for X<T> { } //~ ERROR cannot implement this trait
impl <T:Sync> RequiresRequiresShareAndSend for X<T> { } //~ ERROR cannot implement this trait
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 : Share {
trait Foo : Sync {
fn foo(self, mut chan: Sender<Self>) {
chan.send(self); //~ ERROR does not fulfill `Send`
}
}
impl <T: Share> Foo for T { }
impl <T: Sync> Foo for T { }
fn main() {
let (tx, rx) = channel();

View file

@ -12,6 +12,6 @@
trait Foo : Send { }
impl <T: Share> Foo for T { } //~ ERROR cannot implement this trait
impl <T: Sync> Foo for T { } //~ ERROR cannot implement this trait
fn main() { }

View file

@ -12,7 +12,7 @@
fn take_any(_: ||:) {
}
fn take_const_owned(_: ||:Share+Send) {
fn take_const_owned(_: ||:Sync+Send) {
}
fn give_any(f: ||:) {
@ -21,7 +21,7 @@ fn give_any(f: ||:) {
fn give_owned(f: ||:Send) {
take_any(f);
take_const_owned(f); //~ ERROR expected bounds `Send+Share` but found bounds `Send`
take_const_owned(f); //~ ERROR expected bounds `Send+Sync` but found bounds `Send`
}
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: Share>() {}
fn test<T: Sync>() {}
fn main() {
test::<Sender<int>>(); //~ ERROR: does not fulfill `Share`
test::<Receiver<int>>(); //~ ERROR: does not fulfill `Share`
test::<Sender<int>>(); //~ ERROR: does not fulfill `Share`
test::<Sender<int>>(); //~ ERROR: does not fulfill `Sync`
test::<Receiver<int>>(); //~ ERROR: does not fulfill `Sync`
test::<Sender<int>>(); //~ ERROR: does not fulfill `Sync`
}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Share(Bad),Send,Copy)]
#[deriving(Sync(Bad),Send,Copy)]
//~^ ERROR unexpected value in deriving, expected a trait
struct Test;

View file

@ -20,7 +20,7 @@ struct E {
}
impl A for E {
fn b<F: Share, G>(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Share`
fn b<F: Sync, G>(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Sync`
}
fn main() {}

View file

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

View file

@ -10,9 +10,9 @@
use std::cell::RefCell;
fn f<T: Share>(_: T) {}
fn f<T: Sync>(_: T) {}
fn main() {
let x = RefCell::new(0i);
f(x); //~ ERROR: which does not fulfill `Share`
f(x); //~ ERROR: which does not fulfill `Sync`
}

View file

@ -13,11 +13,11 @@
use std::kinds::marker;
enum Foo { A(marker::NoShare) }
enum Foo { A(marker::NoSync) }
fn bar<T: Share>(_: T) {}
fn bar<T: Sync>(_: T) {}
fn main() {
let x = A(marker::NoShare);
let x = A(marker::NoSync);
bar(&x); //~ ERROR type parameter with an incompatible type
}

View file

@ -10,13 +10,13 @@
use std::kinds::marker;
enum Foo { A(marker::NoShare) }
enum Foo { A(marker::NoSync) }
fn bar<T: Share>(_: T) {}
fn bar<T: Sync>(_: T) {}
fn main() {
let x = A(marker::NoShare);
let x = A(marker::NoSync);
bar(x);
//~^ ERROR instantiating a type parameter with an incompatible type `Foo`,
// which does not fulfill `Share`
// which does not fulfill `Sync`
}

View file

@ -11,11 +11,11 @@
use std::rc::Rc;
use std::cell::RefCell;
fn bar<T: Share>(_: T) {}
fn bar<T: Sync>(_: T) {}
fn main() {
let x = Rc::new(RefCell::new(5i));
bar(x);
//~^ ERROR instantiating a type parameter with an incompatible type
// `std::rc::Rc<std::cell::RefCell<int>>`, which does not fulfill `Share`
// `std::rc::Rc<std::cell::RefCell<int>>`, which does not fulfill `Sync`
}

View file

@ -10,13 +10,13 @@
use std::kinds::marker;
struct Foo { a: int, m: marker::NoShare }
struct Foo { a: int, m: marker::NoSync }
fn bar<T: Share>(_: T) {}
fn bar<T: Sync>(_: T) {}
fn main() {
let x = Foo { a: 5, m: marker::NoShare };
let x = Foo { a: 5, m: marker::NoSync };
bar(x);
//~^ ERROR instantiating a type parameter with an incompatible type `Foo`,
// which does not fulfill `Share`
// which does not fulfill `Sync`
}

View file

@ -9,7 +9,7 @@
// except according to those terms.
fn is_send<T: Send>() {}
fn is_freeze<T: Share>() {}
fn is_freeze<T: Sync>() {}
fn is_static<T: 'static>() {}
fn main() {

View file

@ -15,7 +15,7 @@ trait Foo {
fn a(_x: Box<Foo+Send>) {
}
fn c(x: Box<Foo+Share+Send>) {
fn c(x: Box<Foo+Sync+Send>) {
a(x);
}

View file

@ -19,11 +19,11 @@ fn a(_x: Box<Foo+Send>) {
fn b(_x: &'static Foo) { // should be same as &'static Foo+'static
}
fn c(x: Box<Foo+Share>) {
fn c(x: Box<Foo+Sync>) {
a(x); //~ ERROR expected bounds `Send`
}
fn d(x: &'static Foo+Share) {
fn d(x: &'static Foo+Sync) {
b(x); //~ ERROR expected bounds `'static`
}

View file

@ -8,36 +8,36 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Verify that UnsafeCell is *always* share regardles `T` is share.
// Verify that UnsafeCell is *always* sync regardles `T` is sync.
// ignore-tidy-linelength
use std::cell::UnsafeCell;
use std::kinds::marker;
struct MyShare<T> {
struct MySync<T> {
u: UnsafeCell<T>
}
struct NoShare {
m: marker::NoShare
struct NoSync {
m: marker::NoSync
}
fn test<T: Share>(s: T){
fn test<T: Sync>(s: T){
}
fn main() {
let us = UnsafeCell::new(MyShare{u: UnsafeCell::new(0i)});
let us = UnsafeCell::new(MySync{u: UnsafeCell::new(0i)});
test(us);
let uns = UnsafeCell::new(NoShare{m: marker::NoShare});
let uns = UnsafeCell::new(NoSync{m: marker::NoSync});
test(uns);
let ms = MyShare{u: uns};
let ms = MySync{u: uns};
test(ms);
let ns = NoShare{m: marker::NoShare};
let ns = NoSync{m: marker::NoSync};
test(ns);
//~^ ERROR instantiating a type parameter with an incompatible type `NoShare`, which does not fulfill `Share`
//~^ ERROR instantiating a type parameter with an incompatible type `NoSync`, which does not fulfill `Sync`
}

View file

@ -14,11 +14,11 @@
trait Tr { }
impl Tr for int { }
fn foo(x: Box<Tr+ Share>) -> Box<Tr+ Share> { x }
fn foo(x: Box<Tr+ Sync>) -> Box<Tr+ Sync> { x }
fn main() {
let x: Box<Tr+ Share>;
let x: Box<Tr+ Sync>;
box() 1i as Box<Tr+ Share>;
box() 1i as Box<Tr+ Sync>;
}

View file

@ -20,8 +20,8 @@ use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare};
#[deriving(PartialEq)]
struct X<T>(T);
impl <T: Share> RequiresShare for X<T> { }
impl <T: Share+Send> RequiresRequiresShareAndSend for X<T> { }
impl <T: Sync> RequiresShare for X<T> { }
impl <T: Sync+Send> RequiresRequiresShareAndSend for X<T> { }
fn foo<T: RequiresRequiresShareAndSend>(val: T, chan: Sender<T>) {
chan.send(val);

View file

@ -19,9 +19,9 @@ use trait_superkinds_in_metadata::{RequiresCopy};
struct X<T>(T);
impl <T:Share> RequiresShare for X<T> { }
impl <T:Sync> RequiresShare for X<T> { }
impl <T:Share+Send> RequiresRequiresShareAndSend for X<T> { }
impl <T:Sync+Send> RequiresRequiresShareAndSend for X<T> { }
impl <T:Copy> RequiresCopy for X<T> { }

View file

@ -28,11 +28,11 @@ struct Foo<'a> {
a: ||: 'a,
b: ||: 'static,
c: <'b>||: 'a,
d: ||: 'a + Share,
e: <'b>|int|: 'a + Share -> &'b f32,
d: ||: 'a + Sync,
e: <'b>|int|: 'a + Sync -> &'b f32,
f: proc(),
g: proc(): 'static + Share,
h: proc<'b>(int): Share -> &'b f32,
g: proc(): 'static + Sync,
h: proc<'b>(int): Sync -> &'b f32,
}
fn f<'a>(a: &'a int, f: <'b>|&'b int| -> &'b int) -> &'a int {
@ -54,14 +54,14 @@ fn bar<'b>() {
foo::<|| -> ()>();
foo::<||:>();
foo::<||:'b>();
foo::<||:'b + Share>();
foo::<||:Share>();
foo::< <'a>|int, f32, &'a int|:'b + Share -> &'a int>();
foo::<||:'b + Sync>();
foo::<||:Sync>();
foo::< <'a>|int, f32, &'a int|:'b + Sync -> &'a int>();
foo::<proc()>();
foo::<proc() -> ()>();
foo::<proc():'static>();
foo::<proc():Share>();
foo::<proc<'a>(int, f32, &'a int):'static + Share -> &'a int>();
foo::<proc():Sync>();
foo::<proc<'a>(int, f32, &'a int):'static + Sync -> &'a int>();
foo::<<'a>||>();

View file

@ -12,7 +12,7 @@
// are const.
fn foo<T: Share>(x: T) -> T { x }
fn foo<T: Sync>(x: T) -> T { x }
struct F { field: int }

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Share,Send,Copy)]
#[deriving(Sync,Send,Copy)]
struct Test;
pub fn main() {}

View file

@ -12,7 +12,7 @@
// than the traits require.
trait A {
fn b<C:Share,D>(x: C) -> C;
fn b<C:Sync,D>(x: C) -> C;
}
struct E {

View file

@ -20,7 +20,7 @@ mod foo {
}
fn foo1<T>(_: &A<T> + Send) {}
fn foo2<T>(_: Box<A<T> + Send + Share>) {}
fn foo2<T>(_: Box<A<T> + Send + Sync>) {}
fn foo3<T>(_: Box<B<int, uint> + 'static>) {}
fn foo4<'a, T>(_: Box<C<'a, T> + 'static + Send>) {}
fn foo5<'a, T>(_: Box<foo::D<'a, T> + 'static + Send>) {}

View file

@ -12,18 +12,18 @@ fn foo<T>() {}
fn bar<T>(_: T) {}
fn is_send<T: Send>() {}
fn is_freeze<T: Share>() {}
fn is_freeze<T: Sync>() {}
fn is_static<T: 'static>() {}
pub fn main() {
foo::<proc()>();
foo::<proc()>();
foo::<proc():Send>();
foo::<proc():Send + Share>();
foo::<proc():'static + Send + Share>();
foo::<proc():Send + Sync>();
foo::<proc():'static + Send + Sync>();
is_send::<proc():Send>();
is_freeze::<proc():Share>();
is_freeze::<proc():Sync>();
is_static::<proc():'static>();

View file

@ -15,7 +15,7 @@ trait Foo {
fn b(_x: Box<Foo+Send>) {
}
fn c(x: Box<Foo+Share+Send>) {
fn c(x: Box<Foo+Sync+Send>) {
e(x);
}

View file

@ -71,10 +71,10 @@ pub fn main() {
swim_speed: 998,
name: "alec_guinness".to_string(),
};
let arc = Arc::new(vec!(box catte as Box<Pet+Share+Send>,
box dogge1 as Box<Pet+Share+Send>,
box fishe as Box<Pet+Share+Send>,
box dogge2 as Box<Pet+Share+Send>));
let arc = Arc::new(vec!(box catte as Box<Pet+Sync+Send>,
box dogge1 as Box<Pet+Sync+Send>,
box fishe as Box<Pet+Sync+Send>,
box dogge2 as Box<Pet+Sync+Send>));
let (tx1, rx1) = channel();
let arc1 = arc.clone();
task::spawn(proc() { check_legs(arc1); tx1.send(()); });
@ -89,21 +89,21 @@ pub fn main() {
rx3.recv();
}
fn check_legs(arc: Arc<Vec<Box<Pet+Share+Send>>>) {
fn check_legs(arc: Arc<Vec<Box<Pet+Sync+Send>>>) {
let mut legs = 0;
for pet in arc.iter() {
legs += pet.num_legs();
}
assert!(legs == 12);
}
fn check_names(arc: Arc<Vec<Box<Pet+Share+Send>>>) {
fn check_names(arc: Arc<Vec<Box<Pet+Sync+Send>>>) {
for pet in arc.iter() {
pet.name(|name| {
assert!(name.as_bytes()[0] == 'a' as u8 && name.as_bytes()[1] == 'l' as u8);
})
}
}
fn check_pedigree(arc: Arc<Vec<Box<Pet+Share+Send>>>) {
fn check_pedigree(arc: Arc<Vec<Box<Pet+Sync+Send>>>) {
for pet in arc.iter() {
assert!(pet.of_good_pedigree());
}