diff --git a/src/libextra/arc.rs b/src/libextra/arc.rs index 15c24052563b4..a65beeef6f8e9 100644 --- a/src/libextra/arc.rs +++ b/src/libextra/arc.rs @@ -113,7 +113,7 @@ impl<'self> Condvar<'self> { pub struct ARC { x: UnsafeAtomicRcBox } /// Create an atomically reference counted wrapper. -pub fn ARC(data: T) -> ARC { +pub fn ARC(data: T) -> ARC { ARC { x: UnsafeAtomicRcBox::new(data) } } @@ -121,7 +121,7 @@ pub fn ARC(data: T) -> ARC { * Access the underlying data in an atomically reference counted * wrapper. */ -impl ARC { +impl ARC { pub fn get<'a>(&'a self) -> &'a T { unsafe { &*self.x.get_immut() } } @@ -134,7 +134,7 @@ impl ARC { * object. However, one of the `arc` objects can be sent to another task, * allowing them to share the underlying data. */ -impl Clone for ARC { +impl Clone for ARC { fn clone(&self) -> ARC { ARC { x: self.x.clone() } } @@ -150,14 +150,14 @@ struct MutexARCInner { lock: Mutex, failed: bool, data: T } struct MutexARC { x: UnsafeAtomicRcBox> } /// Create a mutex-protected ARC with the supplied data. -pub fn MutexARC(user_data: T) -> MutexARC { +pub fn MutexARC(user_data: T) -> MutexARC { mutex_arc_with_condvars(user_data, 1) } /** * Create a mutex-protected ARC with the supplied data and a specified number * of condvars (as sync::mutex_with_condvars). */ -pub fn mutex_arc_with_condvars(user_data: T, +pub fn mutex_arc_with_condvars(user_data: T, num_condvars: uint) -> MutexARC { let data = MutexARCInner { lock: mutex_with_condvars(num_condvars), @@ -165,7 +165,7 @@ pub fn mutex_arc_with_condvars(user_data: T, MutexARC { x: UnsafeAtomicRcBox::new(data) } } -impl Clone for MutexARC { +impl Clone for MutexARC { /// Duplicate a mutex-protected ARC, as arc::clone. fn clone(&self) -> MutexARC { // NB: Cloning the underlying mutex is not necessary. Its reference @@ -174,7 +174,7 @@ impl Clone for MutexARC { } } -impl MutexARC { +impl MutexARC { /** * Access the underlying mutable data with mutual exclusion from other @@ -286,14 +286,14 @@ struct RWARC { } /// Create a reader/writer ARC with the supplied data. -pub fn RWARC(user_data: T) -> RWARC { +pub fn RWARC(user_data: T) -> RWARC { rw_arc_with_condvars(user_data, 1) } /** * Create a reader/writer ARC with the supplied data and a specified number * of condvars (as sync::rwlock_with_condvars). */ -pub fn rw_arc_with_condvars( +pub fn rw_arc_with_condvars( user_data: T, num_condvars: uint) -> RWARC { @@ -303,7 +303,7 @@ pub fn rw_arc_with_condvars( RWARC { x: UnsafeAtomicRcBox::new(data), cant_nest: () } } -impl RWARC { +impl RWARC { /// Duplicate a rwlock-protected ARC, as arc::clone. pub fn clone(&self) -> RWARC { RWARC { @@ -314,7 +314,7 @@ impl RWARC { } -impl RWARC { +impl RWARC { /** * Access the underlying data mutably. Locks the rwlock in write mode; * other readers and writers will block. @@ -440,7 +440,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: *const RWARCInner) -> *RWlock { +fn borrow_rwlock(state: *const RWARCInner) -> *RWlock { unsafe { cast::transmute(&const (*state).lock) } } @@ -457,7 +457,7 @@ pub struct RWReadMode<'self, T> { token: sync::RWlockReadMode<'self>, } -impl<'self, T:Const + Owned> RWWriteMode<'self, T> { +impl<'self, T:Freeze + Send> RWWriteMode<'self, T> { /// Access the pre-downgrade RWARC in write mode. pub fn write(&mut self, blk: &fn(x: &mut T) -> U) -> U { match *self { @@ -498,7 +498,7 @@ impl<'self, T:Const + Owned> RWWriteMode<'self, T> { } } -impl<'self, T:Const + Owned> RWReadMode<'self, T> { +impl<'self, T:Freeze + Send> RWReadMode<'self, T> { /// Access the post-downgrade rwlock in read mode. pub fn read(&self, blk: &fn(x: &T) -> U) -> U { match *self { diff --git a/src/libextra/comm.rs b/src/libextra/comm.rs index 1001d4f6ac9ed..2cb2128db5f73 100644 --- a/src/libextra/comm.rs +++ b/src/libextra/comm.rs @@ -30,7 +30,7 @@ pub struct DuplexStream { } // Allow these methods to be used without import: -impl DuplexStream { +impl DuplexStream { pub fn send(&self, x: T) { self.chan.send(x) } @@ -48,19 +48,19 @@ impl DuplexStream { } } -impl GenericChan for DuplexStream { +impl GenericChan for DuplexStream { fn send(&self, x: T) { self.chan.send(x) } } -impl GenericSmartChan for DuplexStream { +impl GenericSmartChan for DuplexStream { fn try_send(&self, x: T) -> bool { self.chan.try_send(x) } } -impl GenericPort for DuplexStream { +impl GenericPort for DuplexStream { fn recv(&self) -> U { self.port.recv() } @@ -70,20 +70,20 @@ impl GenericPort for DuplexStream { } } -impl Peekable for DuplexStream { +impl Peekable for DuplexStream { fn peek(&self) -> bool { self.port.peek() } } -impl Selectable for DuplexStream { +impl Selectable for DuplexStream { fn header(&mut self) -> *mut pipes::PacketHeader { self.port.header() } } /// Creates a bidirectional stream. -pub fn DuplexStream() +pub fn DuplexStream() -> (DuplexStream, DuplexStream) { let (p1, c2) = comm::stream(); diff --git a/src/libextra/flatpipes.rs b/src/libextra/flatpipes.rs index e8239b9f7fd75..82ce93cb62679 100644 --- a/src/libextra/flatpipes.rs +++ b/src/libextra/flatpipes.rs @@ -166,8 +166,8 @@ Constructors for flat pipes that send POD types using memcpy. # Safety Note -This module is currently unsafe because it uses `Copy Owned` as a type -parameter bounds meaning POD (plain old data), but `Copy Owned` and +This module is currently unsafe because it uses `Copy Send` as a type +parameter bounds meaning POD (plain old data), but `Copy Send` and POD are not equivelant. */ @@ -191,7 +191,7 @@ pub mod pod { pub type PipeChan = FlatChan, PipeByteChan>; /// Create a `FlatPort` from a `Reader` - pub fn reader_port( + pub fn reader_port( reader: R ) -> ReaderPort { let unflat: PodUnflattener = PodUnflattener::new(); @@ -200,7 +200,7 @@ pub mod pod { } /// Create a `FlatChan` from a `Writer` - pub fn writer_chan( + pub fn writer_chan( writer: W ) -> WriterChan { let flat: PodFlattener = PodFlattener::new(); @@ -209,21 +209,21 @@ pub mod pod { } /// Create a `FlatPort` from a `Port<~[u8]>` - pub fn pipe_port(port: Port<~[u8]>) -> PipePort { + pub fn pipe_port(port: Port<~[u8]>) -> PipePort { let unflat: PodUnflattener = PodUnflattener::new(); let byte_port = PipeBytePort::new(port); FlatPort::new(unflat, byte_port) } /// Create a `FlatChan` from a `Chan<~[u8]>` - pub fn pipe_chan(chan: Chan<~[u8]>) -> PipeChan { + pub fn pipe_chan(chan: Chan<~[u8]>) -> PipeChan { let flat: PodFlattener = PodFlattener::new(); let byte_chan = PipeByteChan::new(chan); FlatChan::new(flat, byte_chan) } /// Create a pair of `FlatChan` and `FlatPort`, backed by pipes - pub fn pipe_stream() -> (PipePort, PipeChan) { + pub fn pipe_stream() -> (PipePort, PipeChan) { let (port, chan) = comm::stream(); return (pipe_port(port), pipe_chan(chan)); } @@ -352,7 +352,7 @@ pub mod flatteners { use core::sys::size_of; use core::vec; - // FIXME #4074: Copy + Owned != POD + // FIXME #4074: Copy + Send != POD pub struct PodUnflattener { bogus: () } @@ -361,7 +361,7 @@ pub mod flatteners { bogus: () } - impl Unflattener for PodUnflattener { + impl Unflattener for PodUnflattener { fn unflatten(&self, buf: ~[u8]) -> T { assert!(size_of::() != 0); assert_eq!(size_of::(), buf.len()); @@ -371,7 +371,7 @@ pub mod flatteners { } } - impl Flattener for PodFlattener { + impl Flattener for PodFlattener { fn flatten(&self, val: T) -> ~[u8] { assert!(size_of::() != 0); let val: *T = ptr::to_unsafe_ptr(&val); @@ -380,7 +380,7 @@ pub mod flatteners { } } - impl PodUnflattener { + impl PodUnflattener { pub fn new() -> PodUnflattener { PodUnflattener { bogus: () @@ -388,7 +388,7 @@ pub mod flatteners { } } - impl PodFlattener { + impl PodFlattener { pub fn new() -> PodFlattener { PodFlattener { bogus: () diff --git a/src/libextra/future.rs b/src/libextra/future.rs index 40cfeebd5dcd8..c231c8b0090a3 100644 --- a/src/libextra/future.rs +++ b/src/libextra/future.rs @@ -101,7 +101,7 @@ pub fn from_value(val: A) -> Future { Future {state: Forced(val)} } -pub fn from_port(port: PortOne) -> Future { +pub fn from_port(port: PortOne) -> Future { /*! * Create a future from a port * @@ -127,7 +127,7 @@ pub fn from_fn(f: ~fn() -> A) -> Future { Future {state: Pending(f)} } -pub fn spawn(blk: ~fn() -> A) -> Future { +pub fn spawn(blk: ~fn() -> A) -> Future { /*! * Create a future from a unique closure. * diff --git a/src/libextra/par.rs b/src/libextra/par.rs index 49696a5fa25c7..ace00f2b08afa 100644 --- a/src/libextra/par.rs +++ b/src/libextra/par.rs @@ -33,7 +33,7 @@ static min_granularity : uint = 1024u; * This is used to build most of the other parallel vector functions, * like map or alli. */ -fn map_slices( +fn map_slices( xs: &[A], f: &fn() -> ~fn(uint, v: &[A]) -> B) -> ~[B] { @@ -88,7 +88,7 @@ fn map_slices( } /// A parallel version of map. -pub fn map( +pub fn map( xs: &[A], fn_factory: &fn() -> ~fn(&A) -> B) -> ~[B] { vec::concat(map_slices(xs, || { let f = fn_factory(); @@ -99,7 +99,7 @@ pub fn map( } /// A parallel version of mapi. -pub fn mapi( +pub fn mapi( xs: &[A], fn_factory: &fn() -> ~fn(uint, &A) -> B) -> ~[B] { let slices = map_slices(xs, || { @@ -118,7 +118,7 @@ pub fn mapi( } /// Returns true if the function holds for all elements in the vector. -pub fn alli( +pub fn alli( xs: &[A], fn_factory: &fn() -> ~fn(uint, &A) -> bool) -> bool { @@ -134,7 +134,7 @@ pub fn alli( } /// Returns true if the function holds for any elements in the vector. -pub fn any( +pub fn any( xs: &[A], fn_factory: &fn() -> ~fn(&A) -> bool) -> bool { do vec::any(map_slices(xs, || { diff --git a/src/libextra/rc.rs b/src/libextra/rc.rs index 96ad629ea8374..e165bfa4ab697 100644 --- a/src/libextra/rc.rs +++ b/src/libextra/rc.rs @@ -13,10 +13,10 @@ /** Task-local reference counted smart pointers Task-local reference counted smart pointers are an alternative to managed boxes with deterministic -destruction. They are restricted to containing types that are either `Owned` or `Const` (or both) to +destruction. They are restricted to containing types that are either `Send` or `Freeze` (or both) to prevent cycles. -Neither `Rc` or `RcMut` is ever `Owned` and `RcMut` is never `Const`. If `T` is `Const`, a +Neither `Rc` or `RcMut` is ever `Send` and `RcMut` is never `Freeze`. If `T` is `Freeze`, a cycle cannot be created with `Rc` because there is no way to modify it after creation. */ @@ -36,6 +36,7 @@ struct RcBox { /// Immutable reference counted pointer type #[non_owned] +#[non_sendable] pub struct Rc { priv ptr: *mut RcBox, } @@ -50,12 +51,12 @@ impl Rc { } // FIXME: #6516: should be a static method -pub fn rc_from_owned(value: T) -> Rc { +pub fn rc_from_owned(value: T) -> Rc { unsafe { Rc::new(value) } } // FIXME: #6516: should be a static method -pub fn rc_from_const(value: T) -> Rc { +pub fn rc_from_const(value: T) -> Rc { unsafe { Rc::new(value) } } @@ -165,6 +166,7 @@ struct RcMutBox { /// Mutable reference counted pointer type #[non_owned] +#[non_sendable] #[mutable] pub struct RcMut { priv ptr: *mut RcMutBox, @@ -180,12 +182,12 @@ impl RcMut { } // FIXME: #6516: should be a static method -pub fn rc_mut_from_owned(value: T) -> RcMut { +pub fn rc_mut_from_owned(value: T) -> RcMut { unsafe { RcMut::new(value) } } // FIXME: #6516: should be a static method -pub fn rc_mut_from_const(value: T) -> RcMut { +pub fn rc_mut_from_const(value: T) -> RcMut { unsafe { RcMut::new(value) } } diff --git a/src/libextra/sync.rs b/src/libextra/sync.rs index 8f09ddea9ba78..03eefb061475c 100644 --- a/src/libextra/sync.rs +++ b/src/libextra/sync.rs @@ -85,7 +85,7 @@ struct SemInner { struct Sem(Exclusive>); #[doc(hidden)] -fn new_sem(count: int, q: Q) -> Sem { +fn new_sem(count: int, q: Q) -> Sem { Sem(exclusive(SemInner { count: count, waiters: new_waitqueue(), blocked: q })) } @@ -100,7 +100,7 @@ fn new_sem_and_signal(count: int, num_condvars: uint) } #[doc(hidden)] -impl Sem { +impl Sem { pub fn acquire(&self) { unsafe { let mut waiter_nobe = None; @@ -171,7 +171,7 @@ type SemAndSignalRelease<'self> = SemReleaseGeneric<'self, ~[Waitqueue]>; struct SemReleaseGeneric<'self, Q> { sem: &'self Sem } #[unsafe_destructor] -impl<'self, Q:Owned> Drop for SemReleaseGeneric<'self, Q> { +impl<'self, Q:Send> Drop for SemReleaseGeneric<'self, Q> { fn finalize(&self) { self.sem.release(); } diff --git a/src/libextra/timer.rs b/src/libextra/timer.rs index f251336666309..443e4e6320550 100644 --- a/src/libextra/timer.rs +++ b/src/libextra/timer.rs @@ -39,7 +39,7 @@ use core::libc; * * ch - a channel of type T to send a `val` on * * val - a value of type T to send over the provided `ch` */ -pub fn delayed_send(iotask: &IoTask, +pub fn delayed_send(iotask: &IoTask, msecs: uint, ch: &Chan, val: T) { @@ -119,7 +119,7 @@ pub fn sleep(iotask: &IoTask, msecs: uint) { * on the provided port in the allotted timeout period, then the result will * be a `Some(T)`. If not, then `None` will be returned. */ -pub fn recv_timeout(iotask: &IoTask, +pub fn recv_timeout(iotask: &IoTask, msecs: uint, wait_po: &Port) -> Option { diff --git a/src/libextra/workcache.rs b/src/libextra/workcache.rs index b2fd998b73fd2..0953aa5be8115 100644 --- a/src/libextra/workcache.rs +++ b/src/libextra/workcache.rs @@ -271,7 +271,7 @@ impl Context { } } - pub fn prep + Decodable>(@self, // FIXME(#5121) fn_name:&str, @@ -291,7 +291,7 @@ trait TPrep { fn declare_input(&mut self, kind:&str, name:&str, val:&str); fn is_fresh(&self, cat:&str, kind:&str, name:&str, val:&str) -> bool; fn all_fresh(&self, cat:&str, map:&WorkMap) -> bool; - fn exec + Decodable>( // FIXME(#5121) &self, blk: ~fn(&Exec) -> T) -> Work; @@ -327,7 +327,7 @@ impl TPrep for Prep { return true; } - fn exec + Decodable>( // FIXME(#5121) &self, blk: ~fn(&Exec) -> T) -> Work { @@ -364,7 +364,7 @@ impl TPrep for Prep { } } -impl + Decodable> Work { // FIXME(#5121) pub fn new(p: @mut Prep, e: Either>) -> Work { @@ -373,7 +373,7 @@ impl + Decodable>( // FIXME(#5121) w: Work) -> T { diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index bb35af198079d..8786b6dfb9e30 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -96,7 +96,7 @@ fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc { #[deriving(Eq)] enum Family { - Const, // c + Freeze, // c Fn, // f UnsafeFn, // u PureFn, // p @@ -121,7 +121,7 @@ enum Family { fn item_family(item: ebml::Doc) -> Family { let fam = reader::get_doc(item, tag_items_data_item_family); match reader::doc_as_u8(fam) as char { - 'c' => Const, + 'c' => Freeze, 'f' => Fn, 'u' => UnsafeFn, 'p' => PureFn, @@ -324,7 +324,7 @@ fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::crate_num) -> def_like { let fam = item_family(item); match fam { - Const => dl_def(ast::def_const(did)), + Freeze => dl_def(ast::def_const(did)), Struct => dl_def(ast::def_struct(did)), UnsafeFn => dl_def(ast::def_fn(did, ast::unsafe_fn)), Fn => dl_def(ast::def_fn(did, ast::impure_fn)), @@ -951,7 +951,7 @@ pub fn get_item_visibility(cdata: cmd, id: ast::node_id) fn family_has_type_params(fam: Family) -> bool { match fam { - Const | ForeignType | Mod | ForeignMod | PublicField | PrivateField + Freeze | ForeignType | Mod | ForeignMod | PublicField | PrivateField | ForeignFn => false, _ => true } @@ -981,7 +981,7 @@ fn describe_def(items: ebml::Doc, id: ast::def_id) -> ~str { fn item_family_to_str(fam: Family) -> ~str { match fam { - Const => ~"const", + Freeze => ~"const", Fn => ~"fn", UnsafeFn => ~"unsafe fn", PureFn => ~"pure fn", diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 33e033ace4835..ca6c825bca83c 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -558,13 +558,13 @@ fn parse_bounds(st: @mut PState, conv: conv_did) -> ty::ParamBounds { loop { match next(st) { 'S' => { - param_bounds.builtin_bounds.add(ty::BoundOwned); + param_bounds.builtin_bounds.add(ty::BoundSend); } 'C' => { param_bounds.builtin_bounds.add(ty::BoundCopy); } 'K' => { - param_bounds.builtin_bounds.add(ty::BoundConst); + param_bounds.builtin_bounds.add(ty::BoundFreeze); } 'O' => { param_bounds.builtin_bounds.add(ty::BoundStatic); diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index 947c68634148e..76cd695743764 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -399,9 +399,9 @@ fn enc_fn_sig(w: @io::Writer, cx: @ctxt, fsig: &ty::FnSig) { fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: &ty::ParamBounds) { for bs.builtin_bounds.each |bound| { match bound { - ty::BoundOwned => w.write_char('S'), + ty::BoundSend => w.write_char('S'), ty::BoundCopy => w.write_char('C'), - ty::BoundConst => w.write_char('K'), + ty::BoundFreeze => w.write_char('K'), ty::BoundStatic => w.write_char('O'), ty::BoundSized => w.write_char('Z'), } diff --git a/src/librustc/middle/borrowck/doc.rs b/src/librustc/middle/borrowck/doc.rs index cb3983117e97c..8bb5c4620ef78 100644 --- a/src/librustc/middle/borrowck/doc.rs +++ b/src/librustc/middle/borrowck/doc.rs @@ -359,7 +359,7 @@ of its owner: LIFETIME(LV.f, LT, MQ) // L-Field LIFETIME(LV, LT, MQ) - LIFETIME(*LV, LT, MQ) // L-Deref-Owned + LIFETIME(*LV, LT, MQ) // L-Deref-Send TYPE(LV) = ~Ty LIFETIME(LV, LT, MQ) @@ -504,7 +504,7 @@ must prevent the owned pointer `LV` from being mutated, which means that we always add `MUTATE` and `CLAIM` to the restriction set imposed on `LV`: - RESTRICTIONS(*LV, ACTIONS) = RS, (*LV, ACTIONS) // R-Deref-Owned-Pointer + RESTRICTIONS(*LV, ACTIONS) = RS, (*LV, ACTIONS) // R-Deref-Send-Pointer TYPE(LV) = ~Ty RESTRICTIONS(LV, ACTIONS|MUTATE|CLAIM) = RS @@ -539,14 +539,14 @@ mutable borrowed pointers. ### Restrictions for loans of const aliasable pointees -Const pointers are read-only. There may be `&mut` or `&` aliases, and +Freeze pointers are read-only. There may be `&mut` or `&` aliases, and we can not prevent *anything* but moves in that case. So the `RESTRICTIONS` function is only defined if `ACTIONS` is the empty set. Because moves from a `&const` or `@const` lvalue are never legal, it is not necessary to add any restrictions at all to the final result. - RESTRICTIONS(*LV, []) = [] // R-Deref-Const-Borrowed + RESTRICTIONS(*LV, []) = [] // R-Deref-Freeze-Borrowed TYPE(LV) = &const Ty or @const Ty ### Restrictions for loans of mutable borrowed pointees diff --git a/src/librustc/middle/borrowck/gather_loans/lifetime.rs b/src/librustc/middle/borrowck/gather_loans/lifetime.rs index 9455340268eff..131ee5aa067b4 100644 --- a/src/librustc/middle/borrowck/gather_loans/lifetime.rs +++ b/src/librustc/middle/borrowck/gather_loans/lifetime.rs @@ -109,7 +109,7 @@ impl GuaranteeLifetimeContext { } mc::cat_downcast(base) | - mc::cat_deref(base, _, mc::uniq_ptr(*)) | // L-Deref-Owned + mc::cat_deref(base, _, mc::uniq_ptr(*)) | // L-Deref-Send mc::cat_interior(base, _) => { // L-Field self.check(base, discr_scope) } diff --git a/src/librustc/middle/borrowck/gather_loans/restrictions.rs b/src/librustc/middle/borrowck/gather_loans/restrictions.rs index 6bd32f04ce5b9..659b69f0cf55a 100644 --- a/src/librustc/middle/borrowck/gather_loans/restrictions.rs +++ b/src/librustc/middle/borrowck/gather_loans/restrictions.rs @@ -103,7 +103,7 @@ impl RestrictionsContext { } mc::cat_deref(cmt_base, _, mc::uniq_ptr(*)) => { - // R-Deref-Owned-Pointer + // R-Deref-Send-Pointer // // When we borrow the interior of an owned pointer, we // cannot permit the base to be mutated, because that @@ -125,7 +125,7 @@ impl RestrictionsContext { mc::cat_deref(_, _, mc::region_ptr(m_const, _)) | mc::cat_deref(_, _, mc::gc_ptr(m_const)) => { - // R-Deref-Const-Borrowed + // R-Deref-Freeze-Borrowed self.check_no_mutability_control(cmt, restrictions); Safe } diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 48983dcadc8b4..09a52e518a143 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -33,21 +33,21 @@ use syntax::{visit, ast_util}; // // send: Things that can be sent on channels or included in spawned closures. // copy: Things that can be copied. -// const: Things thare are deeply immutable. They are guaranteed never to +// freeze: Things thare are deeply immutable. They are guaranteed never to // change, and can be safely shared without copying between tasks. -// owned: Things that do not contain borrowed pointers. +// 'static: Things that do not contain borrowed pointers. // // Send includes scalar types as well as classes and unique types containing // only sendable types. // // Copy includes boxes, closure and unique types containing copyable types. // -// Const include scalar types, things without non-const fields, and pointers -// to const things. +// Freeze include scalar types, things without non-const fields, and pointers +// to freezable things. // // This pass ensures that type parameters are only instantiated with types // whose kinds are equal or less general than the way the type parameter was -// annotated (with the `send`, `copy` or `const` keyword). +// annotated (with the `Send`, `Copy` or `Freeze` bound). // // It also verifies that noncopyable kinds are not copied. Sendability is not // applied, since none of our language primitives send. Instead, the sending @@ -94,10 +94,10 @@ fn check_struct_safe_for_destructor(cx: Context, self_ty: None, tps: ~[] }); - if !ty::type_is_owned(cx.tcx, struct_ty) { + if !ty::type_is_sendable(cx.tcx, struct_ty) { cx.tcx.sess.span_err(span, - "cannot implement a destructor on a struct \ - that is not Owned"); + "cannot implement a destructor on a \ + structure that does not satisfy Send"); cx.tcx.sess.span_note(span, "use \"#[unsafe_destructor]\" on the \ implementation to force the compiler to \ @@ -105,7 +105,7 @@ fn check_struct_safe_for_destructor(cx: Context, } } else { cx.tcx.sess.span_err(span, - "cannot implement a destructor on a struct \ + "cannot implement a destructor on a structure \ with type parameters"); cx.tcx.sess.span_note(span, "use \"#[unsafe_destructor]\" on the \ @@ -165,18 +165,18 @@ fn check_item(item: @item, cx: Context, visitor: visit::vt) { // closure. fn with_appropriate_checker(cx: Context, id: node_id, b: &fn(check_fn)) { fn check_for_uniq(cx: Context, fv: @freevar_entry) { - // all captured data must be owned, regardless of whether it is + // all captured data must be sendable, regardless of whether it is // moved in or copied in. let id = ast_util::def_id_of_def(fv.def).node; let var_t = ty::node_id_to_type(cx.tcx, id); - if !check_owned(cx, var_t, fv.span) { return; } + if !check_send(cx, var_t, fv.span) { return; } // check that only immutable variables are implicitly copied in check_imm_free_var(cx, fv.def, fv.span); } fn check_for_box(cx: Context, fv: @freevar_entry) { - // all captured data must be owned + // all captured data must be durable let id = ast_util::def_id_of_def(fv.def).node; let var_t = ty::node_id_to_type(cx.tcx, id); if !check_durable(cx.tcx, var_t, fv.span) { return; } @@ -389,10 +389,10 @@ fn check_copy(cx: Context, ty: ty::t, sp: span, reason: &str) { } } -pub fn check_owned(cx: Context, ty: ty::t, sp: span) -> bool { - if !ty::type_is_owned(cx.tcx, ty) { +pub fn check_send(cx: Context, ty: ty::t, sp: span) -> bool { + if !ty::type_is_sendable(cx.tcx, ty) { cx.tcx.sess.span_err( - sp, fmt!("value has non-owned type `%s`", + sp, fmt!("value has non-sendable type `%s`", ty_to_str(cx.tcx, ty))); false } else { @@ -440,7 +440,7 @@ pub fn check_durable(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool { /// `deque`, then whatever borrowed ptrs may appear in `T` also /// appear in `deque`. /// -/// (3) The type parameter is owned (and therefore does not contain +/// (3) The type parameter is sendable (and therefore does not contain /// borrowed ptrs). /// /// FIXME(#5723)---This code should probably move into regionck. @@ -479,7 +479,7 @@ pub fn check_cast_for_escaping_regions( } // Assuming the trait instance can escape, then ensure that each parameter - // either appears in the trait type or is owned. + // either appears in the trait type or is sendable. let target_params = ty::param_tys_in_type(target_ty); let source_ty = ty::expr_ty(cx.tcx, source); ty::walk_regions_and_ty( @@ -532,7 +532,7 @@ pub fn check_kind_bounds_of_cast(cx: Context, source: @expr, target: @expr) { match ty::get(target_ty).sty { ty::ty_trait(_, _, ty::UniqTraitStore, _) => { let source_ty = ty::expr_ty(cx.tcx, source); - if !ty::type_is_owned(cx.tcx, source_ty) { + if !ty::type_is_sendable(cx.tcx, source_ty) { cx.tcx.sess.span_err( target.span, "uniquely-owned trait objects must be sendable"); diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 798cba236297b..dc09d31b15c6f 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -13,9 +13,9 @@ // Language items are items that represent concepts intrinsic to the language // itself. Examples are: // -// * Traits that specify "kinds"; e.g. "const", "copy", "owned". +// * Traits that specify "kinds"; e.g. "Freeze", "Copy", "Send". // -// * Traits that represent operators; e.g. "add", "sub", "index". +// * Traits that represent operators; e.g. "Add", "Sub", "Index". // // * Functions called by the compiler itself. @@ -33,9 +33,9 @@ use syntax::visit::visit_crate; use core::hashmap::HashMap; pub enum LangItem { - ConstTraitLangItem, // 0 + FreezeTraitLangItem, // 0 CopyTraitLangItem, // 1 - OwnedTraitLangItem, // 2 + SendTraitLangItem, // 2 SizedTraitLangItem, // 3 DropTraitLangItem, // 4 @@ -95,9 +95,9 @@ impl LanguageItems { pub fn item_name(index: uint) -> &'static str { match index { - 0 => "const", + 0 => "freeze", 1 => "copy", - 2 => "owned", + 2 => "send", 3 => "sized", 4 => "drop", @@ -144,14 +144,14 @@ impl LanguageItems { // FIXME #4621: Method macros sure would be nice here. - pub fn const_trait(&const self) -> def_id { - self.items[ConstTraitLangItem as uint].get() + pub fn freeze_trait(&const self) -> def_id { + self.items[FreezeTraitLangItem as uint].get() } pub fn copy_trait(&const self) -> def_id { self.items[CopyTraitLangItem as uint].get() } - pub fn owned_trait(&const self) -> def_id { - self.items[OwnedTraitLangItem as uint].get() + pub fn send_trait(&const self) -> def_id { + self.items[SendTraitLangItem as uint].get() } pub fn sized_trait(&const self) -> def_id { self.items[SizedTraitLangItem as uint].get() @@ -269,9 +269,9 @@ fn LanguageItemCollector(crate: @crate, -> LanguageItemCollector { let mut item_refs = HashMap::new(); - item_refs.insert(@~"const", ConstTraitLangItem as uint); + item_refs.insert(@~"freeze", FreezeTraitLangItem as uint); item_refs.insert(@~"copy", CopyTraitLangItem as uint); - item_refs.insert(@~"owned", OwnedTraitLangItem as uint); + item_refs.insert(@~"send", SendTraitLangItem as uint); item_refs.insert(@~"sized", SizedTraitLangItem as uint); item_refs.insert(@~"drop", DropTraitLangItem as uint); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 433c1a864dd5b..c2e4c7590bea9 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -684,8 +684,8 @@ pub type BuiltinBounds = EnumSet; pub enum BuiltinBound { BoundCopy, BoundStatic, - BoundOwned, - BoundConst, + BoundSend, + BoundFreeze, BoundSized, } @@ -697,8 +697,8 @@ pub fn AllBuiltinBounds() -> BuiltinBounds { let mut set = EnumSet::empty(); set.add(BoundCopy); set.add(BoundStatic); - set.add(BoundOwned); - set.add(BoundConst); + set.add(BoundSend); + set.add(BoundFreeze); set.add(BoundSized); set } @@ -1831,8 +1831,8 @@ impl TypeContents { match bb { BoundCopy => self.is_copy(cx), BoundStatic => self.is_static(cx), - BoundConst => self.is_const(cx), - BoundOwned => self.is_owned(cx), + BoundFreeze => self.is_freezable(cx), + BoundSend => self.is_sendable(cx), BoundSized => self.is_sized(cx), } } @@ -1858,23 +1858,23 @@ impl TypeContents { TC_BORROWED_POINTER } - pub fn is_owned(&self, cx: ctxt) -> bool { - !self.intersects(TypeContents::nonowned(cx)) + pub fn is_sendable(&self, cx: ctxt) -> bool { + !self.intersects(TypeContents::nonsendable(cx)) } - pub fn nonowned(_cx: ctxt) -> TypeContents { - TC_MANAGED + TC_BORROWED_POINTER + TC_NON_OWNED + pub fn nonsendable(_cx: ctxt) -> TypeContents { + TC_MANAGED + TC_BORROWED_POINTER + TC_NON_SENDABLE } pub fn contains_managed(&self) -> bool { self.intersects(TC_MANAGED) } - pub fn is_const(&self, cx: ctxt) -> bool { - !self.intersects(TypeContents::nonconst(cx)) + pub fn is_freezable(&self, cx: ctxt) -> bool { + !self.intersects(TypeContents::nonfreezable(cx)) } - pub fn nonconst(_cx: ctxt) -> TypeContents { + pub fn nonfreezable(_cx: ctxt) -> TypeContents { TC_MUTABLE } @@ -1895,12 +1895,12 @@ impl TypeContents { } pub fn needs_drop(&self, cx: ctxt) -> bool { - let tc = TC_MANAGED + TC_DTOR + TypeContents::owned(cx); + let tc = TC_MANAGED + TC_DTOR + TypeContents::sendable(cx); self.intersects(tc) } - pub fn owned(_cx: ctxt) -> TypeContents { - //! Any kind of owned contents. + pub fn sendable(_cx: ctxt) -> TypeContents { + //! Any kind of sendable contents. TC_OWNED_CLOSURE + TC_OWNED_POINTER + TC_OWNED_VEC } } @@ -1956,8 +1956,8 @@ static TC_ONCE_CLOSURE: TypeContents = TypeContents{bits: 0b0001_0000_0000}; /// An enum with no variants. static TC_EMPTY_ENUM: TypeContents = TypeContents{bits: 0b0010_0000_0000}; -/// Contains a type marked with `#[non_owned]` -static TC_NON_OWNED: TypeContents = TypeContents{bits: 0b0100_0000_0000}; +/// Contains a type marked with `#[non_sendable]` +static TC_NON_SENDABLE: TypeContents = TypeContents{bits: 0b0100_0000_0000}; /// Is a bare vector, str, function, trait, etc (only relevant at top level). static TC_DYNAMIC_SIZE: TypeContents = TypeContents{bits: 0b1000_0000_0000}; @@ -1973,12 +1973,12 @@ pub fn type_is_static(cx: ctxt, t: ty::t) -> bool { type_contents(cx, t).is_static(cx) } -pub fn type_is_owned(cx: ctxt, t: ty::t) -> bool { - type_contents(cx, t).is_owned(cx) +pub fn type_is_sendable(cx: ctxt, t: ty::t) -> bool { + type_contents(cx, t).is_sendable(cx) } -pub fn type_is_const(cx: ctxt, t: ty::t) -> bool { - type_contents(cx, t).is_const(cx) +pub fn type_is_freezable(cx: ctxt, t: ty::t) -> bool { + type_contents(cx, t).is_freezable(cx) } pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { @@ -2032,7 +2032,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { let _i = indenter(); let result = match get(ty).sty { - // Scalar and unique types are sendable, constant, and owned + // Scalar and unique types are sendable, freezable, and durable ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_bare_fn(_) | ty_ptr(_) => { TC_NONE @@ -2047,7 +2047,8 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { } ty_box(mt) => { - TC_MANAGED + statically_sized(nonowned(tc_mt(cx, mt, cache))) + TC_MANAGED + + statically_sized(nonsendable(tc_mt(cx, mt, cache))) } ty_trait(_, _, UniqTraitStore, _) => { @@ -2067,7 +2068,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { ty_rptr(r, mt) => { borrowed_contents(r, mt.mutbl) + - statically_sized(nonowned(tc_mt(cx, mt, cache))) + statically_sized(nonsendable(tc_mt(cx, mt, cache))) } ty_uniq(mt) => { @@ -2079,12 +2080,13 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { } ty_evec(mt, vstore_box) => { - TC_MANAGED + statically_sized(nonowned(tc_mt(cx, mt, cache))) + TC_MANAGED + + statically_sized(nonsendable(tc_mt(cx, mt, cache))) } ty_evec(mt, vstore_slice(r)) => { borrowed_contents(r, mt.mutbl) + - statically_sized(nonowned(tc_mt(cx, mt, cache))) + statically_sized(nonsendable(tc_mt(cx, mt, cache))) } ty_evec(mt, vstore_fixed(_)) => { @@ -2202,8 +2204,8 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { if has_attr(cx, did, "mutable") { tc += TC_MUTABLE; } - if has_attr(cx, did, "non_owned") { - tc += TC_NON_OWNED; + if has_attr(cx, did, "non_sendable") { + tc += TC_NON_SENDABLE; } tc } @@ -2224,7 +2226,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { mc + rc } - fn nonowned(pointee: TypeContents) -> TypeContents { + fn nonsendable(pointee: TypeContents) -> TypeContents { /*! * * Given a non-owning pointer to some type `T` with @@ -2271,8 +2273,8 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { tc = tc - match bound { BoundCopy => TypeContents::nonimplicitly_copyable(cx), BoundStatic => TypeContents::nonstatic(cx), - BoundOwned => TypeContents::nonowned(cx), - BoundConst => TypeContents::nonconst(cx), + BoundSend => TypeContents::nonsendable(cx), + BoundFreeze => TypeContents::nonfreezable(cx), // The dynamic-size bit can be removed at pointer-level, etc. BoundSized => TypeContents::dynamically_sized(cx), }; diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 4b5f416cdd172..bea33ca07d3eb 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -733,7 +733,7 @@ fn conv_builtin_bounds(tcx: ty::ctxt, //! Converts a list of bounds from the AST into a `BuiltinBounds` //! struct. Reports an error if any of the bounds that appear //! in the AST refer to general traits and not the built-in traits - //! like `Copy` or `Owned`. Used to translate the bounds that + //! like `Copy` or `Send`. Used to translate the bounds that //! appear in closure and trait types, where only builtin bounds are //! legal. @@ -768,19 +768,19 @@ pub fn try_add_builtin_trait(tcx: ty::ctxt, trait_def_id: ast::def_id, builtin_bounds: &mut ty::BuiltinBounds) -> bool { //! Checks whether `trait_ref` refers to one of the builtin - //! traits, like `Copy` or `Owned`, and adds the corresponding + //! traits, like `Copy` or `Send`, and adds the corresponding //! bound to the set `builtin_bounds` if so. Returns true if `trait_ref` //! is a builtin trait. let li = &tcx.lang_items; - if trait_def_id == li.owned_trait() { - builtin_bounds.add(ty::BoundOwned); + if trait_def_id == li.send_trait() { + builtin_bounds.add(ty::BoundSend); true } else if trait_def_id == li.copy_trait() { builtin_bounds.add(ty::BoundCopy); true - } else if trait_def_id == li.const_trait() { - builtin_bounds.add(ty::BoundConst); + } else if trait_def_id == li.freeze_trait() { + builtin_bounds.add(ty::BoundFreeze); true } else if trait_def_id == li.sized_trait() { builtin_bounds.add(ty::BoundSized); diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index 03803a64fc36e..1f7d2c3520055 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -539,7 +539,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) { check_pointer_pat(pcx, Managed, inner, pat.id, pat.span, expected); } ast::pat_uniq(inner) => { - check_pointer_pat(pcx, Owned, inner, pat.id, pat.span, expected); + check_pointer_pat(pcx, Send, inner, pat.id, pat.span, expected); } ast::pat_region(inner) => { check_pointer_pat(pcx, Borrowed, inner, pat.id, pat.span, expected); @@ -625,7 +625,7 @@ pub fn check_pointer_pat(pcx: &pat_ctxt, ty::ty_box(e_inner) if pointer_kind == Managed => { check_inner(e_inner); } - ty::ty_uniq(e_inner) if pointer_kind == Owned => { + ty::ty_uniq(e_inner) if pointer_kind == Send => { check_inner(e_inner); } ty::ty_rptr(_, e_inner) if pointer_kind == Borrowed => { @@ -642,7 +642,7 @@ pub fn check_pointer_pat(pcx: &pat_ctxt, Some(expected), fmt!("%s pattern", match pointer_kind { Managed => "an @-box", - Owned => "a ~-box", + Send => "a ~-box", Borrowed => "an &-pointer" }), None); @@ -652,4 +652,4 @@ pub fn check_pointer_pat(pcx: &pat_ctxt, } #[deriving(Eq)] -enum PointerKind { Managed, Owned, Borrowed } +enum PointerKind { Managed, Send, Borrowed } diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index a2c1211c5c46e..be54801243459 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -1204,7 +1204,7 @@ pub fn ty_generics(ccx: &CrateCtxt, * enum consisting of a newtyped Ty or a region) to ty's * notion of ty param bounds, which can either be user-defined * traits, or one of the four built-in traits (formerly known - * as kinds): Const, Copy, and Send. + * as kinds): Freeze, Copy, and Send. */ let mut param_bounds = ty::ParamBounds { diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 4ffa4d0d25e09..13eb1a0293a48 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -560,8 +560,8 @@ impl Repr for ty::ParamBounds { res.push(match b { ty::BoundCopy => ~"Copy", ty::BoundStatic => ~"'static", - ty::BoundOwned => ~"Owned", - ty::BoundConst => ~"Const", + ty::BoundSend => ~"Send", + ty::BoundFreeze => ~"Freeze", ty::BoundSized => ~"Sized", }); } @@ -766,8 +766,8 @@ impl UserString for ty::BuiltinBound { match *self { ty::BoundCopy => ~"Copy", ty::BoundStatic => ~"'static", - ty::BoundOwned => ~"Owned", - ty::BoundConst => ~"Const", + ty::BoundSend => ~"Send", + ty::BoundFreeze => ~"Freeze", ty::BoundSized => ~"Sized", } } diff --git a/src/librustdoc/astsrv.rs b/src/librustdoc/astsrv.rs index c4fc377bc8bf7..cc5224de4dff6 100644 --- a/src/librustdoc/astsrv.rs +++ b/src/librustdoc/astsrv.rs @@ -101,7 +101,7 @@ fn act(po: &Port, source: ~str, parse: Parser) { } } -pub fn exec( +pub fn exec( srv: Srv, f: ~fn(ctxt: Ctxt) -> T ) -> T { diff --git a/src/librustdoc/attr_pass.rs b/src/librustdoc/attr_pass.rs index a1dad7d17f8e8..ae8f109d697f7 100644 --- a/src/librustdoc/attr_pass.rs +++ b/src/librustdoc/attr_pass.rs @@ -101,7 +101,7 @@ fn fold_item( } } -fn parse_item_attrs( +fn parse_item_attrs( srv: astsrv::Srv, id: doc::AstId, parse_attrs: ~fn(a: ~[ast::attribute]) -> T) -> T { diff --git a/src/librustdoc/markdown_pass.rs b/src/librustdoc/markdown_pass.rs index b17816d4e3652..16bc5f492fb0b 100644 --- a/src/librustdoc/markdown_pass.rs +++ b/src/librustdoc/markdown_pass.rs @@ -152,7 +152,7 @@ pub fn header_kind(doc: doc::ItemTag) -> ~str { ~"Function" } doc::ConstTag(_) => { - ~"Const" + ~"Freeze" } doc::EnumTag(_) => { ~"Enum" @@ -795,7 +795,7 @@ mod test { #[test] fn should_write_const_header() { let markdown = render(~"static a: bool = true;"); - assert!(str::contains(markdown, "## Const `a`\n\n")); + assert!(str::contains(markdown, "## Freeze `a`\n\n")); } #[test] diff --git a/src/libstd/clone.rs b/src/libstd/clone.rs index 266dd1a35e32c..b3b47858c9295 100644 --- a/src/libstd/clone.rs +++ b/src/libstd/clone.rs @@ -22,7 +22,7 @@ by convention implementing the `Clone` trait and calling the */ -use core::kinds::Const; +use core::kinds::Freeze; /// A common trait for cloning an object. pub trait Clone { @@ -100,17 +100,17 @@ impl DeepClone for ~T { fn deep_clone(&self) -> ~T { ~(**self).deep_clone() } } -// FIXME: #6525: should also be implemented for `T: Owned + DeepClone` -impl DeepClone for @T { - /// Return a deep copy of the managed box. The `Const` trait is required to prevent performing +// FIXME: #6525: should also be implemented for `T: Send + DeepClone` +impl DeepClone for @T { + /// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing /// a deep clone of a potentially cyclical type. #[inline(always)] fn deep_clone(&self) -> @T { @(**self).deep_clone() } } -// FIXME: #6525: should also be implemented for `T: Owned + DeepClone` -impl DeepClone for @mut T { - /// Return a deep copy of the managed box. The `Const` trait is required to prevent performing +// FIXME: #6525: should also be implemented for `T: Send + DeepClone` +impl DeepClone for @mut T { + /// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing /// a deep clone of a potentially cyclical type. #[inline(always)] fn deep_clone(&self) -> @mut T { @mut (**self).deep_clone() } diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index f0c353c8d62b6..dd2ed2c953653 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -17,7 +17,7 @@ Message passing use cast::{transmute, transmute_mut}; use container::Container; use either::{Either, Left, Right}; -use kinds::Owned; +use kinds::Send; use option::{Option, Some, None}; use uint; use vec; @@ -78,7 +78,7 @@ pub struct Port { These allow sending or receiving an unlimited number of messages. */ -pub fn stream() -> (Port, Chan) { +pub fn stream() -> (Port, Chan) { let (port, chan) = match rt::context() { rt::OldTaskContext => match pipesy::stream() { (p, c) => (Left(p), Left(c)) @@ -92,7 +92,7 @@ pub fn stream() -> (Port, Chan) { return (port, chan); } -impl GenericChan for Chan { +impl GenericChan for Chan { fn send(&self, x: T) { match self.inner { Left(ref chan) => chan.send(x), @@ -101,7 +101,7 @@ impl GenericChan for Chan { } } -impl GenericSmartChan for Chan { +impl GenericSmartChan for Chan { fn try_send(&self, x: T) -> bool { match self.inner { Left(ref chan) => chan.try_send(x), @@ -110,7 +110,7 @@ impl GenericSmartChan for Chan { } } -impl GenericPort for Port { +impl GenericPort for Port { fn recv(&self) -> T { match self.inner { Left(ref port) => port.recv(), @@ -126,7 +126,7 @@ impl GenericPort for Port { } } -impl Peekable for Port { +impl Peekable for Port { fn peek(&self) -> bool { match self.inner { Left(ref port) => port.peek(), @@ -135,7 +135,7 @@ impl Peekable for Port { } } -impl Selectable for Port { +impl Selectable for Port { fn header(&mut self) -> *mut PacketHeader { match self.inner { Left(ref mut port) => port.header(), @@ -150,7 +150,7 @@ pub struct PortSet { ports: ~[pipesy::Port], } -impl PortSet { +impl PortSet { pub fn new() -> PortSet { PortSet { ports: ~[] @@ -176,7 +176,7 @@ impl PortSet { } } -impl GenericPort for PortSet { +impl GenericPort for PortSet { fn try_recv(&self) -> Option { unsafe { let self_ports = transmute_mut(&self.ports); @@ -205,7 +205,7 @@ impl GenericPort for PortSet { } } -impl Peekable for PortSet { +impl Peekable for PortSet { fn peek(&self) -> bool { // It'd be nice to use self.port.each, but that version isn't // pure. @@ -224,7 +224,7 @@ pub struct SharedChan { ch: Exclusive> } -impl SharedChan { +impl SharedChan { /// Converts a `chan` into a `shared_chan`. pub fn new(c: Chan) -> SharedChan { let Chan { inner } = c; @@ -236,7 +236,7 @@ impl SharedChan { } } -impl GenericChan for SharedChan { +impl GenericChan for SharedChan { fn send(&self, x: T) { unsafe { let mut xx = Some(x); @@ -248,7 +248,7 @@ impl GenericChan for SharedChan { } } -impl GenericSmartChan for SharedChan { +impl GenericSmartChan for SharedChan { fn try_send(&self, x: T) -> bool { unsafe { let mut xx = Some(x); @@ -260,7 +260,7 @@ impl GenericSmartChan for SharedChan { } } -impl ::clone::Clone for SharedChan { +impl ::clone::Clone for SharedChan { fn clone(&self) -> SharedChan { SharedChan { ch: self.ch.clone() } } @@ -274,7 +274,7 @@ pub struct ChanOne { inner: Either, rtcomm::ChanOne> } -pub fn oneshot() -> (PortOne, ChanOne) { +pub fn oneshot() -> (PortOne, ChanOne) { let (port, chan) = match rt::context() { rt::OldTaskContext => match pipesy::oneshot() { (p, c) => (Left(p), Left(c)), @@ -288,7 +288,7 @@ pub fn oneshot() -> (PortOne, ChanOne) { return (port, chan); } -impl PortOne { +impl PortOne { pub fn recv(self) -> T { let PortOne { inner } = self; match inner { @@ -306,7 +306,7 @@ impl PortOne { } } -impl ChanOne { +impl ChanOne { pub fn send(self, data: T) { let ChanOne { inner } = self; match inner { @@ -324,7 +324,7 @@ impl ChanOne { } } -pub fn recv_one(port: PortOne) -> T { +pub fn recv_one(port: PortOne) -> T { let PortOne { inner } = port; match inner { Left(p) => pipesy::recv_one(p), @@ -332,7 +332,7 @@ pub fn recv_one(port: PortOne) -> T { } } -pub fn try_recv_one(port: PortOne) -> Option { +pub fn try_recv_one(port: PortOne) -> Option { let PortOne { inner } = port; match inner { Left(p) => pipesy::try_recv_one(p), @@ -340,7 +340,7 @@ pub fn try_recv_one(port: PortOne) -> Option { } } -pub fn send_one(chan: ChanOne, data: T) { +pub fn send_one(chan: ChanOne, data: T) { let ChanOne { inner } = chan; match inner { Left(c) => pipesy::send_one(c, data), @@ -348,7 +348,7 @@ pub fn send_one(chan: ChanOne, data: T) { } } -pub fn try_send_one(chan: ChanOne, data: T) -> bool { +pub fn try_send_one(chan: ChanOne, data: T) -> bool { let ChanOne { inner } = chan; match inner { Left(c) => pipesy::try_send_one(c, data), @@ -358,7 +358,7 @@ pub fn try_send_one(chan: ChanOne, data: T) -> bool { mod pipesy { - use kinds::Owned; + use kinds::Send; use option::{Option, Some, None}; use pipes::{recv, try_recv, peek, PacketHeader}; use super::{GenericChan, GenericSmartChan, GenericPort, Peekable, Selectable}; @@ -366,17 +366,17 @@ mod pipesy { use util::replace; /*proto! oneshot ( - Oneshot:send { + Oneshot:send { send(T) -> ! } )*/ #[allow(non_camel_case_types)] pub mod oneshot { - priv use core::kinds::Owned; + priv use core::kinds::Send; use ptr::to_mut_unsafe_ptr; - pub fn init() -> (server::Oneshot, client::Oneshot) { + pub fn init() -> (server::Oneshot, client::Oneshot) { pub use core::pipes::HasBuffer; let buffer = ~::core::pipes::Buffer { @@ -400,10 +400,10 @@ mod pipesy { #[allow(non_camel_case_types)] pub mod client { - priv use core::kinds::Owned; + priv use core::kinds::Send; #[allow(non_camel_case_types)] - pub fn try_send(pipe: Oneshot, x_0: T) -> + pub fn try_send(pipe: Oneshot, x_0: T) -> ::core::option::Option<()> { { use super::send; @@ -415,7 +415,7 @@ mod pipesy { } #[allow(non_camel_case_types)] - pub fn send(pipe: Oneshot, x_0: T) { + pub fn send(pipe: Oneshot, x_0: T) { { use super::send; let message = send(x_0); @@ -465,12 +465,12 @@ mod pipesy { } /// Initialiase a (send-endpoint, recv-endpoint) oneshot pipe pair. - pub fn oneshot() -> (PortOne, ChanOne) { + pub fn oneshot() -> (PortOne, ChanOne) { let (port, chan) = oneshot::init(); (PortOne::new(port), ChanOne::new(chan)) } - impl PortOne { + impl PortOne { pub fn recv(self) -> T { recv_one(self) } pub fn try_recv(self) -> Option { try_recv_one(self) } pub fn unwrap(self) -> oneshot::server::Oneshot { @@ -480,7 +480,7 @@ mod pipesy { } } - impl ChanOne { + impl ChanOne { pub fn send(self, data: T) { send_one(self, data) } pub fn try_send(self, data: T) -> bool { try_send_one(self, data) } pub fn unwrap(self) -> oneshot::client::Oneshot { @@ -494,7 +494,7 @@ mod pipesy { * Receive a message from a oneshot pipe, failing if the connection was * closed. */ - pub fn recv_one(port: PortOne) -> T { + pub fn recv_one(port: PortOne) -> T { match port { PortOne { contents: port } => { let oneshot::send(message) = recv(port); @@ -504,7 +504,7 @@ mod pipesy { } /// Receive a message from a oneshot pipe unless the connection was closed. - pub fn try_recv_one (port: PortOne) -> Option { + pub fn try_recv_one (port: PortOne) -> Option { match port { PortOne { contents: port } => { let message = try_recv(port); @@ -520,7 +520,7 @@ mod pipesy { } /// Send a message on a oneshot pipe, failing if the connection was closed. - pub fn send_one(chan: ChanOne, data: T) { + pub fn send_one(chan: ChanOne, data: T) { match chan { ChanOne { contents: chan } => oneshot::client::send(chan, data), } @@ -530,7 +530,7 @@ mod pipesy { * Send a message on a oneshot pipe, or return false if the connection was * closed. */ - pub fn try_send_one(chan: ChanOne, data: T) -> bool { + pub fn try_send_one(chan: ChanOne, data: T) -> bool { match chan { ChanOne { contents: chan } => { oneshot::client::try_send(chan, data).is_some() @@ -541,16 +541,16 @@ mod pipesy { // Streams - Make pipes a little easier in general. /*proto! streamp ( - Open:send { + Open:send { data(T) -> Open } )*/ #[allow(non_camel_case_types)] pub mod streamp { - priv use core::kinds::Owned; + priv use core::kinds::Send; - pub fn init() -> (server::Open, client::Open) { + pub fn init() -> (server::Open, client::Open) { pub use core::pipes::HasBuffer; ::core::pipes::entangle() } @@ -560,10 +560,10 @@ mod pipesy { #[allow(non_camel_case_types)] pub mod client { - priv use core::kinds::Owned; + priv use core::kinds::Send; #[allow(non_camel_case_types)] - pub fn try_data(pipe: Open, x_0: T) -> + pub fn try_data(pipe: Open, x_0: T) -> ::core::option::Option> { { use super::data; @@ -576,7 +576,7 @@ mod pipesy { } #[allow(non_camel_case_types)] - pub fn data(pipe: Open, x_0: T) -> Open { + pub fn data(pipe: Open, x_0: T) -> Open { { use super::data; let (s, c) = ::core::pipes::entangle(); @@ -614,7 +614,7 @@ mod pipesy { These allow sending or receiving an unlimited number of messages. */ - pub fn stream() -> (Port, Chan) { + pub fn stream() -> (Port, Chan) { let (s, c) = streamp::init(); (Port { @@ -624,7 +624,7 @@ mod pipesy { }) } - impl GenericChan for Chan { + impl GenericChan for Chan { #[inline(always)] fn send(&self, x: T) { unsafe { @@ -635,7 +635,7 @@ mod pipesy { } } - impl GenericSmartChan for Chan { + impl GenericSmartChan for Chan { #[inline(always)] fn try_send(&self, x: T) -> bool { unsafe { @@ -652,7 +652,7 @@ mod pipesy { } } - impl GenericPort for Port { + impl GenericPort for Port { #[inline(always)] fn recv(&self) -> T { unsafe { @@ -680,7 +680,7 @@ mod pipesy { } } - impl Peekable for Port { + impl Peekable for Port { #[inline(always)] fn peek(&self) -> bool { unsafe { @@ -696,7 +696,7 @@ mod pipesy { } } - impl Selectable for Port { + impl Selectable for Port { fn header(&mut self) -> *mut PacketHeader { match self.endp { Some(ref mut endp) => endp.header(), @@ -724,15 +724,15 @@ pub fn select2i(a: &mut A, b: &mut B) } /// Receive a message from one of two endpoints. -pub trait Select2 { +pub trait Select2 { /// Receive a message or return `None` if a connection closes. fn try_select(&mut self) -> Either, Option>; /// Receive a message or fail if a connection closes. fn select(&mut self) -> Either; } -impl, Right:Selectable + GenericPort> Select2 diff --git a/src/libstd/kinds.rs b/src/libstd/kinds.rs index 05c963a32cc73..f350e10616805 100644 --- a/src/libstd/kinds.rs +++ b/src/libstd/kinds.rs @@ -24,11 +24,10 @@ The 4 kinds are scalar types and managed pointers, and exludes owned pointers. It also excludes types that implement `Drop`. -* Owned - owned types and types containing owned types. These types +* Send - owned types and types containing owned types. These types may be transferred across task boundaries. -* Const - types that are deeply immutable. Const types are used for - freezable data structures. +* Freeze - types that are deeply immutable. `Copy` types include both implicitly copyable types that the compiler will copy automatically and non-implicitly copyable types that require @@ -44,14 +43,28 @@ pub trait Copy { // Empty. } +#[cfg(stage0)] #[lang="owned"] -pub trait Owned { - // Empty. +pub trait Send { + // empty. +} + +#[cfg(not(stage0))] +#[lang="send"] +pub trait Send { + // empty. } +#[cfg(stage0)] #[lang="const"] -pub trait Const { - // Empty. +pub trait Freeze { + // empty. +} + +#[cfg(not(stage0))] +#[lang="freeze"] +pub trait Freeze { + // empty. } #[lang="sized"] diff --git a/src/libstd/pipes.rs b/src/libstd/pipes.rs index fe1b834813e8b..a073b1ee42ee4 100644 --- a/src/libstd/pipes.rs +++ b/src/libstd/pipes.rs @@ -87,7 +87,7 @@ bounded and unbounded protocols allows for less code duplication. use container::Container; use cast::{forget, transmute, transmute_copy}; use either::{Either, Left, Right}; -use kinds::Owned; +use kinds::Send; use libc; use ops::Drop; use option::{None, Option, Some}; @@ -181,7 +181,7 @@ impl PacketHeader { transmute_copy(&self.buffer) } - pub fn set_buffer(&mut self, b: ~Buffer) { + pub fn set_buffer(&mut self, b: ~Buffer) { unsafe { self.buffer = transmute_copy(&b); } @@ -197,13 +197,13 @@ pub trait HasBuffer { fn set_buffer(&mut self, b: *libc::c_void); } -impl HasBuffer for Packet { +impl HasBuffer for Packet { fn set_buffer(&mut self, b: *libc::c_void) { self.header.buffer = b; } } -pub fn mk_packet() -> Packet { +pub fn mk_packet() -> Packet { Packet { header: PacketHeader(), payload: None, @@ -234,7 +234,7 @@ pub fn packet() -> *mut Packet { p } -pub fn entangle_buffer( +pub fn entangle_buffer( mut buffer: ~Buffer, init: &fn(*libc::c_void, x: &mut T) -> *mut Packet) -> (RecvPacketBuffered, SendPacketBuffered) { @@ -397,7 +397,7 @@ pub fn send(mut p: SendPacketBuffered, Fails if the sender closes the connection. */ -pub fn recv( +pub fn recv( p: RecvPacketBuffered) -> T { try_recv(p).expect("connection closed") } @@ -408,7 +408,7 @@ Returns `None` if the sender has closed the connection without sending a message, or `Some(T)` if a message was received. */ -pub fn try_recv(mut p: RecvPacketBuffered) +pub fn try_recv(mut p: RecvPacketBuffered) -> Option { let p_ = p.unwrap(); let p = unsafe { &mut *p_ }; @@ -428,7 +428,7 @@ pub fn try_recv(mut p: RecvPacketBuffered) } } -fn try_recv_(p: &mut Packet) -> Option { +fn try_recv_(p: &mut Packet) -> Option { // optimistic path match p.header.state { Full => { @@ -512,7 +512,7 @@ fn try_recv_(p: &mut Packet) -> Option { } /// Returns true if messages are available. -pub fn peek(p: &mut RecvPacketBuffered) -> bool { +pub fn peek(p: &mut RecvPacketBuffered) -> bool { unsafe { match (*p.header()).state { Empty | Terminated => false, @@ -522,7 +522,7 @@ pub fn peek(p: &mut RecvPacketBuffered) -> bool { } } -fn sender_terminate(p: *mut Packet) { +fn sender_terminate(p: *mut Packet) { let p = unsafe { &mut *p }; @@ -554,7 +554,7 @@ fn sender_terminate(p: *mut Packet) { } } -fn receiver_terminate(p: *mut Packet) { +fn receiver_terminate(p: *mut Packet) { let p = unsafe { &mut *p }; @@ -672,7 +672,7 @@ pub struct SendPacketBuffered { } #[unsafe_destructor] -impl Drop for SendPacketBuffered { +impl Drop for SendPacketBuffered { fn finalize(&self) { unsafe { let this: &mut SendPacketBuffered = transmute(self); @@ -730,7 +730,7 @@ pub struct RecvPacketBuffered { } #[unsafe_destructor] -impl Drop for RecvPacketBuffered { +impl Drop for RecvPacketBuffered { fn finalize(&self) { unsafe { let this: &mut RecvPacketBuffered = transmute(self); @@ -742,7 +742,7 @@ impl Drop for RecvPacketBuffered { } } -impl RecvPacketBuffered { +impl RecvPacketBuffered { pub fn unwrap(&mut self) -> *mut Packet { replace(&mut self.p, None).unwrap() } @@ -752,7 +752,7 @@ impl RecvPacketBuffered { } } -impl Selectable for RecvPacketBuffered { +impl Selectable for RecvPacketBuffered { fn header(&mut self) -> *mut PacketHeader { match self.p { Some(packet) => unsafe { @@ -808,7 +808,7 @@ Sometimes messages will be available on both endpoints at once. In this case, `select2` may return either `left` or `right`. */ -pub fn select2( +pub fn select2( mut a: RecvPacketBuffered, mut b: RecvPacketBuffered) -> Either<(Option, RecvPacketBuffered), @@ -848,7 +848,7 @@ pub fn select2i(a: &mut A, b: &mut B) /// Waits on a set of endpoints. Returns a message, its index, and a /// list of the remaining endpoints. -pub fn select(mut endpoints: ~[RecvPacketBuffered]) +pub fn select(mut endpoints: ~[RecvPacketBuffered]) -> (uint, Option, ~[RecvPacketBuffered]) { diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs index ab8a699a50299..1df57ad1f644a 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -29,7 +29,8 @@ Rust's prelude has three main parts: // Reexported core operators pub use either::{Either, Left, Right}; -pub use kinds::{Const, Copy, Owned, Sized}; +pub use kinds::{Copy, Sized}; +pub use kinds::{Freeze, Send}; pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not}; pub use ops::{BitAnd, BitOr, BitXor}; pub use ops::{Drop}; diff --git a/src/libstd/rt/comm.rs b/src/libstd/rt/comm.rs index 8a8f31bbdfa52..03bc2da14138b 100644 --- a/src/libstd/rt/comm.rs +++ b/src/libstd/rt/comm.rs @@ -19,7 +19,7 @@ use option::*; use cast; use util; use ops::Drop; -use kinds::Owned; +use kinds::Send; use rt::sched::{Scheduler, Coroutine}; use rt::local::Local; use unstable::intrinsics::{atomic_xchg, atomic_load}; @@ -68,7 +68,7 @@ pub struct PortOneHack { suppress_finalize: bool } -pub fn oneshot() -> (PortOne, ChanOne) { +pub fn oneshot() -> (PortOne, ChanOne) { let packet: ~Packet = ~Packet { state: STATE_BOTH, payload: None @@ -307,20 +307,20 @@ pub struct Port { next: Cell>> } -pub fn stream() -> (Port, Chan) { +pub fn stream() -> (Port, Chan) { let (pone, cone) = oneshot(); let port = Port { next: Cell::new(pone) }; let chan = Chan { next: Cell::new(cone) }; return (port, chan); } -impl GenericChan for Chan { +impl GenericChan for Chan { fn send(&self, val: T) { self.try_send(val); } } -impl GenericSmartChan for Chan { +impl GenericSmartChan for Chan { fn try_send(&self, val: T) -> bool { let (next_pone, next_cone) = oneshot(); let cone = self.next.take(); diff --git a/src/libstd/rt/message_queue.rs b/src/libstd/rt/message_queue.rs index 5b60543344de1..d561e81d03271 100644 --- a/src/libstd/rt/message_queue.rs +++ b/src/libstd/rt/message_queue.rs @@ -9,7 +9,7 @@ // except according to those terms. use container::Container; -use kinds::Owned; +use kinds::Send; use vec::OwnedVector; use cell::Cell; use option::*; @@ -21,7 +21,7 @@ pub struct MessageQueue { priv queue: ~Exclusive<~[T]> } -impl MessageQueue { +impl MessageQueue { pub fn new() -> MessageQueue { MessageQueue { queue: ~exclusive(~[]) diff --git a/src/libstd/rt/work_queue.rs b/src/libstd/rt/work_queue.rs index cfffc55a58c80..00d2774426884 100644 --- a/src/libstd/rt/work_queue.rs +++ b/src/libstd/rt/work_queue.rs @@ -13,7 +13,7 @@ use option::*; use vec::OwnedVector; use unstable::sync::{Exclusive, exclusive}; use cell::Cell; -use kinds::Owned; +use kinds::Send; use clone::Clone; pub struct WorkQueue { @@ -21,7 +21,7 @@ pub struct WorkQueue { priv queue: ~Exclusive<~[T]> } -impl WorkQueue { +impl WorkQueue { pub fn new() -> WorkQueue { WorkQueue { queue: ~exclusive(~[]) diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs index 223afbce091b8..435e1fc8e6245 100644 --- a/src/libstd/task/mod.rs +++ b/src/libstd/task/mod.rs @@ -353,7 +353,7 @@ impl TaskBuilder { } /// Runs a task, while transfering ownership of one argument to the child. - pub fn spawn_with(&mut self, arg: A, f: ~fn(v: A)) { + pub fn spawn_with(&mut self, arg: A, f: ~fn(v: A)) { let arg = Cell::new(arg); do self.spawn { f(arg.take()); @@ -373,7 +373,7 @@ impl TaskBuilder { * # Failure * Fails if a future_result was already set for this task. */ - pub fn try(&mut self, f: ~fn() -> T) -> Result { + pub fn try(&mut self, f: ~fn() -> T) -> Result { let (po, ch) = stream::(); let mut result = None; @@ -445,7 +445,7 @@ pub fn spawn_supervised(f: ~fn()) { task.spawn(f) } -pub fn spawn_with(arg: A, f: ~fn(v: A)) { +pub fn spawn_with(arg: A, f: ~fn(v: A)) { /*! * Runs a task, while transfering ownership of one argument to the * child. @@ -478,7 +478,7 @@ pub fn spawn_sched(mode: SchedMode, f: ~fn()) { task.spawn(f) } -pub fn try(f: ~fn() -> T) -> Result { +pub fn try(f: ~fn() -> T) -> Result { /*! * Execute a function in another task and return either the return value * of the function or result::err. diff --git a/src/libstd/unstable/global.rs b/src/libstd/unstable/global.rs index 96549a83a8cf3..d26720348c63a 100644 --- a/src/libstd/unstable/global.rs +++ b/src/libstd/unstable/global.rs @@ -27,7 +27,7 @@ avoid hitting the mutex. use cast::{transmute}; use clone::Clone; -use kinds::Owned; +use kinds::Send; use libc::{c_void}; use option::{Option, Some, None}; use ops::Drop; @@ -43,7 +43,7 @@ use sys::Closure; pub type GlobalDataKey<'self,T> = &'self fn(v: T); -pub unsafe fn global_data_clone_create( +pub unsafe fn global_data_clone_create( key: GlobalDataKey, create: &fn() -> ~T) -> T { /*! * Clone a global value or, if it has not been created, @@ -59,7 +59,7 @@ pub unsafe fn global_data_clone_create( global_data_clone_create_(key_ptr(key), create) } -unsafe fn global_data_clone_create_( +unsafe fn global_data_clone_create_( key: uint, create: &fn() -> ~T) -> T { let mut clone_value: Option = None; @@ -79,13 +79,13 @@ unsafe fn global_data_clone_create_( return clone_value.unwrap(); } -unsafe fn global_data_modify( +unsafe fn global_data_modify( key: GlobalDataKey, op: &fn(Option<~T>) -> Option<~T>) { global_data_modify_(key_ptr(key), op) } -unsafe fn global_data_modify_( +unsafe fn global_data_modify_( key: uint, op: &fn(Option<~T>) -> Option<~T>) { let mut old_dtor = None; @@ -124,7 +124,7 @@ unsafe fn global_data_modify_( } } -pub unsafe fn global_data_clone( +pub unsafe fn global_data_clone( key: GlobalDataKey) -> Option { let mut maybe_clone: Option = None; do global_data_modify(key) |current| { @@ -220,7 +220,7 @@ fn get_global_state() -> Exclusive { } } -fn key_ptr(key: GlobalDataKey) -> uint { +fn key_ptr(key: GlobalDataKey) -> uint { unsafe { let closure: Closure = transmute(key); return transmute(closure.code); diff --git a/src/libstd/unstable/sync.rs b/src/libstd/unstable/sync.rs index f0b178c667013..b8e987a481e64 100644 --- a/src/libstd/unstable/sync.rs +++ b/src/libstd/unstable/sync.rs @@ -17,7 +17,7 @@ use unstable::finally::Finally; use unstable::intrinsics; use ops::Drop; use clone::Clone; -use kinds::Owned; +use kinds::Send; /// An atomically reference counted pointer. /// @@ -31,7 +31,7 @@ struct AtomicRcBoxData { data: Option, } -impl UnsafeAtomicRcBox { +impl UnsafeAtomicRcBox { pub fn new(data: T) -> UnsafeAtomicRcBox { unsafe { let data = ~AtomicRcBoxData { count: 1, data: Some(data) }; @@ -61,7 +61,7 @@ impl UnsafeAtomicRcBox { } } -impl Clone for UnsafeAtomicRcBox { +impl Clone for UnsafeAtomicRcBox { fn clone(&self) -> UnsafeAtomicRcBox { unsafe { let mut data: ~AtomicRcBoxData = cast::transmute(self.data); @@ -144,7 +144,7 @@ pub struct Exclusive { x: UnsafeAtomicRcBox> } -pub fn exclusive(user_data: T) -> Exclusive { +pub fn exclusive(user_data: T) -> Exclusive { let data = ExData { lock: LittleLock(), failed: false, @@ -155,14 +155,14 @@ pub fn exclusive(user_data: T) -> Exclusive { } } -impl Clone for Exclusive { +impl Clone for Exclusive { // Duplicate an exclusive ARC, as std::arc::clone. fn clone(&self) -> Exclusive { Exclusive { x: self.x.clone() } } } -impl Exclusive { +impl Exclusive { // Exactly like std::arc::mutex_arc,access(), but with the little_lock // instead of a proper mutex. Same reason for being unsafe. // diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 625bcd4ec9c3f..74f3b33ead720 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -147,7 +147,7 @@ pub static crate_node_id: node_id = 0; // The AST represents all type param bounds as types. // typeck::collect::compute_bounds matches these against // the "special" built-in traits (see middle::lang_items) and -// detects Copy, Send, Owned, and Const. +// detects Copy, Send, Send, and Freeze. pub enum TyParamBound { TraitTyParamBound(@trait_ref), RegionTyParamBound diff --git a/src/libsyntax/ext/deriving/to_str.rs b/src/libsyntax/ext/deriving/to_str.rs index 52efabd4b9b87..81292ec4b5fd9 100644 --- a/src/libsyntax/ext/deriving/to_str.rs +++ b/src/libsyntax/ext/deriving/to_str.rs @@ -31,7 +31,7 @@ pub fn expand_deriving_to_str(cx: @ExtCtxt, generics: LifetimeBounds::empty(), explicit_self: borrowed_explicit_self(), args: ~[], - ret_ty: Ptr(~Literal(Path::new_local("str")), Owned), + ret_ty: Ptr(~Literal(Path::new_local("str")), Send), const_nonmatching: false, combine_substructure: to_str_substructure } diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index 3b39cb691a629..347683f0b21da 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -24,7 +24,7 @@ use opt_vec; /// The types of pointers pub enum PtrTy<'self> { - Owned, // ~ + Send, // ~ Managed(ast::mutability), // @[mut] Borrowed(Option<&'self str>, ast::mutability), // &['lifetime] [mut] } @@ -130,7 +130,7 @@ impl<'self> Ty<'self> { Ptr(ref ty, ref ptr) => { let raw_ty = ty.to_ty(cx, span, self_ty, self_generics); match *ptr { - Owned => { + Send => { cx.ty_uniq(span, raw_ty) } Managed(mutbl) => { @@ -249,7 +249,7 @@ pub fn get_explicit_self(cx: @ExtCtxt, span: span, self_ptr: &Option) let self_ty = respan( span, match *ptr { - Owned => ast::sty_uniq(ast::m_imm), + Send => ast::sty_uniq(ast::m_imm), Managed(mutbl) => ast::sty_box(mutbl), Borrowed(ref lt, mutbl) => { let lt = lt.map(|s| @cx.lifetime(span, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 23e3f14539815..a423ca8dffbd3 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1139,14 +1139,14 @@ impl Parser { pub fn token_is_mutability(&self, tok: &token::Token) -> bool { token::is_keyword(keywords::Mut, tok) || - token::is_keyword(keywords::Const, tok) + token::is_keyword(keywords::Freeze, tok) } // parse mutability declaration (mut/const/imm) pub fn parse_mutability(&self) -> mutability { if self.eat_keyword(keywords::Mut) { m_mutbl - } else if self.eat_keyword(keywords::Const) { + } else if self.eat_keyword(keywords::Freeze) { m_const } else { m_imm @@ -3032,7 +3032,7 @@ impl Parser { ) -> ast::explicit_self_ { // We need to make sure it isn't a mode or a type if token::is_keyword(keywords::Self, &p.look_ahead(1)) || - ((token::is_keyword(keywords::Const, &p.look_ahead(1)) || + ((token::is_keyword(keywords::Freeze, &p.look_ahead(1)) || token::is_keyword(keywords::Mut, &p.look_ahead(1))) && token::is_keyword(keywords::Self, &p.look_ahead(2))) { @@ -3667,7 +3667,7 @@ impl Parser { let lo = self.span.lo; // XXX: Obsolete; remove after snap. - if self.eat_keyword(keywords::Const) { + if self.eat_keyword(keywords::Freeze) { self.obsolete(*self.last_span, ObsoleteConstItem); } else { self.expect_keyword(keywords::Static); @@ -4058,11 +4058,11 @@ impl Parser { } } // the rest are all guaranteed to be items: - if (self.is_keyword(keywords::Const) || + if (self.is_keyword(keywords::Freeze) || (self.is_keyword(keywords::Static) && !token::is_keyword(keywords::Fn, &self.look_ahead(1)))) { // CONST / STATIC ITEM - if self.is_keyword(keywords::Const) { + if self.is_keyword(keywords::Freeze) { self.obsolete(*self.span, ObsoleteConstItem); } self.bump(); @@ -4160,7 +4160,7 @@ impl Parser { let visibility = self.parse_visibility(); - if (self.is_keyword(keywords::Const) || self.is_keyword(keywords::Static)) { + if (self.is_keyword(keywords::Freeze) || self.is_keyword(keywords::Static)) { // FOREIGN CONST ITEM let item = self.parse_item_foreign_const(visibility, attrs); return iovi_foreign_item(item); diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index b716384c6ccc5..6d9bb9a4450aa 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -549,7 +549,7 @@ pub mod keywords { // Strict keywords As, Break, - Const, + Freeze, Copy, Do, Else, @@ -592,7 +592,7 @@ pub mod keywords { match *self { As => ident { repr: 35, ctxt: 0 }, Break => ident { repr: 36, ctxt: 0 }, - Const => ident { repr: 37, ctxt: 0 }, + Freeze => ident { repr: 37, ctxt: 0 }, Copy => ident { repr: 38, ctxt: 0 }, Do => ident { repr: 39, ctxt: 0 }, Else => ident { repr: 41, ctxt: 0 }, diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index c3deb65163ddd..2da5b451ebae2 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -27,7 +27,7 @@ pub struct Interner { } // when traits can extend traits, we should extend index to get [] -impl Interner { +impl Interner { pub fn new() -> Interner { Interner { map: @mut HashMap::new(), diff --git a/src/test/auxiliary/cci_capture_clause.rs b/src/test/auxiliary/cci_capture_clause.rs index e58b28aa3ded1..98c364590be83 100644 --- a/src/test/auxiliary/cci_capture_clause.rs +++ b/src/test/auxiliary/cci_capture_clause.rs @@ -11,7 +11,7 @@ use std::comm::*; use std::task; -pub fn foo(x: T) -> Port { +pub fn foo(x: T) -> Port { let (p, c) = stream(); do task::spawn() { c.send(x); diff --git a/src/test/auxiliary/issue-2526.rs b/src/test/auxiliary/issue-2526.rs index bbc0f1ad3e558..a9250630ad496 100644 --- a/src/test/auxiliary/issue-2526.rs +++ b/src/test/auxiliary/issue-2526.rs @@ -20,17 +20,17 @@ struct arc_destruct { } #[unsafe_destructor] -impl Drop for arc_destruct { +impl Drop for arc_destruct { fn finalize(&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/bench/pingpong.rs b/src/test/bench/pingpong.rs index 63e4174a0fc7c..1d32a78303a8f 100644 --- a/src/test/bench/pingpong.rs +++ b/src/test/bench/pingpong.rs @@ -82,7 +82,7 @@ endpoint. The send endpoint is returned to the caller and the receive endpoint is passed to the new task. */ -pub fn spawn_service( +pub fn spawn_service( init: extern fn() -> (RecvPacketBuffered, SendPacketBuffered), service: ~fn(v: RecvPacketBuffered)) @@ -103,7 +103,7 @@ pub fn spawn_service( receive state. */ -pub fn spawn_service_recv( +pub fn spawn_service_recv( init: extern fn() -> (SendPacketBuffered, RecvPacketBuffered), service: ~fn(v: SendPacketBuffered)) @@ -120,7 +120,7 @@ pub fn spawn_service_recv( client } -fn switch(endp: std::pipes::RecvPacketBuffered, +fn switch(endp: std::pipes::RecvPacketBuffered, f: &fn(v: Option) -> U) -> U { f(std::pipes::try_recv(endp)) diff --git a/src/test/compile-fail/closure-bounds-subtype.rs b/src/test/compile-fail/closure-bounds-subtype.rs index ebec113cedc53..9b3a58d010ed2 100644 --- a/src/test/compile-fail/closure-bounds-subtype.rs +++ b/src/test/compile-fail/closure-bounds-subtype.rs @@ -4,28 +4,28 @@ fn take_any(_: &fn()) { fn take_copyable(_: &fn:Copy()) { } -fn take_copyable_owned(_: &fn:Copy+Owned()) { +fn take_copyable_owned(_: &fn:Copy+Send()) { } fn give_any(f: &fn()) { take_any(f); take_copyable(f); //~ ERROR expected bounds `Copy` but found no bounds - take_copyable_owned(f); //~ ERROR expected bounds `Copy+Owned` but found no bounds + take_copyable_owned(f); //~ ERROR expected bounds `Copy+Send` but found no bounds } fn give_copyable(f: &fn:Copy()) { take_any(f); take_copyable(f); - take_copyable_owned(f); //~ ERROR expected bounds `Copy+Owned` but found bounds `Copy` + take_copyable_owned(f); //~ ERROR expected bounds `Copy+Send` but found bounds `Copy` } -fn give_owned(f: &fn:Owned()) { +fn give_owned(f: &fn:Send()) { take_any(f); - take_copyable(f); //~ ERROR expected bounds `Copy` but found bounds `Owned` - take_copyable_owned(f); //~ ERROR expected bounds `Copy+Owned` but found bounds `Owned` + take_copyable(f); //~ ERROR expected bounds `Copy` but found bounds `Send` + take_copyable_owned(f); //~ ERROR expected bounds `Copy+Send` but found bounds `Send` } -fn give_copyable_owned(f: &fn:Copy+Owned()) { +fn give_copyable_owned(f: &fn:Copy+Send()) { take_any(f); take_copyable(f); take_copyable_owned(f); diff --git a/src/test/compile-fail/issue-2611-4.rs b/src/test/compile-fail/issue-2611-4.rs index 2385be5723e2a..531d4eab53578 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 `Const` + fn b(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Freeze` } fn main() {} diff --git a/src/test/compile-fail/issue-2766-a.rs b/src/test/compile-fail/issue-2766-a.rs index 91ae0e1c07a55..c5d13c81b7c59 100644 --- a/src/test/compile-fail/issue-2766-a.rs +++ b/src/test/compile-fail/issue-2766-a.rs @@ -9,12 +9,12 @@ // except according to those terms. pub mod stream { - pub enum Stream { send(T, ::stream::server::Stream), } + pub enum Stream { send(T, ::stream::server::Stream), } pub mod server { use std::option; use std::pipes; - impl Stream { + impl Stream { pub fn recv() -> extern fn(v: Stream) -> ::stream::Stream { // resolve really should report just one error here. // Change the test case when it changes. @@ -28,7 +28,7 @@ pub mod stream { } } - pub type Stream = pipes::RecvPacket<::stream::Stream>; + pub type Stream = pipes::RecvPacket<::stream::Stream>; } } diff --git a/src/test/compile-fail/issue-3177-mutable-struct.rs b/src/test/compile-fail/issue-3177-mutable-struct.rs index 31c0dc7d9c4e2..180f13d037195 100644 --- a/src/test/compile-fail/issue-3177-mutable-struct.rs +++ b/src/test/compile-fail/issue-3177-mutable-struct.rs @@ -10,7 +10,7 @@ // xfail-test // error-pattern: instantiating a type parameter with an incompatible type -struct S { +struct S { s: T, cant_nest: () } diff --git a/src/test/compile-fail/kindck-destructor-owned.rs b/src/test/compile-fail/kindck-destructor-owned.rs index faad36a15d2fa..4c957d6bce4c5 100644 --- a/src/test/compile-fail/kindck-destructor-owned.rs +++ b/src/test/compile-fail/kindck-destructor-owned.rs @@ -2,7 +2,7 @@ struct Foo { f: @mut int, } -impl Drop for Foo { //~ ERROR cannot implement a destructor on a struct that is not Owned +impl Drop for Foo { //~ ERROR cannot implement a destructor on a struct that is not Send fn finalize(&self) { *self.f = 10; } diff --git a/src/test/compile-fail/liveness-use-after-send.rs b/src/test/compile-fail/liveness-use-after-send.rs index 23d3fff01cf3c..72555d7e85119 100644 --- a/src/test/compile-fail/liveness-use-after-send.rs +++ b/src/test/compile-fail/liveness-use-after-send.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn send(ch: _chan, data: T) { +fn send(ch: _chan, data: T) { debug!(ch); debug!(data); fail!(); diff --git a/src/test/compile-fail/mutable-enum.rs b/src/test/compile-fail/mutable-enum.rs index 2368e5eb5c51f..db2172b2e570f 100644 --- a/src/test/compile-fail/mutable-enum.rs +++ b/src/test/compile-fail/mutable-enum.rs @@ -11,9 +11,9 @@ #[mutable] enum Foo { A } -fn bar(_: T) {} +fn bar(_: T) {} fn main() { let x = A; - bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Const` + bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Freeze` } diff --git a/src/test/compile-fail/mutable-struct.rs b/src/test/compile-fail/mutable-struct.rs index ee040506c40bd..8511bcdcd3501 100644 --- a/src/test/compile-fail/mutable-struct.rs +++ b/src/test/compile-fail/mutable-struct.rs @@ -11,9 +11,9 @@ #[mutable] struct Foo { a: int } -fn bar(_: T) {} +fn bar(_: T) {} fn main() { let x = Foo { a: 5 }; - bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Const` + bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Freeze` } diff --git a/src/test/compile-fail/non_owned-enum.rs b/src/test/compile-fail/non_owned-enum.rs index 79c2be8183a62..6068b7f173030 100644 --- a/src/test/compile-fail/non_owned-enum.rs +++ b/src/test/compile-fail/non_owned-enum.rs @@ -11,9 +11,9 @@ #[non_owned] enum Foo { A } -fn bar(_: T) {} +fn bar(_: T) {} fn main() { let x = A; - bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Owned` + bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Send` } diff --git a/src/test/compile-fail/non_owned-struct.rs b/src/test/compile-fail/non_owned-struct.rs index 2d0bc9a7e8e46..b6f29df05752d 100644 --- a/src/test/compile-fail/non_owned-struct.rs +++ b/src/test/compile-fail/non_owned-struct.rs @@ -11,9 +11,9 @@ #[non_owned] struct Foo { a: int } -fn bar(_: T) {} +fn bar(_: T) {} fn main() { let x = Foo { a: 5 }; - bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Owned` + bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Send` } diff --git a/src/test/compile-fail/unique-unique-kind.rs b/src/test/compile-fail/unique-unique-kind.rs index 26058bf89cad7..d51df4979e352 100644 --- a/src/test/compile-fail/unique-unique-kind.rs +++ b/src/test/compile-fail/unique-unique-kind.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(_i: T) { +fn f(_i: T) { } fn main() { let i = ~@100; - f(i); //~ ERROR does not fulfill `Owned` + f(i); //~ ERROR does not fulfill `Send` } diff --git a/src/test/compile-fail/unsendable-class.rs b/src/test/compile-fail/unsendable-class.rs index 58de0926f7c66..de089dcf914b9 100644 --- a/src/test/compile-fail/unsendable-class.rs +++ b/src/test/compile-fail/unsendable-class.rs @@ -27,6 +27,6 @@ fn foo(i:int, j: @~str) -> foo { fn main() { let cat = ~"kitty"; - let (_, ch) = comm::stream(); //~ ERROR does not fulfill `Owned` - ch.send(foo(42, @(cat))); //~ ERROR does not fulfill `Owned` + let (_, ch) = comm::stream(); //~ ERROR does not fulfill `Send` + ch.send(foo(42, @(cat))); //~ ERROR does not fulfill `Send` } diff --git a/src/test/run-fail/bug-811.rs b/src/test/run-fail/bug-811.rs index b497b0224b9f7..992747187f635 100644 --- a/src/test/run-fail/bug-811.rs +++ b/src/test/run-fail/bug-811.rs @@ -19,6 +19,6 @@ struct chan_t { port: port_id, } -fn send(ch: chan_t, data: T) { fail!(); } +fn send(ch: chan_t, data: T) { fail!(); } fn main() { fail!("quux"); } diff --git a/src/test/run-pass/alignment-gep-tup-like-2.rs b/src/test/run-pass/alignment-gep-tup-like-2.rs index 6bf4e96bc053d..cfef97346a52d 100644 --- a/src/test/run-pass/alignment-gep-tup-like-2.rs +++ b/src/test/run-pass/alignment-gep-tup-like-2.rs @@ -23,7 +23,7 @@ fn make_cycle(a: A) { g.rec = Some(g); } -fn f(a: A, b: B) -> @fn() -> (A, B) { +fn f(a: A, b: B) -> @fn() -> (A, B) { let result: @fn() -> (A, B) = || (a, b); result } diff --git a/src/test/run-pass/const-bound.rs b/src/test/run-pass/const-bound.rs index 685d86c740d97..05f586f76e950 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/fixed-point-bind-unique.rs b/src/test/run-pass/fixed-point-bind-unique.rs index 53f9c723a4738..c7b64fde3fd5a 100644 --- a/src/test/run-pass/fixed-point-bind-unique.rs +++ b/src/test/run-pass/fixed-point-bind-unique.rs @@ -10,11 +10,11 @@ // xfail-fast -fn fix_help(f: extern fn(@fn(A) -> B, A) -> B, x: A) -> B { +fn fix_help(f: extern fn(@fn(A) -> B, A) -> B, x: A) -> B { return f(|a| fix_help(f, a), x); } -fn fix(f: extern fn(@fn(A) -> B, A) -> B) -> @fn(A) -> B { +fn fix(f: extern fn(@fn(A) -> B, A) -> B) -> @fn(A) -> B { return |a| fix_help(f, a); } diff --git a/src/test/run-pass/fn-bare-spawn.rs b/src/test/run-pass/fn-bare-spawn.rs index 4f0f451a08c09..e9954be93575c 100644 --- a/src/test/run-pass/fn-bare-spawn.rs +++ b/src/test/run-pass/fn-bare-spawn.rs @@ -10,7 +10,7 @@ // This is what the signature to spawn should look like with bare functions -fn spawn(val: T, f: extern fn(T)) { +fn spawn(val: T, f: extern fn(T)) { f(val); } diff --git a/src/test/run-pass/generic-alias-unique.rs b/src/test/run-pass/generic-alias-unique.rs index ad271186639bd..815cc1bc79bcd 100644 --- a/src/test/run-pass/generic-alias-unique.rs +++ b/src/test/run-pass/generic-alias-unique.rs @@ -10,7 +10,7 @@ -fn id(t: T) -> T { return t; } +fn id(t: T) -> T { return t; } pub fn main() { let expected = ~100; diff --git a/src/test/run-pass/issue-2611-3.rs b/src/test/run-pass/issue-2611-3.rs index acc6ffd0dd1b3..7f6535526312a 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/issue-2718.rs b/src/test/run-pass/issue-2718.rs index 4ef83e405be40..b01216ff8feb7 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -39,7 +39,7 @@ pub mod pipes { payload: Option } - pub fn packet() -> *packet { + pub fn packet() -> *packet { unsafe { let p: *packet = cast::transmute(~Stuff{ state: empty, @@ -74,7 +74,7 @@ pub mod pipes { } } - pub fn send(mut p: send_packet, payload: T) { + pub fn send(mut p: send_packet, payload: T) { let mut p = p.unwrap(); let mut p = unsafe { uniquify(p) }; assert!((*p).payload.is_none()); @@ -100,7 +100,7 @@ pub mod pipes { } } - pub fn recv(mut p: recv_packet) -> Option { + pub fn recv(mut p: recv_packet) -> Option { let mut p = p.unwrap(); let mut p = unsafe { uniquify(p) }; loop { @@ -120,7 +120,7 @@ pub mod pipes { } } - pub fn sender_terminate(mut p: *packet) { + pub fn sender_terminate(mut p: *packet) { let mut p = unsafe { uniquify(p) }; match swap_state_rel(&mut (*p).state, terminated) { empty | blocked => { @@ -137,7 +137,7 @@ pub mod pipes { } } - pub fn receiver_terminate(mut p: *packet) { + pub fn receiver_terminate(mut p: *packet) { let mut p = unsafe { uniquify(p) }; match swap_state_rel(&mut (*p).state, terminated) { empty => { @@ -159,7 +159,7 @@ pub mod pipes { } #[unsafe_destructor] - impl Drop for send_packet { + impl Drop for send_packet { fn finalize(&self) { unsafe { if self.p != None { @@ -172,13 +172,13 @@ pub mod pipes { } } - impl send_packet { + impl send_packet { pub fn unwrap(&mut self) -> *packet { util::replace(&mut self.p, None).unwrap() } } - pub fn send_packet(p: *packet) -> send_packet { + pub fn send_packet(p: *packet) -> send_packet { send_packet { p: Some(p) } @@ -189,7 +189,7 @@ pub mod pipes { } #[unsafe_destructor] - impl Drop for recv_packet { + impl Drop for recv_packet { fn finalize(&self) { unsafe { if self.p != None { @@ -202,19 +202,19 @@ pub mod pipes { } } - impl recv_packet { + impl recv_packet { pub fn unwrap(&mut self) -> *packet { util::replace(&mut self.p, None).unwrap() } } - pub fn recv_packet(p: *packet) -> recv_packet { + pub fn recv_packet(p: *packet) -> recv_packet { recv_packet { p: Some(p) } } - pub fn entangle() -> (send_packet, recv_packet) { + pub fn entangle() -> (send_packet, recv_packet) { let p = packet(); (send_packet(p), recv_packet(p)) } diff --git a/src/test/run-pass/issue-2834.rs b/src/test/run-pass/issue-2834.rs index 5d3a2d2331c90..b0ddccf28944b 100644 --- a/src/test/run-pass/issue-2834.rs +++ b/src/test/run-pass/issue-2834.rs @@ -12,7 +12,7 @@ // proto! streamp ( - open:send { + open:send { data(T) -> open } ) diff --git a/src/test/run-pass/issue-2930.rs b/src/test/run-pass/issue-2930.rs index cfce19826d7e0..10a19d62bd97b 100644 --- a/src/test/run-pass/issue-2930.rs +++ b/src/test/run-pass/issue-2930.rs @@ -9,7 +9,7 @@ // except according to those terms. proto! stream ( - Stream:send { + Stream:send { send(T) -> Stream } ) diff --git a/src/test/run-pass/pipe-bank-proto.rs b/src/test/run-pass/pipe-bank-proto.rs index d723fa3220945..47ab69e0b36ae 100644 --- a/src/test/run-pass/pipe-bank-proto.rs +++ b/src/test/run-pass/pipe-bank-proto.rs @@ -49,7 +49,7 @@ macro_rules! move_it ( { $x:expr } => { unsafe { let y = *ptr::to_unsafe_ptr(&($x)); y } } ) -fn switch(endp: pipes::RecvPacket, +fn switch(endp: pipes::RecvPacket, f: &fn(v: Option) -> U) -> U { f(pipes::try_recv(endp)) } diff --git a/src/test/run-pass/pipe-select.rs b/src/test/run-pass/pipe-select.rs index 0a860d0a1e22c..36f144152f2a3 100644 --- a/src/test/run-pass/pipe-select.rs +++ b/src/test/run-pass/pipe-select.rs @@ -29,12 +29,12 @@ proto! oneshot ( ) proto! stream ( - Stream:send { + Stream:send { send(T) -> Stream } ) -pub fn spawn_service( +pub fn spawn_service( init: extern fn() -> (RecvPacketBuffered, SendPacketBuffered), service: ~fn(v: RecvPacketBuffered)) diff --git a/src/test/run-pass/pipe-sleep.rs b/src/test/run-pass/pipe-sleep.rs index dc88f36ba113a..dbf860cd04075 100644 --- a/src/test/run-pass/pipe-sleep.rs +++ b/src/test/run-pass/pipe-sleep.rs @@ -33,7 +33,7 @@ endpoint. The send endpoint is returned to the caller and the receive endpoint is passed to the new task. */ -pub fn spawn_service( +pub fn spawn_service( init: extern fn() -> (RecvPacketBuffered, SendPacketBuffered), service: ~fn(v: RecvPacketBuffered)) diff --git a/src/test/run-pass/send-type-inference.rs b/src/test/run-pass/send-type-inference.rs index bdb1fbaf42261..4fcbc789f57b2 100644 --- a/src/test/run-pass/send-type-inference.rs +++ b/src/test/run-pass/send-type-inference.rs @@ -16,7 +16,7 @@ struct Command { val: V } -fn cache_server(c: Chan>>) { +fn cache_server(c: Chan>>) { let (ctrl_port, ctrl_chan) = stream(); c.send(ctrl_chan); } diff --git a/src/test/run-pass/type-param-constraints.rs b/src/test/run-pass/type-param-constraints.rs index bd6165806c273..fd721e00f2558 100644 --- a/src/test/run-pass/type-param-constraints.rs +++ b/src/test/run-pass/type-param-constraints.rs @@ -12,7 +12,7 @@ fn p_foo(pinned: T) { } fn s_foo(shared: T) { } -fn u_foo(unique: T) { } +fn u_foo(unique: T) { } struct r { i: int, diff --git a/src/test/run-pass/uniq-cc-generic.rs b/src/test/run-pass/uniq-cc-generic.rs index b54b3b52692ed..2c3424d1f06fd 100644 --- a/src/test/run-pass/uniq-cc-generic.rs +++ b/src/test/run-pass/uniq-cc-generic.rs @@ -20,7 +20,7 @@ struct Pointy { d : ~fn() -> uint, } -fn make_uniq_closure(a: A) -> ~fn() -> uint { +fn make_uniq_closure(a: A) -> ~fn() -> uint { let result: ~fn() -> uint = || ptr::to_unsafe_ptr(&a) as uint; result } diff --git a/src/test/run-pass/unique-kinds.rs b/src/test/run-pass/unique-kinds.rs index b3ce71dcbff5d..391881deff668 100644 --- a/src/test/run-pass/unique-kinds.rs +++ b/src/test/run-pass/unique-kinds.rs @@ -12,11 +12,11 @@ use std::cmp::Eq; fn sendable() { - fn f(i: T, j: T) { + fn f(i: T, j: T) { assert_eq!(i, j); } - fn g(i: T, j: T) { + fn g(i: T, j: T) { assert!(i != j); }