diff --git a/doc/rust.md b/doc/rust.md index 7a88086e0ddd7..e0c00c4d23c79 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -2725,11 +2725,11 @@ The kinds are: `Const` : Types of this kind are deeply immutable; they contain no mutable memory locations directly or indirectly via pointers. -`Send` +`Owned` : Types of this kind can be safely sent between tasks. This kind includes scalars, owning pointers, owned closures, and - structural types containing only other sendable types. -`Owned` + structural types containing only other owned types. All `Owned` types are `Static`. +`Static` : Types of this kind do not contain any borrowed pointers; this can be a useful guarantee for code that breaks borrowing assumptions using [`unsafe` operations](#unsafe-functions). `Copy` @@ -2818,10 +2818,10 @@ frame they are allocated within. A task owns all memory it can *safely* reach through local variables, as well as managed, owning and borrowed pointers. -When a task sends a value that has the `Send` trait to another task, +When a task sends a value that has the `Owned` trait to another task, it loses ownership of the value sent and can no longer refer to it. This is statically guaranteed by the combined use of "move semantics", -and the compiler-checked _meaning_ of the `Send` trait: +and the compiler-checked _meaning_ of the `Owned` trait: it is only instantiated for (transitively) sendable kinds of data constructor and pointers, never including managed or borrowed pointers. @@ -2956,7 +2956,7 @@ These include: - read-only and read-write shared variables with various safe mutual exclusion patterns - simple locks and semaphores -When such facilities carry values, the values are restricted to the [`Send` type-kind](#type-kinds). +When such facilities carry values, the values are restricted to the [`Owned` type-kind](#type-kinds). Restricting communication interfaces to this kind ensures that no borrowed or managed pointers move between tasks. Thus access to an entire data structure can be mediated through its owning "root" value; no further locking or copying is required to avoid data races within the substructure of such a value. diff --git a/doc/tutorial.md b/doc/tutorial.md index b7a07f4021a5a..4b443b0da4daa 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1914,9 +1914,9 @@ types by the compiler, and may not be overridden: `copy` operator. All types are copyable unless they have destructors or contain types with destructors. -* `Send` - Sendable (owned) types. All types are sendable unless they - contain managed boxes, managed closures, or otherwise managed - types. Sendable types may or may not be copyable. +* `Owned` - Owned types. Types are owned unless they contain managed + boxes, managed closures, or borrowed pointers. Owned types may or + may not be copyable. * `Const` - Constant (immutable) types. These are types that do not contain mutable fields. @@ -1949,7 +1949,7 @@ may call it. ## Declaring and implementing traits A trait consists of a set of methods, without bodies, or may be empty, -as is the case with `Copy`, `Send`, and `Const`. For example, we could +as is the case with `Copy`, `Owned`, and `Const`. For example, we could declare the trait `Printable` for things that can be printed to the console, with a single method: diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index 64395470c847d..0f3c7fc4edc89 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -57,7 +57,7 @@ use libc::size_t; * transmitted. If a port value is copied, both copies refer to the same * port. Ports may be associated with multiple `chan`s. */ -pub enum Port { +pub enum Port { Port_(@PortPtr) } @@ -73,16 +73,16 @@ pub enum Port { * data will be silently dropped. Channels may be duplicated and * themselves transmitted over other channels. */ -pub enum Chan { +pub enum Chan { Chan_(port_id) } /// Constructs a port -pub fn Port() -> Port { +pub fn Port() -> Port { Port_(@PortPtr(rustrt::new_port(sys::size_of::() as size_t))) } -impl Port { +impl Port { fn chan() -> Chan { Chan(&self) } fn send(v: T) { self.chan().send(move v) } @@ -91,7 +91,7 @@ impl Port { } -impl Chan { +impl Chan { fn chan() -> Chan { self } fn send(v: T) { send(self, move v) } @@ -101,12 +101,12 @@ impl Chan { } /// Open a new receiving channel for the duration of a function -pub fn listen(f: fn(Chan) -> U) -> U { +pub fn listen(f: fn(Chan) -> U) -> U { let po = Port(); f(po.chan()) } -struct PortPtr { +struct PortPtr { po: *rust_port, drop unsafe { do task::unkillable { @@ -130,7 +130,7 @@ struct PortPtr { } } -fn PortPtr(po: *rust_port) -> PortPtr { +fn PortPtr(po: *rust_port) -> PortPtr { PortPtr { po: po } @@ -144,7 +144,7 @@ fn PortPtr(po: *rust_port) -> PortPtr { * Fails if the port is detached or dead. Fails if the port * is owned by a different task. */ -fn as_raw_port(ch: comm::Chan, f: fn(*rust_port) -> U) -> U { +fn as_raw_port(ch: comm::Chan, f: fn(*rust_port) -> U) -> U { struct PortRef { p: *rust_port, @@ -176,7 +176,7 @@ fn as_raw_port(ch: comm::Chan, f: fn(*rust_port) -> U) -> U { * Constructs a channel. The channel is bound to the port used to * construct it. */ -pub fn Chan(p: &Port) -> Chan { +pub fn Chan(p: &Port) -> Chan { Chan_(rustrt::get_port_id((**p).po)) } @@ -184,7 +184,7 @@ pub fn Chan(p: &Port) -> Chan { * Sends data over a channel. The sent data is moved into the channel, * whereupon the caller loses access to it. */ -pub fn send(ch: Chan, data: T) { +pub fn send(ch: Chan, data: T) { let Chan_(p) = ch; let data_ptr = ptr::addr_of(&data) as *(); let res = rustrt::rust_port_id_send(p, data_ptr); @@ -199,22 +199,22 @@ pub fn send(ch: Chan, data: T) { * Receive from a port. If no data is available on the port then the * task will block until data becomes available. */ -pub fn recv(p: Port) -> T { recv_((**p).po) } +pub fn recv(p: Port) -> T { recv_((**p).po) } /// Returns true if there are messages available -pub fn peek(p: Port) -> bool { peek_((**p).po) } +pub fn peek(p: Port) -> bool { peek_((**p).po) } #[doc(hidden)] -pub fn recv_chan(ch: comm::Chan) -> T { +pub fn recv_chan(ch: comm::Chan) -> T { as_raw_port(ch, |x|recv_(x)) } -fn peek_chan(ch: comm::Chan) -> bool { +fn peek_chan(ch: comm::Chan) -> bool { as_raw_port(ch, |x|peek_(x)) } /// Receive on a raw port pointer -fn recv_(p: *rust_port) -> T { +fn recv_(p: *rust_port) -> T { let yield = 0; let yieldp = ptr::addr_of(&yield); let mut res; @@ -240,7 +240,7 @@ fn peek_(p: *rust_port) -> bool { } /// Receive on one of two ports -pub fn select2(p_a: Port, p_b: Port) +pub fn select2(p_a: Port, p_b: Port) -> Either { let ports = ~[(**p_a).po, (**p_b).po]; let yield = 0, yieldp = ptr::addr_of(&yield); diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 5f313244e2758..fade2dd2fb39a 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -167,7 +167,7 @@ pub mod util; /* Reexported core operators */ -pub use kinds::{Const, Copy, Send, Owned}; +pub use kinds::{Const, Copy, Owned, Static}; pub use ops::{Drop}; pub use ops::{Add, Sub, Mul, Div, Modulo, Neg}; pub use ops::{BitAnd, BitOr, BitXor}; diff --git a/src/libcore/kinds.rs b/src/libcore/kinds.rs index c5a4a3a9dac5e..3295ef94fbc54 100644 --- a/src/libcore/kinds.rs +++ b/src/libcore/kinds.rs @@ -24,15 +24,13 @@ The 4 kinds are scalar types and managed pointers, and exludes owned pointers. It also excludes types that implement `Drop`. -* Send - owned types and types containing owned types. These types +* Owned - 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. -* Owned - types that do not contain borrowed pointers. Note that this - meaning of 'owned' conflicts with 'owned pointers'. The two notions - of ownership are different. +* Static - types that do not contain borrowed pointers. `Copy` types include both implicitly copyable types that the compiler will copy automatically and non-implicitly copyable types that require @@ -46,8 +44,17 @@ pub trait Copy { // Empty. } +#[cfg(stage0)] #[lang="send"] -pub trait Send { +pub trait Owned { + // Empty. +} + +#[cfg(stage1)] +#[cfg(stage2)] +#[cfg(stage3)] +#[lang="owned"] +pub trait Owned { // Empty. } @@ -56,7 +63,16 @@ pub trait Const { // Empty. } +#[cfg(stage0)] #[lang="owned"] -pub trait Owned { +pub trait Static { + // Empty. +} + +#[cfg(stage1)] +#[cfg(stage2)] +#[cfg(stage3)] +#[lang="static"] +pub trait Static { // Empty. } diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index c298213fb7c1c..aeaa321178644 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -131,7 +131,7 @@ pub fn BufferHeader() -> BufferHeader{ // This is for protocols to associate extra data to thread around. #[doc(hidden)] -type Buffer = { +type Buffer = { header: BufferHeader, data: T, }; @@ -180,13 +180,13 @@ impl PacketHeader { reinterpret_cast(&self.buffer) } - fn set_buffer(b: ~Buffer) unsafe { + fn set_buffer(b: ~Buffer) unsafe { self.buffer = reinterpret_cast(&b); } } #[doc(hidden)] -pub type Packet = { +pub type Packet = { header: PacketHeader, mut payload: Option, }; @@ -197,14 +197,14 @@ pub trait HasBuffer { fn set_buffer_(b: *libc::c_void); } -impl Packet: HasBuffer { +impl Packet: HasBuffer { fn set_buffer_(b: *libc::c_void) { self.header.buffer = b; } } #[doc(hidden)] -pub fn mk_packet() -> Packet { +pub fn mk_packet() -> Packet { { header: PacketHeader(), mut payload: None @@ -212,7 +212,7 @@ pub fn mk_packet() -> Packet { } #[doc(hidden)] -fn unibuffer() -> ~Buffer> { +fn unibuffer() -> ~Buffer> { let b = ~{ header: BufferHeader(), data: { @@ -228,7 +228,7 @@ fn unibuffer() -> ~Buffer> { } #[doc(hidden)] -pub fn packet() -> *Packet { +pub fn packet() -> *Packet { let b = unibuffer(); let p = ptr::addr_of(&(b.data)); // We'll take over memory management from here. @@ -237,7 +237,7 @@ pub fn packet() -> *Packet { } #[doc(hidden)] -pub fn entangle_buffer( +pub fn entangle_buffer( buffer: ~Buffer, init: fn(*libc::c_void, x: &T) -> *Packet) -> (SendPacketBuffered, RecvPacketBuffered) @@ -329,12 +329,12 @@ fn swap_state_rel(dst: &mut State, src: State) -> State { } #[doc(hidden)] -pub unsafe fn get_buffer(p: *PacketHeader) -> ~Buffer { +pub unsafe fn get_buffer(p: *PacketHeader) -> ~Buffer { transmute((*p).buf_header()) } // This could probably be done with SharedMutableState to avoid move_it!(). -struct BufferResource { +struct BufferResource { buffer: ~Buffer, drop unsafe { @@ -354,7 +354,7 @@ struct BufferResource { } } -fn BufferResource(b: ~Buffer) -> BufferResource { +fn BufferResource(b: ~Buffer) -> BufferResource { //let p = ptr::addr_of(*b); //error!("take %?", p); atomic_add_acq(&mut b.header.ref_count, 1); @@ -366,7 +366,7 @@ fn BufferResource(b: ~Buffer) -> BufferResource { } #[doc(hidden)] -pub fn send(p: SendPacketBuffered, +pub fn send(p: SendPacketBuffered, payload: T) -> bool { let header = p.header(); let p_ = p.unwrap(); @@ -410,7 +410,8 @@ pub fn send(p: SendPacketBuffered, Fails if the sender closes the connection. */ -pub fn recv(p: RecvPacketBuffered) -> T { +pub fn recv( + p: RecvPacketBuffered) -> T { option::unwrap_expect(try_recv(move p), "connection closed") } @@ -420,7 +421,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(p: RecvPacketBuffered) +pub fn try_recv(p: RecvPacketBuffered) -> Option { let p_ = p.unwrap(); @@ -519,7 +520,7 @@ pub fn try_recv(p: RecvPacketBuffered) } /// Returns true if messages are available. -pub pure fn peek(p: &RecvPacketBuffered) -> bool { +pub pure fn peek(p: &RecvPacketBuffered) -> bool { match unsafe {(*p.header()).state} { Empty | Terminated => false, Blocked => fail ~"peeking on blocked packet", @@ -527,14 +528,14 @@ pub pure fn peek(p: &RecvPacketBuffered) -> bool { } } -impl RecvPacketBuffered: Peekable { +impl RecvPacketBuffered: Peekable { pure fn peek() -> bool { peek(&self) } } #[doc(hidden)] -fn sender_terminate(p: *Packet) { +fn sender_terminate(p: *Packet) { let p = unsafe { &*p }; match swap_state_rel(&mut p.header.state, Terminated) { Empty => { @@ -563,7 +564,7 @@ fn sender_terminate(p: *Packet) { } #[doc(hidden)] -fn receiver_terminate(p: *Packet) { +fn receiver_terminate(p: *Packet) { let p = unsafe { &*p }; match swap_state_rel(&mut p.header.state, Terminated) { Empty => { @@ -671,7 +672,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( a: RecvPacketBuffered, b: RecvPacketBuffered) -> Either<(Option, RecvPacketBuffered), @@ -714,7 +715,7 @@ pub fn select2i(a: &A, b: &B) -> list of the remaining endpoints. */ -pub fn select(endpoints: ~[RecvPacketBuffered]) +pub fn select(endpoints: ~[RecvPacketBuffered]) -> (uint, Option, ~[RecvPacketBuffered]) { let ready = wait_many(endpoints.map(|p| p.header())); @@ -728,14 +729,14 @@ pub fn select(endpoints: ~[RecvPacketBuffered]) message. */ -pub type SendPacket = SendPacketBuffered>; +pub type SendPacket = SendPacketBuffered>; #[doc(hidden)] -pub fn SendPacket(p: *Packet) -> SendPacket { +pub fn SendPacket(p: *Packet) -> SendPacket { SendPacketBuffered(p) } -pub struct SendPacketBuffered { +pub struct SendPacketBuffered { mut p: Option<*Packet>, mut buffer: Option>, drop { @@ -754,7 +755,7 @@ pub struct SendPacketBuffered { } } -pub fn SendPacketBuffered(p: *Packet) +pub fn SendPacketBuffered(p: *Packet) -> SendPacketBuffered { //debug!("take send %?", p); SendPacketBuffered { @@ -766,7 +767,7 @@ pub fn SendPacketBuffered(p: *Packet) } } -impl SendPacketBuffered { +impl SendPacketBuffered { fn unwrap() -> *Packet { let mut p = None; p <-> self.p; @@ -795,14 +796,14 @@ impl SendPacketBuffered { /// Represents the receive end of a pipe. It can receive exactly one /// message. -pub type RecvPacket = RecvPacketBuffered>; +pub type RecvPacket = RecvPacketBuffered>; #[doc(hidden)] -pub fn RecvPacket(p: *Packet) -> RecvPacket { +pub fn RecvPacket(p: *Packet) -> RecvPacket { RecvPacketBuffered(p) } -pub struct RecvPacketBuffered { +pub struct RecvPacketBuffered { mut p: Option<*Packet>, mut buffer: Option>, drop { @@ -821,7 +822,7 @@ pub struct RecvPacketBuffered { } } -impl RecvPacketBuffered { +impl RecvPacketBuffered { fn unwrap() -> *Packet { let mut p = None; p <-> self.p; @@ -836,7 +837,7 @@ impl RecvPacketBuffered { } } -impl RecvPacketBuffered : Selectable { +impl RecvPacketBuffered : Selectable { pure fn header() -> *PacketHeader { match self.p { Some(packet) => unsafe { @@ -850,7 +851,7 @@ impl RecvPacketBuffered : Selectable { } } -pub fn RecvPacketBuffered(p: *Packet) +pub fn RecvPacketBuffered(p: *Packet) -> RecvPacketBuffered { //debug!("take recv %?", p); RecvPacketBuffered { @@ -863,7 +864,7 @@ pub fn RecvPacketBuffered(p: *Packet) } #[doc(hidden)] -pub fn entangle() -> (SendPacket, RecvPacket) { +pub fn entangle() -> (SendPacket, RecvPacket) { let p = packet(); (SendPacket(p), RecvPacket(p)) } @@ -875,7 +876,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() -> (SendPacketBuffered, RecvPacketBuffered), service: fn~(v: RecvPacketBuffered)) @@ -899,7 +900,7 @@ pub fn spawn_service( receive state. */ -pub fn spawn_service_recv( +pub fn spawn_service_recv( init: extern fn() -> (RecvPacketBuffered, SendPacketBuffered), service: fn~(v: SendPacketBuffered)) @@ -922,7 +923,7 @@ pub fn spawn_service_recv( // Streams - Make pipes a little easier in general. proto! streamp ( - Open:send { + Open:send { data(T) -> Open } ) @@ -958,18 +959,18 @@ pub trait Peekable { } #[doc(hidden)] -type Chan_ = { mut endp: Option> }; +type Chan_ = { mut endp: Option> }; /// An endpoint that can send many messages. -pub enum Chan { +pub enum Chan { Chan_(Chan_) } #[doc(hidden)] -type Port_ = { mut endp: Option> }; +type Port_ = { mut endp: Option> }; /// An endpoint that can receive many messages. -pub enum Port { +pub enum Port { Port_(Port_) } @@ -978,13 +979,13 @@ pub enum Port { These allow sending or receiving an unlimited number of messages. */ -pub fn stream() -> (Chan, Port) { +pub fn stream() -> (Chan, Port) { let (c, s) = streamp::init(); (Chan_({ mut endp: Some(move c) }), Port_({ mut endp: Some(move s) })) } -impl Chan: GenericChan { +impl Chan: GenericChan { fn send(x: T) { let mut endp = None; endp <-> self.endp; @@ -993,7 +994,7 @@ impl Chan: GenericChan { } } -impl Chan: GenericSmartChan { +impl Chan: GenericSmartChan { fn try_send(x: T) -> bool { let mut endp = None; @@ -1008,7 +1009,7 @@ impl Chan: GenericSmartChan { } } -impl Port: GenericPort { +impl Port: GenericPort { fn recv() -> T { let mut endp = None; endp <-> self.endp; @@ -1030,7 +1031,7 @@ impl Port: GenericPort { } } -impl Port: Peekable { +impl Port: Peekable { pure fn peek() -> bool unsafe { let mut endp = None; endp <-> self.endp; @@ -1043,7 +1044,7 @@ impl Port: Peekable { } } -impl Port: Selectable { +impl Port: Selectable { pure fn header() -> *PacketHeader unsafe { match self.endp { Some(ref endp) => endp.header(), @@ -1053,17 +1054,17 @@ impl Port: Selectable { } /// Treat many ports as one. -pub struct PortSet { +pub struct PortSet { mut ports: ~[pipes::Port], } -pub fn PortSet() -> PortSet{ +pub fn PortSet() -> PortSet{ PortSet { ports: ~[] } } -impl PortSet { +impl PortSet { fn add(port: pipes::Port) { self.ports.push(move port) @@ -1076,7 +1077,7 @@ impl PortSet { } } -impl PortSet : GenericPort { +impl PortSet : GenericPort { fn try_recv() -> Option { let mut result = None; @@ -1106,7 +1107,7 @@ impl PortSet : GenericPort { } -impl PortSet : Peekable { +impl PortSet : Peekable { pure fn peek() -> bool { // It'd be nice to use self.port.each, but that version isn't // pure. @@ -1118,9 +1119,9 @@ impl PortSet : Peekable { } /// A channel that can be shared between many senders. -pub type SharedChan = private::Exclusive>; +pub type SharedChan = private::Exclusive>; -impl SharedChan: GenericChan { +impl SharedChan: GenericChan { fn send(x: T) { let mut xx = Some(move x); do self.with_imm |chan| { @@ -1131,7 +1132,7 @@ impl SharedChan: GenericChan { } } -impl SharedChan: GenericSmartChan { +impl SharedChan: GenericSmartChan { fn try_send(x: T) -> bool { let mut xx = Some(move x); do self.with_imm |chan| { @@ -1143,19 +1144,19 @@ impl SharedChan: GenericSmartChan { } /// Converts a `chan` into a `shared_chan`. -pub fn SharedChan(c: Chan) -> SharedChan { +pub fn SharedChan(c: Chan) -> SharedChan { private::exclusive(move c) } /// 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() -> Either, Option>; /// Receive a message or fail if a connection closes. fn select() -> Either; } -impl, Right: Selectable GenericPort> (Left, Right): Select2 { @@ -1180,18 +1181,18 @@ impl { + Oneshot:send { send(T) -> ! } ) /// The send end of a oneshot pipe. -pub type ChanOne = oneshot::client::Oneshot; +pub type ChanOne = oneshot::client::Oneshot; /// The receive end of a oneshot pipe. -pub type PortOne = oneshot::server::Oneshot; +pub type PortOne = oneshot::server::Oneshot; /// Initialiase a (send-endpoint, recv-endpoint) oneshot pipe pair. -pub fn oneshot() -> (ChanOne, PortOne) { +pub fn oneshot() -> (ChanOne, PortOne) { oneshot::init() } @@ -1199,13 +1200,13 @@ pub fn oneshot() -> (ChanOne, PortOne) { * 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 { let oneshot::send(message) = recv(move port); move message } /// 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 { let message = try_recv(move port); if message.is_none() { None } @@ -1216,7 +1217,7 @@ pub fn try_recv_one (port: PortOne) -> Option { } /// 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) { oneshot::client::send(move chan, move data); } @@ -1224,7 +1225,7 @@ pub fn send_one(chan: ChanOne, data: T) { * Send a message on a oneshot pipe, or return false if the connection was * closed. */ -pub fn try_send_one(chan: ChanOne, data: T) +pub fn try_send_one(chan: ChanOne, data: T) -> bool { oneshot::client::try_send(move chan, move data).is_some() } diff --git a/src/libcore/private.rs b/src/libcore/private.rs index 2b6156b14c4bd..85735a82beeb3 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -52,7 +52,7 @@ fn compare_and_swap(address: &mut int, oldval: int, newval: int) -> bool { * or, if no channel exists creates and installs a new channel and sets up a * new task to receive from it. */ -pub unsafe fn chan_from_global_ptr( +pub unsafe fn chan_from_global_ptr( global: GlobalPtr, task_fn: fn() -> task::TaskBuilder, f: fn~(comm::Port) @@ -350,7 +350,7 @@ fn ArcDestruct(data: *libc::c_void) -> ArcDestruct { } } -pub unsafe fn unwrap_shared_mutable_state(rc: SharedMutableState) +pub unsafe fn unwrap_shared_mutable_state(rc: SharedMutableState) -> T { struct DeathThroes { mut ptr: Option<~ArcData>, @@ -421,9 +421,9 @@ pub unsafe fn unwrap_shared_mutable_state(rc: SharedMutableState) * Data races between tasks can result in crashes and, with sufficient * cleverness, arbitrary type coercion. */ -pub type SharedMutableState = ArcDestruct; +pub type SharedMutableState = ArcDestruct; -pub unsafe fn shared_mutable_state(data: T) -> +pub unsafe fn shared_mutable_state(data: T) -> SharedMutableState { let data = ~ArcData { count: 1, unwrapper: 0, data: Some(move data) }; unsafe { @@ -433,7 +433,7 @@ pub unsafe fn shared_mutable_state(data: T) -> } #[inline(always)] -pub unsafe fn get_shared_mutable_state(rc: &a/SharedMutableState) +pub unsafe fn get_shared_mutable_state(rc: &a/SharedMutableState) -> &a/mut T { unsafe { let ptr: ~ArcData = cast::reinterpret_cast(&(*rc).data); @@ -445,7 +445,7 @@ pub unsafe fn get_shared_mutable_state(rc: &a/SharedMutableState) } } #[inline(always)] -pub unsafe fn get_shared_immutable_state( +pub unsafe fn get_shared_immutable_state( rc: &a/SharedMutableState) -> &a/T { unsafe { let ptr: ~ArcData = cast::reinterpret_cast(&(*rc).data); @@ -457,7 +457,7 @@ pub unsafe fn get_shared_immutable_state( } } -pub unsafe fn clone_shared_mutable_state(rc: &SharedMutableState) +pub unsafe fn clone_shared_mutable_state(rc: &SharedMutableState) -> SharedMutableState { unsafe { let ptr: ~ArcData = cast::reinterpret_cast(&(*rc).data); @@ -506,27 +506,27 @@ impl LittleLock { } } -struct ExData { lock: LittleLock, mut failed: bool, mut data: T, } +struct ExData { lock: LittleLock, mut failed: bool, mut data: T, } /** * An arc over mutable data that is protected by a lock. For library use only. */ -pub struct Exclusive { x: SharedMutableState> } +pub struct Exclusive { x: SharedMutableState> } -pub fn exclusive(user_data: T) -> Exclusive { +pub fn exclusive(user_data: T) -> Exclusive { let data = ExData { lock: LittleLock(), mut failed: false, mut data: move user_data }; Exclusive { x: unsafe { shared_mutable_state(move data) } } } -impl Exclusive: Clone { +impl Exclusive: Clone { // Duplicate an exclusive ARC, as std::arc::clone. fn clone(&self) -> Exclusive { Exclusive { x: unsafe { clone_shared_mutable_state(&self.x) } } } } -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. // @@ -556,7 +556,7 @@ impl Exclusive { } // FIXME(#3724) make this a by-move method on the exclusive -pub fn unwrap_exclusive(arc: Exclusive) -> T { +pub fn unwrap_exclusive(arc: Exclusive) -> T { let Exclusive { x: x } = move arc; let inner = unsafe { unwrap_shared_mutable_state(move x) }; let ExData { data: data, _ } = move inner; diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs index cc0353a354b69..19ecdf22e0d6c 100644 --- a/src/libcore/task/local_data.rs +++ b/src/libcore/task/local_data.rs @@ -47,13 +47,13 @@ use local_data_priv::{ * * These two cases aside, the interface is safe. */ -pub type LocalDataKey = &fn(v: @T); +pub type LocalDataKey = &fn(v: @T); /** * Remove a task-local data value from the table, returning the * reference that was originally created to insert it. */ -pub unsafe fn local_data_pop( +pub unsafe fn local_data_pop( key: LocalDataKey) -> Option<@T> { local_pop(rt::rust_get_task(), key) @@ -62,7 +62,7 @@ pub unsafe fn local_data_pop( * Retrieve a task-local data value. It will also be kept alive in the * table until explicitly removed. */ -pub unsafe fn local_data_get( +pub unsafe fn local_data_get( key: LocalDataKey) -> Option<@T> { local_get(rt::rust_get_task(), key) @@ -71,7 +71,7 @@ pub unsafe fn local_data_get( * Store a value in task-local data. If this key already has a value, * that value is overwritten (and its destructor is run). */ -pub unsafe fn local_data_set( +pub unsafe fn local_data_set( key: LocalDataKey, data: @T) { local_set(rt::rust_get_task(), key, data) @@ -80,7 +80,7 @@ pub unsafe fn local_data_set( * Modify a task-local data value. If the function returns 'None', the * data is removed (and its reference dropped). */ -pub unsafe fn local_data_modify( +pub unsafe fn local_data_modify( key: LocalDataKey, modify_fn: fn(Option<@T>) -> Option<@T>) { diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index 494801d88ea4e..88952972764c0 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -14,7 +14,7 @@ use local_data::LocalDataKey; use rt::rust_task; pub trait LocalData { } -impl @T: LocalData { } +impl @T: LocalData { } impl LocalData: Eq { pure fn eq(&self, other: &@LocalData) -> bool unsafe { @@ -62,7 +62,7 @@ unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap { } } -unsafe fn key_to_key_value( +unsafe fn key_to_key_value( key: LocalDataKey) -> *libc::c_void { // Keys are closures, which are (fnptr,envptr) pairs. Use fnptr. @@ -72,7 +72,7 @@ unsafe fn key_to_key_value( } // If returning Some(..), returns with @T with the map's reference. Careful! -unsafe fn local_data_lookup( +unsafe fn local_data_lookup( map: TaskLocalMap, key: LocalDataKey) -> Option<(uint, *libc::c_void)> { @@ -90,7 +90,7 @@ unsafe fn local_data_lookup( } } -unsafe fn local_get_helper( +unsafe fn local_get_helper( task: *rust_task, key: LocalDataKey, do_pop: bool) -> Option<@T> { @@ -112,21 +112,21 @@ unsafe fn local_get_helper( } -pub unsafe fn local_pop( +pub unsafe fn local_pop( task: *rust_task, key: LocalDataKey) -> Option<@T> { local_get_helper(task, key, true) } -pub unsafe fn local_get( +pub unsafe fn local_get( task: *rust_task, key: LocalDataKey) -> Option<@T> { local_get_helper(task, key, false) } -pub unsafe fn local_set( +pub unsafe fn local_set( task: *rust_task, key: LocalDataKey, data: @T) { let map = get_task_local_map(task); @@ -158,7 +158,7 @@ pub unsafe fn local_set( } } -pub unsafe fn local_modify( +pub unsafe fn local_modify( task: *rust_task, key: LocalDataKey, modify_fn: fn(Option<@T>) -> Option<@T>) { diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index 188b7c334672d..2ba6ccb20fed5 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -427,7 +427,7 @@ impl TaskBuilder { spawn::spawn_raw(move opts, (x.gen_body)(move f)); } /// Runs a task, while transfering ownership of one argument to the child. - fn spawn_with(arg: A, f: fn~(v: A)) { + fn spawn_with(arg: A, f: fn~(v: A)) { let arg = ~mut Some(move arg); do self.spawn |move arg, move f| { f(option::swap_unwrap(arg)) @@ -445,7 +445,7 @@ impl TaskBuilder { * otherwise be required to establish communication from the parent * to the child. */ - fn spawn_listener(f: fn~(comm::Port)) -> comm::Chan { + fn spawn_listener(f: fn~(comm::Port)) -> comm::Chan { let setup_po = comm::Port(); let setup_ch = comm::Chan(&setup_po); do self.spawn |move f| { @@ -460,7 +460,7 @@ impl TaskBuilder { /** * Runs a new task, setting up communication in both directions */ - fn spawn_conversation + fn spawn_conversation (f: fn~(comm::Port, comm::Chan)) -> (comm::Port, comm::Chan) { let from_child = comm::Port(); @@ -484,7 +484,7 @@ impl TaskBuilder { * # Failure * Fails if a future_result was already set for this task. */ - fn try(f: fn~() -> T) -> Result { + fn try(f: fn~() -> T) -> Result { let po = comm::Port(); let ch = comm::Chan(&po); let mut result = None; @@ -554,7 +554,7 @@ pub fn spawn_supervised(f: fn~()) { task().supervised().spawn(move 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. @@ -568,7 +568,7 @@ pub fn spawn_with(arg: A, f: fn~(v: A)) { task().spawn_with(move arg, move f) } -pub fn spawn_listener(f: fn~(comm::Port)) -> comm::Chan { +pub fn spawn_listener(f: fn~(comm::Port)) -> comm::Chan { /*! * Runs a new task while providing a channel from the parent to the child * @@ -578,7 +578,7 @@ pub fn spawn_listener(f: fn~(comm::Port)) -> comm::Chan { task().spawn_listener(move f) } -pub fn spawn_conversation +pub fn spawn_conversation (f: fn~(comm::Port, comm::Chan)) -> (comm::Port, comm::Chan) { /*! @@ -607,7 +607,7 @@ pub fn spawn_sched(mode: SchedMode, f: fn~()) { task().sched_mode(mode).spawn(move 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/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 1708027eaf9b8..2770e2e3dc0e3 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -483,10 +483,10 @@ fn parse_bounds(st: @pstate, conv: conv_did) -> @~[ty::param_bound] { let mut bounds = ~[]; loop { bounds.push(match next(st) { - 'S' => ty::bound_send, + 'S' => ty::bound_owned, 'C' => ty::bound_copy, 'K' => ty::bound_const, - 'O' => ty::bound_owned, + 'O' => ty::bound_static, 'I' => ty::bound_trait(parse_ty(st, conv)), '.' => break, _ => fail ~"parse_bounds: bad bounds" diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index d4abf099e6ec6..5cc6454ec9611 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -392,10 +392,10 @@ fn enc_ty_fn(w: io::Writer, cx: @ctxt, ft: ty::FnTy) { fn enc_bounds(w: io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) { for vec::each(*bs) |bound| { match *bound { - ty::bound_send => w.write_char('S'), + ty::bound_owned => w.write_char('S'), ty::bound_copy => w.write_char('C'), ty::bound_const => w.write_char('K'), - ty::bound_owned => w.write_char('O'), + ty::bound_static => w.write_char('O'), ty::bound_trait(tp) => { w.write_char('I'); enc_ty(w, cx, tp); diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index f5edad9acc432..c73b13532855d 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -62,9 +62,9 @@ fn kind_to_str(k: Kind) -> ~str { } if ty::kind_can_be_sent(k) { - kinds.push(~"send"); - } else if ty::kind_is_owned(k) { kinds.push(~"owned"); + } else if ty::kind_is_static(k) { + kinds.push(~"static"); } str::connect(kinds, ~" ") @@ -135,7 +135,7 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: fn(check_fn)) { fn check_for_box(cx: ctx, id: node_id, fv: Option<@freevar_entry>, is_move: bool, var_t: ty::t, sp: span) { // all captured data must be owned - if !check_owned(cx.tcx, var_t, sp) { return; } + if !check_static(cx.tcx, var_t, sp) { return; } // copied in data must be copyable, but moved in data can be anything let is_implicit = fv.is_some(); @@ -552,12 +552,12 @@ fn check_send(cx: ctx, ty: ty::t, sp: span) -> bool { } // note: also used from middle::typeck::regionck! -fn check_owned(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool { - if !ty::kind_is_owned(ty::type_kind(tcx, ty)) { +fn check_static(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool { + if !ty::kind_is_static(ty::type_kind(tcx, ty)) { match ty::get(ty).sty { ty::ty_param(*) => { tcx.sess.span_err(sp, ~"value may contain borrowed \ - pointers; use `owned` bound"); + pointers; use `static` bound"); } _ => { tcx.sess.span_err(sp, ~"value may contain borrowed \ @@ -629,7 +629,7 @@ fn check_cast_for_escaping_regions( if target_params.contains(&source_param) { /* case (2) */ } else { - check_owned(cx.tcx, ty, source.span); /* case (3) */ + check_static(cx.tcx, ty, source.span); /* case (3) */ } } _ => {} diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 2841c791d4881..ddddd4c4a1a33 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -13,7 +13,7 @@ // Language items are items that represent concepts intrinsic to the language // itself. Examples are: // -// * Traits that specify "kinds"; e.g. "const", "copy", "send". +// * Traits that specify "kinds"; e.g. "const", "copy", "owned". // // * Traits that represent operators; e.g. "add", "sub", "index". // @@ -35,8 +35,8 @@ use str_eq = str::eq; struct LanguageItems { mut const_trait: Option, mut copy_trait: Option, - mut send_trait: Option, mut owned_trait: Option, + mut static_trait: Option, mut drop_trait: Option, @@ -68,8 +68,8 @@ mod language_items { LanguageItems { const_trait: None, copy_trait: None, - send_trait: None, owned_trait: None, + static_trait: None, drop_trait: None, @@ -105,8 +105,8 @@ fn LanguageItemCollector(crate: @crate, session: Session, item_refs.insert(~"const", &mut items.const_trait); item_refs.insert(~"copy", &mut items.copy_trait); - item_refs.insert(~"send", &mut items.send_trait); item_refs.insert(~"owned", &mut items.owned_trait); + item_refs.insert(~"static", &mut items.static_trait); item_refs.insert(~"drop", &mut items.drop_trait); diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index b5c7e1f6195a6..1d5381aaad689 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -518,8 +518,8 @@ fn combine_impl_and_methods_origins(bcx: block, let m_vtables = m_boundss.foldl(0, |sum, m_bounds| { m_bounds.foldl(*sum, |sum, m_bound| { (*sum) + match (*m_bound) { - ty::bound_copy | ty::bound_owned | - ty::bound_send | ty::bound_const => 0, + ty::bound_copy | ty::bound_static | + ty::bound_owned | ty::bound_const => 0, ty::bound_trait(_) => 1 } }) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index d244021763782..8d257bd5612ef 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -140,7 +140,7 @@ export kind_noncopyable, kind_const; export kind_can_be_copied, kind_can_be_sent, kind_can_be_implicitly_copied; export type_implicitly_moves; export kind_is_safe_for_default_mode; -export kind_is_owned; +export kind_is_static; export meta_kind, kind_lteq, type_kind; export operators; export type_err, terr_vstore_kind; @@ -176,9 +176,9 @@ export VariantInfo, VariantInfo_; export walk_ty, maybe_walk_ty; export occurs_check; export param_ty; -export param_bound, param_bounds, bound_copy, bound_owned; +export param_bound, param_bounds, bound_copy, bound_static; export param_bounds_to_str, param_bound_to_str; -export bound_send, bound_trait; +export bound_owned, bound_trait; export param_bounds_to_kind; export default_arg_mode_for_ty; export item_path; @@ -729,8 +729,8 @@ enum type_err { enum param_bound { bound_copy, + bound_static, bound_owned, - bound_send, bound_const, bound_trait(t), } @@ -796,8 +796,8 @@ impl param_bound : to_bytes::IterBytes { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { match *self { bound_copy => 0u8.iter_bytes(lsb0, f), - bound_owned => 1u8.iter_bytes(lsb0, f), - bound_send => 2u8.iter_bytes(lsb0, f), + bound_static => 1u8.iter_bytes(lsb0, f), + bound_owned => 2u8.iter_bytes(lsb0, f), bound_const => 3u8.iter_bytes(lsb0, f), bound_trait(ref t) => to_bytes::iter_bytes_2(&4u8, t, lsb0, f) @@ -900,11 +900,11 @@ fn param_bounds_to_kind(bounds: param_bounds) -> Kind { bound_copy => { kind = raise_kind(kind, kind_implicitly_copyable()); } - bound_owned => { - kind = raise_kind(kind, kind_owned()); + bound_static => { + kind = raise_kind(kind, kind_static()); } - bound_send => { - kind = raise_kind(kind, kind_send_only() | kind_owned()); + bound_owned => { + kind = raise_kind(kind, kind_owned_only() | kind_static()); } bound_const => { kind = raise_kind(kind, kind_const()); @@ -1580,8 +1580,8 @@ fn substs_to_str(cx: ctxt, substs: &substs) -> ~str { fn param_bound_to_str(cx: ctxt, pb: ¶m_bound) -> ~str { match *pb { bound_copy => ~"copy", + bound_static => ~"static", bound_owned => ~"owned", - bound_send => ~"send", bound_const => ~"const", bound_trait(t) => ty_to_str(cx, t) } @@ -1939,11 +1939,11 @@ enum Kind { kind_(u32) } /// can be copied (implicitly or explicitly) const KIND_MASK_COPY : u32 = 0b000000000000000000000000001_u32; -/// can be sent: no shared box, borrowed ptr (must imply OWNED) -const KIND_MASK_SEND : u32 = 0b000000000000000000000000010_u32; +/// cantains owned data, no shared box, borrowed ptr (must imply STATIC) +const KIND_MASK_OWNED : u32 = 0b000000000000000000000000010_u32; -/// is owned (no borrowed ptrs) -const KIND_MASK_OWNED : u32 = 0b000000000000000000000000100_u32; +/// is static (no borrowed ptrs) +const KIND_MASK_STATIC : u32 = 0b000000000000000000000000100_u32; /// is deeply immutable const KIND_MASK_CONST : u32 = 0b000000000000000000000001000_u32; @@ -1972,30 +1972,30 @@ fn kind_safe_for_default_mode() -> Kind { } fn kind_implicitly_sendable() -> Kind { - kind_(KIND_MASK_IMPLICIT | KIND_MASK_COPY | KIND_MASK_SEND) + kind_(KIND_MASK_IMPLICIT | KIND_MASK_COPY | KIND_MASK_OWNED) } fn kind_safe_for_default_mode_send() -> Kind { // similar to implicit copy, but always includes vectors and strings kind_(KIND_MASK_DEFAULT_MODE | KIND_MASK_IMPLICIT | - KIND_MASK_COPY | KIND_MASK_SEND) + KIND_MASK_COPY | KIND_MASK_OWNED) } -fn kind_send_copy() -> Kind { - kind_(KIND_MASK_COPY | KIND_MASK_SEND) +fn kind_owned_copy() -> Kind { + kind_(KIND_MASK_COPY | KIND_MASK_OWNED) } -fn kind_send_only() -> Kind { - kind_(KIND_MASK_SEND) +fn kind_owned_only() -> Kind { + kind_(KIND_MASK_OWNED) } fn kind_const() -> Kind { kind_(KIND_MASK_CONST) } -fn kind_owned() -> Kind { - kind_(KIND_MASK_OWNED) +fn kind_static() -> Kind { + kind_(KIND_MASK_STATIC) } fn kind_top() -> Kind { @@ -2010,12 +2010,12 @@ fn remove_implicit(k: Kind) -> Kind { k - kind_(KIND_MASK_IMPLICIT | KIND_MASK_DEFAULT_MODE) } -fn remove_send(k: Kind) -> Kind { - k - kind_(KIND_MASK_SEND) +fn remove_owned(k: Kind) -> Kind { + k - kind_(KIND_MASK_OWNED) } -fn remove_owned_send(k: Kind) -> Kind { - k - kind_(KIND_MASK_OWNED) - kind_(KIND_MASK_SEND) +fn remove_static_owned(k: Kind) -> Kind { + k - kind_(KIND_MASK_STATIC) - kind_(KIND_MASK_OWNED) } fn remove_copyable(k: Kind) -> Kind { @@ -2062,26 +2062,26 @@ pure fn kind_can_be_copied(k: Kind) -> bool { } pure fn kind_can_be_sent(k: Kind) -> bool { - *k & KIND_MASK_SEND == KIND_MASK_SEND + *k & KIND_MASK_OWNED == KIND_MASK_OWNED } -pure fn kind_is_owned(k: Kind) -> bool { - *k & KIND_MASK_OWNED == KIND_MASK_OWNED +pure fn kind_is_static(k: Kind) -> bool { + *k & KIND_MASK_STATIC == KIND_MASK_STATIC } fn meta_kind(p: FnMeta) -> Kind { match p.proto { // XXX consider the kind bounds! ast::ProtoBare => { - kind_safe_for_default_mode_send() | kind_const() | kind_owned() + kind_safe_for_default_mode_send() | kind_const() | kind_static() } ast::ProtoBorrowed => { kind_noncopyable() | kind_(KIND_MASK_DEFAULT_MODE) } ast::ProtoBox => { - kind_safe_for_default_mode() | kind_owned() + kind_safe_for_default_mode() | kind_static() } ast::ProtoUniq => { - kind_send_copy() | kind_owned() + kind_owned_copy() | kind_static() } } } @@ -2102,17 +2102,17 @@ fn raise_kind(a: Kind, b: Kind) -> Kind { fn test_kinds() { // The kind "lattice" is defined by the subset operation on the // set of permitted operations. - assert kind_lteq(kind_send_copy(), kind_send_copy()); - assert kind_lteq(kind_copyable(), kind_send_copy()); + assert kind_lteq(kind_owned_copy(), kind_owned_copy()); + assert kind_lteq(kind_copyable(), kind_owned_copy()); assert kind_lteq(kind_copyable(), kind_copyable()); - assert kind_lteq(kind_noncopyable(), kind_send_copy()); + assert kind_lteq(kind_noncopyable(), kind_owned_copy()); assert kind_lteq(kind_noncopyable(), kind_copyable()); assert kind_lteq(kind_noncopyable(), kind_noncopyable()); assert kind_lteq(kind_copyable(), kind_implicitly_copyable()); assert kind_lteq(kind_copyable(), kind_implicitly_sendable()); - assert kind_lteq(kind_send_copy(), kind_implicitly_sendable()); - assert !kind_lteq(kind_send_copy(), kind_implicitly_copyable()); - assert !kind_lteq(kind_copyable(), kind_send_only()); + assert kind_lteq(kind_owned_copy(), kind_implicitly_sendable()); + assert !kind_lteq(kind_owned_copy(), kind_implicitly_copyable()); + assert !kind_lteq(kind_copyable(), kind_owned_only()); } // Return the most permissive kind that a composite object containing a field @@ -2144,15 +2144,15 @@ fn type_kind(cx: ctxt, ty: t) -> Kind { // Scalar and unique types are sendable, constant, and owned ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_ptr(_) => { - kind_safe_for_default_mode_send() | kind_const() | kind_owned() + kind_safe_for_default_mode_send() | kind_const() | kind_static() } // Implicit copyability of strs is configurable ty_estr(vstore_uniq) => { if cx.vecs_implicitly_copyable { - kind_implicitly_sendable() | kind_const() | kind_owned() + kind_implicitly_sendable() | kind_const() | kind_static() } else { - kind_send_copy() | kind_const() | kind_owned() + kind_owned_copy() | kind_const() | kind_static() } } @@ -2162,11 +2162,11 @@ fn type_kind(cx: ctxt, ty: t) -> Kind { // Those with refcounts raise noncopyable to copyable, // lower sendable to copyable. Therefore just set result to copyable. ty_box(tm) => { - remove_send(mutable_type_kind(cx, tm) | kind_safe_for_default_mode()) + remove_owned(mutable_type_kind(cx, tm) | kind_safe_for_default_mode()) } // Trait instances are (for now) like shared boxes, basically - ty_trait(_, _, _) => kind_safe_for_default_mode() | kind_owned(), + ty_trait(_, _, _) => kind_safe_for_default_mode() | kind_static(), // Static region pointers are copyable and sendable, but not owned ty_rptr(re_static, mt) => @@ -2192,14 +2192,14 @@ fn type_kind(cx: ctxt, ty: t) -> Kind { // contained type, but aren't implicitly copyable. Fixed vectors have // the kind of the element they contain, taking mutability into account. ty_evec(tm, vstore_box) => { - remove_send(kind_safe_for_default_mode() | mutable_type_kind(cx, tm)) + remove_owned(kind_safe_for_default_mode() | mutable_type_kind(cx, tm)) } ty_evec(tm, vstore_slice(re_static)) => { kind_safe_for_default_mode() | mutable_type_kind(cx, tm) } ty_evec(tm, vstore_slice(_)) => { - remove_owned_send(kind_safe_for_default_mode() | - mutable_type_kind(cx, tm)) + remove_static_owned(kind_safe_for_default_mode() | + mutable_type_kind(cx, tm)) } ty_evec(tm, vstore_fixed(_)) => { mutable_type_kind(cx, tm) @@ -2207,16 +2207,16 @@ fn type_kind(cx: ctxt, ty: t) -> Kind { // All estrs are copyable; uniques and interiors are sendable. ty_estr(vstore_box) => { - kind_safe_for_default_mode() | kind_const() | kind_owned() + kind_safe_for_default_mode() | kind_const() | kind_static() } ty_estr(vstore_slice(re_static)) => { - kind_safe_for_default_mode() | kind_send_copy() | kind_const() + kind_safe_for_default_mode() | kind_owned_copy() | kind_const() } ty_estr(vstore_slice(_)) => { kind_safe_for_default_mode() | kind_const() } ty_estr(vstore_fixed(_)) => { - kind_safe_for_default_mode_send() | kind_const() | kind_owned() + kind_safe_for_default_mode_send() | kind_const() | kind_static() } // Records lower to the lowest of their members. @@ -2257,7 +2257,7 @@ fn type_kind(cx: ctxt, ty: t) -> Kind { let mut lowest = kind_top(); let variants = enum_variants(cx, did); if vec::len(*variants) == 0u { - lowest = kind_send_only() | kind_owned(); + lowest = kind_owned_only() | kind_static(); } else { for vec::each(*variants) |variant| { for variant.args.each |aty| { @@ -4267,8 +4267,8 @@ fn iter_bound_traits_and_supertraits(tcx: ctxt, let bound_trait_ty = match *bound { ty::bound_trait(bound_t) => bound_t, - ty::bound_copy | ty::bound_send | - ty::bound_const | ty::bound_owned => { + ty::bound_copy | ty::bound_owned | + ty::bound_const | ty::bound_static => { loop; // skip non-trait bounds } }; @@ -4678,15 +4678,15 @@ impl param_bound : cmp::Eq { _ => false } } - bound_owned => { + bound_static => { match (*other) { - bound_owned => true, + bound_static => true, _ => false } } - bound_send => { + bound_owned => { match (*other) { - bound_send => true, + bound_owned => true, _ => false } } diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index f037bffb4838e..22351407ca785 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -79,7 +79,7 @@ fn get_region_reporting_err(tcx: ty::ctxt, } } -fn ast_region_to_region( +fn ast_region_to_region( self: AC, rscope: RS, span: span, a_r: @ast::region) -> ty::Region { let res = match a_r.node { @@ -92,7 +92,7 @@ fn ast_region_to_region( get_region_reporting_err(self.tcx(), span, res) } -fn ast_path_to_substs_and_ty( +fn ast_path_to_substs_and_ty( self: AC, rscope: RS, did: ast::def_id, path: @ast::path) -> ty_param_substs_and_ty { @@ -141,7 +141,7 @@ fn ast_path_to_substs_and_ty( {substs: substs, ty: ty::subst(tcx, &substs, decl_ty)} } -fn ast_path_to_ty( +fn ast_path_to_ty( self: AC, rscope: RS, did: ast::def_id, @@ -164,10 +164,10 @@ const NO_TPS: uint = 2; // Parses the programmer's textual representation of a type into our // internal notion of a type. `getter` is a function that returns the type // corresponding to a definition ID: -fn ast_ty_to_ty( +fn ast_ty_to_ty( self: AC, rscope: RS, &&ast_ty: @ast::Ty) -> ty::t { - fn ast_mt_to_mt( + fn ast_mt_to_mt( self: AC, rscope: RS, mt: ast::mt) -> ty::mt { return {ty: ast_ty_to_ty(self, rscope, mt.ty), mutbl: mt.mutbl}; @@ -176,7 +176,7 @@ fn ast_ty_to_ty( // Handle @, ~, and & being able to mean estrs and evecs. // If a_seq_ty is a str or a vec, make it an estr/evec. // Also handle function sigils and first-class trait types. - fn mk_pointer( + fn mk_pointer( self: AC, rscope: RS, a_seq_ty: ast::mt, @@ -389,7 +389,7 @@ fn ast_ty_to_ty( return typ; } -fn ty_of_arg( +fn ty_of_arg( self: AC, rscope: RS, a: ast::arg, expected_ty: Option) -> ty::arg { @@ -438,7 +438,7 @@ fn ty_of_arg( type expected_tys = Option<{inputs: ~[ty::arg], output: ty::t}>; -fn ty_of_fn_decl( +fn ty_of_fn_decl( self: AC, rscope: RS, ast_proto: ast::Proto, purity: ast::purity, diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 2b1078e7dd459..095bdd657af1c 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -339,8 +339,8 @@ impl LookupContext { let bound_trait_ty = match *bound { ty::bound_trait(bound_t) => bound_t, - ty::bound_copy | ty::bound_send | - ty::bound_const | ty::bound_owned => { + ty::bound_copy | ty::bound_owned | + ty::bound_const | ty::bound_static => { loop; // skip non-trait bounds } }; diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 0f4511218ec82..9018bba20d85b 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -34,7 +34,6 @@ use infer::{resolve_and_force_all_but_regions, fres}; use syntax::ast::{def_arg, def_binding, def_local, def_self, def_upvar}; use syntax::ast::{ProtoBare, ProtoBox, ProtoUniq, ProtoBorrowed}; use middle::freevars::get_freevars; -use middle::kind::check_owned; use middle::pat_util::pat_bindings; use middle::ty::{encl_region, re_scope}; use middle::ty::{ty_fn_proto, vstore_box, vstore_fixed, vstore_slice}; diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 5614c3aac8019..7903e1b767dab 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -86,7 +86,7 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) { } impl @crate_ctxt { - fn to_ty( + fn to_ty( rs: RS, ast_ty: @ast::Ty) -> ty::t { ast_ty_to_ty(self, rs, ast_ty) @@ -859,7 +859,7 @@ fn ty_of_foreign_item(ccx: @crate_ctxt, it: @ast::foreign_item) // Translate the AST's notion of ty param bounds (which are just newtyped Tys) // 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, -// Owned, and Send. +// Static, and Send. fn compute_bounds(ccx: @crate_ctxt, ast_bounds: @~[ast::ty_param_bound]) -> ty::param_bounds { @do vec::flat_map(*ast_bounds) |b| { @@ -868,8 +868,8 @@ fn compute_bounds(ccx: @crate_ctxt, match ty::get(ity).sty { ty::ty_trait(did, _, _) => { let d = Some(did); - if d == li.send_trait { - ~[ty::bound_send] + if d == li.owned_trait { + ~[ty::bound_owned] } else if d == li.copy_trait { ~[ty::bound_copy] @@ -877,8 +877,8 @@ fn compute_bounds(ccx: @crate_ctxt, else if d == li.const_trait { ~[ty::bound_const] } - else if d == li.owned_trait { - ~[ty::bound_owned] + else if d == li.static_trait { + ~[ty::bound_static] } else { // Must be a user-defined trait diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs index 5ae52252dc223..1ee20783ded94 100644 --- a/src/librustc/middle/typeck/rscope.rs +++ b/src/librustc/middle/typeck/rscope.rs @@ -60,7 +60,7 @@ fn bound_self_region(rp: Option) -> Option { } enum anon_rscope = {anon: ty::Region, base: region_scope}; -fn in_anon_rscope(self: RS, r: ty::Region) +fn in_anon_rscope(self: RS, r: ty::Region) -> @anon_rscope { @anon_rscope({anon: r, base: self as region_scope}) } @@ -80,7 +80,7 @@ struct binding_rscope { base: region_scope, mut anon_bindings: uint, } -fn in_binding_rscope(self: RS) +fn in_binding_rscope(self: RS) -> @binding_rscope { let base = self as region_scope; @binding_rscope { base: base, anon_bindings: 0 } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 069a9c2875d55..d3cc42f03ddde 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -11,7 +11,7 @@ use std::map::HashMap; use middle::ty; use middle::ty::{arg, canon_mode}; -use middle::ty::{bound_copy, bound_const, bound_owned, bound_send, +use middle::ty::{bound_copy, bound_const, bound_static, bound_owned, bound_trait}; use middle::ty::{bound_region, br_anon, br_named, br_self, br_cap_avoid}; use middle::ty::{ctxt, field, method}; diff --git a/src/librustdoc/astsrv.rs b/src/librustdoc/astsrv.rs index a11943fbf4bca..d32beb8c19142 100644 --- a/src/librustdoc/astsrv.rs +++ b/src/librustdoc/astsrv.rs @@ -95,7 +95,7 @@ fn act(po: comm::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 aaffe3bfeaa15..0180d18668daf 100644 --- a/src/librustdoc/attr_pass.rs +++ b/src/librustdoc/attr_pass.rs @@ -98,7 +98,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/fold.rs b/src/librustdoc/fold.rs index da276922fe779..ba626f80ddb8f 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -92,7 +92,7 @@ fn mk_fold( } } -pub fn default_any_fold(+ctxt: T) -> Fold { +pub fn default_any_fold(+ctxt: T) -> Fold { mk_fold( move ctxt, |f, d| default_seq_fold_doc(f, d), @@ -128,7 +128,7 @@ pub fn default_seq_fold(+ctxt: T) -> Fold { ) } -pub fn default_par_fold(+ctxt: T) -> Fold { +pub fn default_par_fold(+ctxt: T) -> Fold { mk_fold( move ctxt, |f, d| default_seq_fold_doc(f, d), @@ -178,7 +178,7 @@ pub fn default_seq_fold_item( doc } -pub fn default_any_fold_mod( +pub fn default_any_fold_mod( fold: &Fold, +doc: doc::ModDoc ) -> doc::ModDoc { @@ -205,7 +205,7 @@ pub fn default_seq_fold_mod( }) } -pub fn default_par_fold_mod( +pub fn default_par_fold_mod( fold: &Fold, +doc: doc::ModDoc ) -> doc::ModDoc { @@ -219,7 +219,7 @@ pub fn default_par_fold_mod( }) } -pub fn default_any_fold_nmod( +pub fn default_any_fold_nmod( fold: &Fold, +doc: doc::NmodDoc ) -> doc::NmodDoc { @@ -246,7 +246,7 @@ pub fn default_seq_fold_nmod( } } -pub fn default_par_fold_nmod( +pub fn default_par_fold_nmod( fold: &Fold, +doc: doc::NmodDoc ) -> doc::NmodDoc { diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 05acbeab9e58d..5027ee9aa1e2a 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -73,10 +73,10 @@ impl &Condvar { ****************************************************************************/ /// An atomically reference counted wrapper for shared immutable state. -struct ARC { x: SharedMutableState } +struct ARC { x: SharedMutableState } /// Create an atomically reference counted wrapper. -pub fn ARC(data: T) -> ARC { +pub fn ARC(data: T) -> ARC { ARC { x: unsafe { shared_mutable_state(move data) } } } @@ -84,7 +84,7 @@ pub fn ARC(data: T) -> ARC { * Access the underlying data in an atomically reference counted * wrapper. */ -pub fn get(rc: &a/ARC) -> &a/T { +pub fn get(rc: &a/ARC) -> &a/T { unsafe { get_shared_immutable_state(&rc.x) } } @@ -95,7 +95,7 @@ pub fn get(rc: &a/ARC) -> &a/T { * object. However, one of the `arc` objects can be sent to another task, * allowing them to share the underlying data. */ -pub fn clone(rc: &ARC) -> ARC { +pub fn clone(rc: &ARC) -> ARC { ARC { x: unsafe { clone_shared_mutable_state(&rc.x) } } } @@ -108,12 +108,12 @@ pub fn clone(rc: &ARC) -> ARC { * unwrap from a task that holds another reference to the same ARC; it is * guaranteed to deadlock. */ -fn unwrap(rc: ARC) -> T { +fn unwrap(rc: ARC) -> T { let ARC { x: x } = move rc; unsafe { unwrap_shared_mutable_state(move x) } } -impl ARC: Clone { +impl ARC: Clone { fn clone(&self) -> ARC { clone(self) } @@ -124,19 +124,19 @@ impl ARC: Clone { ****************************************************************************/ #[doc(hidden)] -struct MutexARCInner { lock: Mutex, failed: bool, data: T } +struct MutexARCInner { lock: Mutex, failed: bool, data: T } /// An ARC with mutable data protected by a blocking mutex. -struct MutexARC { x: SharedMutableState> } +struct MutexARC { x: SharedMutableState> } /// 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(move 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), @@ -144,7 +144,7 @@ pub fn mutex_arc_with_condvars(user_data: T, MutexARC { x: unsafe { shared_mutable_state(move data) } } } -impl MutexARC: Clone { +impl MutexARC: Clone { /// Duplicate a mutex-protected ARC, as arc::clone. fn clone(&self) -> MutexARC { // NB: Cloning the underlying mutex is not necessary. Its reference @@ -153,7 +153,7 @@ impl MutexARC: Clone { } } -impl &MutexARC { +impl &MutexARC { /** * Access the underlying mutable data with mutual exclusion from other @@ -210,7 +210,7 @@ impl &MutexARC { * Will additionally fail if another task has failed while accessing the arc. */ // FIXME(#3724) make this a by-move method on the arc -pub fn unwrap_mutex_arc(arc: MutexARC) -> T { +pub fn unwrap_mutex_arc(arc: MutexARC) -> T { let MutexARC { x: x } = move arc; let inner = unsafe { unwrap_shared_mutable_state(move x) }; let MutexARCInner { failed: failed, data: data, _ } = move inner; @@ -256,27 +256,27 @@ fn PoisonOnFail(failed: &r/mut bool) -> PoisonOnFail/&r { ****************************************************************************/ #[doc(hidden)] -struct RWARCInner { lock: RWlock, failed: bool, data: T } +struct RWARCInner { lock: RWlock, failed: bool, data: T } /** * A dual-mode ARC protected by a reader-writer lock. The data can be accessed * mutably or immutably, and immutably-accessing tasks may run concurrently. * * Unlike mutex_arcs, rw_arcs are safe, because they cannot be nested. */ -struct RWARC { +struct RWARC { x: SharedMutableState>, mut cant_nest: () } /// 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(move 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(user_data: T, +pub fn rw_arc_with_condvars(user_data: T, num_condvars: uint) -> RWARC { let data = RWARCInner { lock: rwlock_with_condvars(num_condvars), @@ -284,7 +284,7 @@ pub fn rw_arc_with_condvars(user_data: T, RWARC { x: unsafe { shared_mutable_state(move data) }, cant_nest: () } } -impl RWARC { +impl RWARC { /// Duplicate a rwlock-protected ARC, as arc::clone. fn clone(&self) -> RWARC { RWARC { x: unsafe { clone_shared_mutable_state(&self.x) }, @@ -293,7 +293,7 @@ impl RWARC { } -impl &RWARC { +impl &RWARC { /** * Access the underlying data mutably. Locks the rwlock in write mode; * other readers and writers will block. @@ -394,7 +394,7 @@ impl &RWARC { * in write mode. */ // FIXME(#3724) make this a by-move method on the arc -pub fn unwrap_rw_arc(arc: RWARC) -> T { +pub fn unwrap_rw_arc(arc: RWARC) -> T { let RWARC { x: x, _ } = move arc; let inner = unsafe { unwrap_shared_mutable_state(move x) }; let RWARCInner { failed: failed, data: data, _ } = move inner; @@ -408,19 +408,19 @@ pub fn unwrap_rw_arc(arc: RWARC) -> T { // 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: &r/mut RWARCInner) -> &r/RWlock { +fn borrow_rwlock(state: &r/mut RWARCInner) -> &r/RWlock { unsafe { cast::transmute_immut(&mut state.lock) } } // FIXME (#3154) ice with struct/& prevents these from being structs. /// The "write permission" token used for RWARC.write_downgrade(). -pub enum RWWriteMode = +pub enum RWWriteMode = (&mut T, sync::RWlockWriteMode, PoisonOnFail); /// The "read permission" token used for RWARC.write_downgrade(). -pub enum RWReadMode = (&T, sync::RWlockReadMode); +pub enum RWReadMode = (&T, sync::RWlockReadMode); -impl &RWWriteMode { +impl &RWWriteMode { /// Access the pre-downgrade RWARC in write mode. fn write(blk: fn(x: &mut T) -> U) -> U { match *self { @@ -446,7 +446,7 @@ impl &RWWriteMode { } } -impl &RWReadMode { +impl &RWReadMode { /// Access the post-downgrade rwlock in read mode. fn read(blk: fn(x: &T) -> U) -> U { match *self { diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index d8c5b6e5944ee..a3fcf1b726dcf 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -21,24 +21,24 @@ use pipes::{GenericChan, GenericSmartChan, GenericPort, Chan, Port, Selectable, Peekable}; /// An extension of `pipes::stream` that allows both sending and receiving. -pub struct DuplexStream { +pub struct DuplexStream { priv chan: Chan, priv port: Port, } -impl DuplexStream : GenericChan { +impl DuplexStream : GenericChan { fn send(x: T) { self.chan.send(move x) } } -impl DuplexStream : GenericSmartChan { +impl DuplexStream : GenericSmartChan { fn try_send(x: T) -> bool { self.chan.try_send(move x) } } -impl DuplexStream : GenericPort { +impl DuplexStream : GenericPort { fn recv() -> U { self.port.recv() } @@ -48,20 +48,20 @@ impl DuplexStream : GenericPort { } } -impl DuplexStream : Peekable { +impl DuplexStream : Peekable { pure fn peek() -> bool { self.port.peek() } } -impl DuplexStream : Selectable { +impl DuplexStream : Selectable { pure fn header() -> *pipes::PacketHeader { self.port.header() } } /// Creates a bidirectional stream. -pub fn DuplexStream() +pub fn DuplexStream() -> (DuplexStream, DuplexStream) { let (c2, p1) = pipes::stream(); diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 96d57297cf7d8..80c7cd0676eb8 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -210,7 +210,7 @@ mod tests { assert (deq.get(3) == d); } - fn test_parameterized(a: T, b: T, c: T, d: T) { + fn test_parameterized(a: T, b: T, c: T, d: T) { let deq: deque::Deque = deque::create::(); assert (deq.size() == 0u); deq.add_front(a); diff --git a/src/libstd/future.rs b/src/libstd/future.rs index e0aed60e80300..94e3d1126f150 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -79,7 +79,7 @@ pub fn from_value(val: A) -> Future { Future {state: Forced(~(move val))} } -pub fn from_port(port: PortOne) -> +pub fn from_port(port: PortOne) -> Future { /*! * Create a future from a port @@ -111,7 +111,7 @@ pub fn from_fn(f: ~fn() -> A) -> Future { Future {state: Pending(move 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/libstd/par.rs b/src/libstd/par.rs index 7cf9c2c377122..55f88d4427cef 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -29,7 +29,7 @@ const 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] { @@ -84,7 +84,8 @@ fn map_slices( } /// A parallel version of map. -pub fn map(xs: &[A], f: fn~((&A)) -> B) -> ~[B] { +pub fn map( + xs: &[A], f: fn~((&A)) -> B) -> ~[B] { vec::concat(map_slices(xs, || { fn~(_base: uint, slice : &[A], copy f) -> ~[B] { vec::map(slice, |x| f(x)) @@ -93,7 +94,7 @@ pub fn map(xs: &[A], f: fn~((&A)) -> B) -> ~[B] { } /// A parallel version of mapi. -pub fn mapi(xs: &[A], +pub fn mapi(xs: &[A], f: fn~(uint, (&A)) -> B) -> ~[B] { let slices = map_slices(xs, || { fn~(base: uint, slice : &[A], copy f) -> ~[B] { @@ -114,7 +115,7 @@ pub fn mapi(xs: &[A], * In this case, f is a function that creates functions to run over the * inner elements. This is to skirt the need for copy constructors. */ -pub fn mapi_factory( +pub fn mapi_factory( xs: &[A], f: fn() -> fn~(uint, A) -> B) -> ~[B] { let slices = map_slices(xs, || { let f = f(); @@ -131,7 +132,7 @@ pub fn mapi_factory( } /// Returns true if the function holds for all elements in the vector. -pub fn alli(xs: &[A], f: fn~(uint, (&A)) -> bool) -> bool { +pub fn alli(xs: &[A], f: fn~(uint, (&A)) -> bool) -> bool { do vec::all(map_slices(xs, || { fn~(base: uint, slice : &[A], copy f) -> bool { vec::alli(slice, |i, x| { @@ -142,7 +143,7 @@ pub fn alli(xs: &[A], f: fn~(uint, (&A)) -> bool) -> bool { } /// Returns true if the function holds for any elements in the vector. -pub fn any(xs: &[A], f: fn~(&(A)) -> bool) -> bool { +pub fn any(xs: &[A], f: fn~(&(A)) -> bool) -> bool { do vec::any(map_slices(xs, || { fn~(_base : uint, slice: &[A], copy f) -> bool { vec::any(slice, |x| f(x)) diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index a373a201ffee0..a7dcfc3d8b604 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -76,10 +76,10 @@ struct SemInner { blocked: Q } #[doc(hidden)] -enum Sem = Exclusive>; +enum Sem = Exclusive>; #[doc(hidden)] -fn new_sem(count: int, q: Q) -> Sem { +fn new_sem(count: int, q: Q) -> Sem { Sem(exclusive(SemInner { mut count: count, waiters: new_waitqueue(), blocked: move q })) } @@ -94,7 +94,7 @@ fn new_sem_and_signal(count: int, num_condvars: uint) } #[doc(hidden)] -impl &Sem { +impl &Sem { fn acquire() { let mut waiter_nobe = None; unsafe { @@ -160,9 +160,9 @@ impl &Sem<~[mut Waitqueue]> { #[doc(hidden)] type SemRelease = SemReleaseGeneric<()>; type SemAndSignalRelease = SemReleaseGeneric<~[mut Waitqueue]>; -struct SemReleaseGeneric { sem: &Sem } +struct SemReleaseGeneric { sem: &Sem } -impl SemReleaseGeneric : Drop { +impl SemReleaseGeneric : Drop { fn finalize(&self) { self.sem.release(); } diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index a53c03d6d2ce6..4eb240f39d7ec 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -33,7 +33,7 @@ use comm = core::comm; * * 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: comm::Chan, val: T) { unsafe { let timer_done_po = core::comm::Port::<()>(); @@ -109,7 +109,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: comm::Port) -> Option { let timeout_po = comm::Port::<()>(); diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index 2fd085fdb3343..24cf2144f8b84 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -157,7 +157,7 @@ struct Exec { discovered_outputs: WorkMap } -struct Work { +struct Work { prep: @mut Prep, res: Option>> } @@ -188,7 +188,7 @@ impl Context { Context {db: db, logger: lg, cfg: cfg, freshness: LinearMap()} } - fn prep Deserializable>( @self, @@ -213,7 +213,7 @@ impl Prep { val.to_owned()); } - fn exec Deserializable>( @mut self, blk: ~fn(&Exec) -> T) -> Work { @@ -250,7 +250,7 @@ impl Prep { } } -impl Deserializable> Work { @@ -260,7 +260,7 @@ impl Deserializable>(w: Work) -> T { diff --git a/src/test/auxiliary/cci_capture_clause.rs b/src/test/auxiliary/cci_capture_clause.rs index 8c885f1b79748..9fe71cecd34ee 100644 --- a/src/test/auxiliary/cci_capture_clause.rs +++ b/src/test/auxiliary/cci_capture_clause.rs @@ -14,7 +14,7 @@ export foo; use comm::*; -fn foo(x: T) -> Port { +fn foo(x: T) -> Port { let p = Port(); let c = Chan(&p); do task::spawn() |copy c, copy x| { diff --git a/src/test/auxiliary/test_comm.rs b/src/test/auxiliary/test_comm.rs index 7de9d9a6739ad..d8ce8076e41ed 100644 --- a/src/test/auxiliary/test_comm.rs +++ b/src/test/auxiliary/test_comm.rs @@ -28,20 +28,20 @@ export recv; * transmitted. If a port value is copied, both copies refer to the same * port. Ports may be associated with multiple `chan`s. */ -enum port { +enum port { port_t(@port_ptr) } /// Constructs a port -fn port() -> port { +fn port() -> port { port_t(@port_ptr(rustrt::new_port(sys::size_of::() as size_t))) } -struct port_ptr { +struct port_ptr { po: *rust_port, } -impl port_ptr : Drop { +impl port_ptr : Drop { fn finalize(&self) { unsafe { debug!("in the port_ptr destructor"); @@ -63,7 +63,7 @@ impl port_ptr : Drop { } } -fn port_ptr(po: *rust_port) -> port_ptr { +fn port_ptr(po: *rust_port) -> port_ptr { debug!("in the port_ptr constructor"); port_ptr { po: po @@ -74,11 +74,11 @@ fn port_ptr(po: *rust_port) -> port_ptr { * Receive from a port. If no data is available on the port then the * task will block until data becomes available. */ -fn recv(p: port) -> T { recv_((**p).po) } +fn recv(p: port) -> T { recv_((**p).po) } /// Receive on a raw port pointer -fn recv_(p: *rust_port) -> T { +fn recv_(p: *rust_port) -> T { let yield = 0; let yieldp = ptr::addr_of(&yield); let mut res; diff --git a/src/test/bench/pingpong.rs b/src/test/bench/pingpong.rs index ee526ac199d88..11d7545e17554 100644 --- a/src/test/bench/pingpong.rs +++ b/src/test/bench/pingpong.rs @@ -68,7 +68,7 @@ macro_rules! follow ( ) ) -fn switch(+endp: pipes::RecvPacketBuffered, +fn switch(+endp: pipes::RecvPacketBuffered, f: fn(+v: Option) -> U) -> U { f(pipes::try_recv(move endp)) } diff --git a/src/test/bench/task-perf-word-count-generic.rs b/src/test/bench/task-perf-word-count-generic.rs index 9d6827127a3e7..8cee0b5f7f359 100644 --- a/src/test/bench/task-perf-word-count-generic.rs +++ b/src/test/bench/task-perf-word-count-generic.rs @@ -124,35 +124,35 @@ mod map_reduce { export reducer; export map_reduce; - type putter = fn(&K, V); + type putter = fn(&K, V); - type mapper = fn~(K1, putter); + type mapper = fn~(K1, putter); - type getter = fn() -> Option; + type getter = fn() -> Option; - type reducer = fn~(&K, getter); + type reducer = fn~(&K, getter); - enum ctrl_proto { + enum ctrl_proto { find_reducer(K, Chan>>), mapper_done } proto! ctrl_proto ( - open: send { + open: send { find_reducer(K) -> reducer_response, mapper_done -> ! } - reducer_response: recv { + reducer_response: recv { reducer(Chan>) -> open } ) - enum reduce_proto { emit_val(V), done, addref, release } + enum reduce_proto { emit_val(V), done, addref, release } - fn start_mappers( + fn start_mappers( map: &mapper, ctrls: &mut ~[ctrl_proto::server::open], inputs: &~[K1]) @@ -170,7 +170,7 @@ mod map_reduce { move tasks } - fn map_task( + fn map_task( map: mapper, ctrl: &box>, input: K1) @@ -202,7 +202,7 @@ mod map_reduce { send(c.get(), emit_val(val)); } - fn finish(_k: K, v: Chan>) + fn finish(_k: K, v: Chan>) { send(v, release); } @@ -210,7 +210,7 @@ mod map_reduce { ctrl_proto::client::mapper_done(ctrl.unwrap()); } - fn reduce_task( + fn reduce_task( reduce: ~reducer, key: K, out: Chan>>) @@ -222,7 +222,7 @@ mod map_reduce { let mut ref_count = 0; let mut is_done = false; - fn get(p: Port>, + fn get(p: Port>, ref_count: &mut int, is_done: &mut bool) -> Option { while !*is_done || *ref_count > 0 { @@ -245,7 +245,7 @@ mod map_reduce { (*reduce)(&key, || get(p, &mut ref_count, &mut is_done) ); } - fn map_reduce( + fn map_reduce( map: mapper, reduce: reducer, inputs: ~[K1]) diff --git a/src/test/compile-fail/issue-2548.rs b/src/test/compile-fail/issue-2548.rs index abf70a4995f99..d805d35668798 100644 --- a/src/test/compile-fail/issue-2548.rs +++ b/src/test/compile-fail/issue-2548.rs @@ -34,7 +34,7 @@ fn main() { let mut res = foo(x); let mut v = ~[mut]; - v = move ~[mut (move res)] + v; //~ ERROR instantiating a type parameter with an incompatible type (needs `copy`, got `owned`, missing `copy`) + v = move ~[mut (move res)] + v; //~ ERROR instantiating a type parameter with an incompatible type (needs `copy`, got `static`, missing `copy`) assert (v.len() == 2); } diff --git a/src/test/compile-fail/issue-2766-a.rs b/src/test/compile-fail/issue-2766-a.rs index a5eff9b3a9c28..c0b27789977ef 100644 --- a/src/test/compile-fail/issue-2766-a.rs +++ b/src/test/compile-fail/issue-2766-a.rs @@ -10,10 +10,10 @@ mod stream { #[legacy_exports]; - enum Stream { send(T, server::Stream), } + enum Stream { send(T, server::Stream), } mod server { #[legacy_exports]; - impl Stream { + impl Stream { fn recv() -> extern fn(+v: Stream) -> stream::Stream { // resolve really should report just one error here. // Change the test case when it changes. @@ -26,7 +26,7 @@ mod stream { recv } } - type Stream = pipes::RecvPacket>; + type Stream = pipes::RecvPacket>; } } diff --git a/src/test/compile-fail/kindck-owned-trait-scoped.rs b/src/test/compile-fail/kindck-owned-trait-scoped.rs index 3b2e8e53aaa47..da995835f6a4b 100644 --- a/src/test/compile-fail/kindck-owned-trait-scoped.rs +++ b/src/test/compile-fail/kindck-owned-trait-scoped.rs @@ -32,10 +32,10 @@ fn to_foo(t: T) { fn to_foo_2(t: T) -> foo { // Not OK---T may contain borrowed ptrs and it is going to escape // as part of the returned foo value - {f:t} as foo //~ ERROR value may contain borrowed pointers; use `owned` bound + {f:t} as foo //~ ERROR value may contain borrowed pointers; use `static` bound } -fn to_foo_3(t: T) -> foo { +fn to_foo_3(t: T) -> foo { // OK---T may escape as part of the returned foo value, but it is // owned and hence does not contain borrowed ptrs {f:t} as foo diff --git a/src/test/compile-fail/kindck-owned-trait.rs b/src/test/compile-fail/kindck-owned-trait.rs index 249c786c4241a..2c7f92234b647 100644 --- a/src/test/compile-fail/kindck-owned-trait.rs +++ b/src/test/compile-fail/kindck-owned-trait.rs @@ -11,10 +11,10 @@ trait foo { fn foo(); } fn to_foo(t: T) -> foo { - t as foo //~ ERROR value may contain borrowed pointers; use `owned` bound + t as foo //~ ERROR value may contain borrowed pointers; use `static` bound } -fn to_foo2(t: T) -> foo { +fn to_foo2(t: T) -> foo { t as foo } diff --git a/src/test/compile-fail/kindck-owned.rs b/src/test/compile-fail/kindck-owned.rs index 788c211e2724c..789d3363da554 100644 --- a/src/test/compile-fail/kindck-owned.rs +++ b/src/test/compile-fail/kindck-owned.rs @@ -12,18 +12,18 @@ fn copy1(t: T) -> fn@() -> T { fn@() -> T { t } //~ ERROR value may contain borrowed pointers } -fn copy2(t: T) -> fn@() -> T { +fn copy2(t: T) -> fn@() -> T { fn@() -> T { t } } fn main() { let x = &3; - copy2(&x); //~ ERROR missing `owned` + copy2(&x); //~ ERROR missing `static` copy2(@3); - copy2(@&x); //~ ERROR missing `owned` + copy2(@&x); //~ ERROR missing `static` copy2(fn@() {}); copy2(fn~() {}); //~ WARNING instantiating copy type parameter with a not implicitly copyable type - copy2(fn&() {}); //~ ERROR missing `copy owned` + copy2(fn&() {}); //~ ERROR missing `copy static` } diff --git a/src/test/compile-fail/liveness-use-after-send.rs b/src/test/compile-fail/liveness-use-after-send.rs index b2ddd23bc6e95..074bdf42280f4 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) { log(debug, ch); log(debug, data); fail; diff --git a/src/test/compile-fail/unique-unique-kind.rs b/src/test/compile-fail/unique-unique-kind.rs index 1dd41b5b9689f..e20971a63bdb7 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(move i); //~ ERROR missing `send` + f(move i); //~ ERROR missing `owned` } diff --git a/src/test/compile-fail/unsendable-class.rs b/src/test/compile-fail/unsendable-class.rs index 8c4d0bd2508ff..ef9e0aae95e6b 100644 --- a/src/test/compile-fail/unsendable-class.rs +++ b/src/test/compile-fail/unsendable-class.rs @@ -25,7 +25,7 @@ fn foo(i:int, j: @~str) -> foo { fn main() { let cat = ~"kitty"; - let po = comm::Port(); //~ ERROR missing `send` - let ch = comm::Chan(&po); //~ ERROR missing `send` - comm::send(ch, foo(42, @(move cat))); //~ ERROR missing `send` + let po = comm::Port(); //~ ERROR missing `owned` + let ch = comm::Chan(&po); //~ ERROR missing `owned` + comm::send(ch, foo(42, @(move cat))); //~ ERROR missing `owned` } diff --git a/src/test/run-fail/bug-811.rs b/src/test/run-fail/bug-811.rs index b3d92883a39bb..739bf097d4fda 100644 --- a/src/test/run-fail/bug-811.rs +++ b/src/test/run-fail/bug-811.rs @@ -14,8 +14,8 @@ fn test00_start(ch: chan_t, message: int) { send(ch, message); } type task_id = int; type port_id = int; -enum chan_t = {task: task_id, port: port_id}; +enum chan_t = {task: task_id, 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-fail/issue-2444.rs b/src/test/run-fail/issue-2444.rs index 15f564348a269..b1d8c99faa519 100644 --- a/src/test/run-fail/issue-2444.rs +++ b/src/test/run-fail/issue-2444.rs @@ -13,7 +13,7 @@ extern mod std; use std::arc; -enum e { e(arc::ARC) } +enum e { e(arc::ARC) } fn foo() -> e {fail;} diff --git a/src/test/run-fail/port-type.rs b/src/test/run-fail/port-type.rs index 3623b55e24e35..8b4c1e3ea30a5 100644 --- a/src/test/run-fail/port-type.rs +++ b/src/test/run-fail/port-type.rs @@ -15,7 +15,7 @@ use comm::Port; use comm::send; use comm::recv; -fn echo(c: Chan, oc: Chan>) { +fn echo(c: Chan, oc: Chan>) { // Tests that the type argument in port gets // visited let p = Port::(); diff --git a/src/test/run-pass/alignment-gep-tup-like-1.rs b/src/test/run-pass/alignment-gep-tup-like-1.rs index 7bc7e3a97c8b9..1d5b706ac7d41 100644 --- a/src/test/run-pass/alignment-gep-tup-like-1.rs +++ b/src/test/run-pass/alignment-gep-tup-like-1.rs @@ -12,7 +12,7 @@ type pair = { a: A, b: B }; -fn f(a: A, b: u16) -> fn@() -> (A, u16) { +fn f(a: A, b: u16) -> fn@() -> (A, u16) { fn@() -> (A, u16) { (a, b) } } 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 8d2c92ba0db56..ded15ca94f119 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) { fn@() -> (A, B) { (a, b) } } diff --git a/src/test/run-pass/bounded-fn-type.rs b/src/test/run-pass/bounded-fn-type.rs index de0ed45de9c74..507bd347fef21 100644 --- a/src/test/run-pass/bounded-fn-type.rs +++ b/src/test/run-pass/bounded-fn-type.rs @@ -11,7 +11,7 @@ fn ignore(_x: T) {} fn main() { - let f: fn@:Send() = ||(); + let f: fn@:Owned() = ||(); ignore(f); } diff --git a/src/test/run-pass/close-over-big-then-small-data.rs b/src/test/run-pass/close-over-big-then-small-data.rs index 025e874ce4862..bcb83ffc0f24e 100644 --- a/src/test/run-pass/close-over-big-then-small-data.rs +++ b/src/test/run-pass/close-over-big-then-small-data.rs @@ -16,7 +16,7 @@ type pair = { a: A, b: B }; -fn f(a: A, b: u16) -> fn@() -> (A, u16) { +fn f(a: A, b: u16) -> fn@() -> (A, u16) { fn@() -> (A, u16) { (a, b) } } diff --git a/src/test/run-pass/fixed-point-bind-unique.rs b/src/test/run-pass/fixed-point-bind-unique.rs index 69f7fa0a81fc2..2faeac1731aac 100644 --- a/src/test/run-pass/fixed-point-bind-unique.rs +++ b/src/test/run-pass/fixed-point-bind-unique.rs @@ -11,11 +11,11 @@ // xfail-fast #[legacy_modes]; -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 754e0df9dc7eb..53e66f950d3e9 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(move val); } diff --git a/src/test/run-pass/generic-alias-unique.rs b/src/test/run-pass/generic-alias-unique.rs index 868681bfbf295..6537be69a1da1 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; } fn main() { let expected = ~100; diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index 690cc6a4ab767..0d5ed97db175e 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -27,13 +27,13 @@ mod pipes { pure fn ne(&self, other: &state) -> bool { !(*self).eq(other) } } - type packet = { + type packet = { mut state: state, mut blocked_task: Option, mut payload: Option }; - fn packet() -> *packet unsafe { + fn packet() -> *packet unsafe { let p: *packet = cast::transmute(~{ mut state: empty, mut blocked_task: None::, @@ -68,7 +68,7 @@ mod pipes { } } - fn send(-p: send_packet, -payload: T) { + fn send(-p: send_packet, -payload: T) { let p = p.unwrap(); let p = unsafe { uniquify(p) }; assert (*p).payload.is_none(); @@ -94,7 +94,7 @@ mod pipes { } } - fn recv(-p: recv_packet) -> Option { + fn recv(-p: recv_packet) -> Option { let p = p.unwrap(); let p = unsafe { uniquify(p) }; loop { @@ -115,7 +115,7 @@ mod pipes { } } - fn sender_terminate(p: *packet) { + fn sender_terminate(p: *packet) { let p = unsafe { uniquify(p) }; match swap_state_rel(&mut (*p).state, terminated) { empty | blocked => { @@ -132,7 +132,7 @@ mod pipes { } } - fn receiver_terminate(p: *packet) { + fn receiver_terminate(p: *packet) { let p = unsafe { uniquify(p) }; match swap_state_rel(&mut (*p).state, terminated) { empty => { @@ -149,11 +149,11 @@ mod pipes { } } - struct send_packet { + struct send_packet { mut p: Option<*packet>, } - impl send_packet : Drop { + impl send_packet : Drop { fn finalize(&self) { if self.p != None { let mut p = None; @@ -163,7 +163,7 @@ mod pipes { } } - impl send_packet { + impl send_packet { fn unwrap() -> *packet { let mut p = None; p <-> self.p; @@ -171,17 +171,17 @@ mod pipes { } } - fn send_packet(p: *packet) -> send_packet { + fn send_packet(p: *packet) -> send_packet { send_packet { p: Some(p) } } - struct recv_packet { + struct recv_packet { mut p: Option<*packet>, } - impl recv_packet : Drop { + impl recv_packet : Drop { fn finalize(&self) { if self.p != None { let mut p = None; @@ -191,7 +191,7 @@ mod pipes { } } - impl recv_packet { + impl recv_packet { fn unwrap() -> *packet { let mut p = None; p <-> self.p; @@ -199,13 +199,13 @@ mod pipes { } } - fn recv_packet(p: *packet) -> recv_packet { + fn recv_packet(p: *packet) -> recv_packet { recv_packet { p: Some(p) } } - fn entangle() -> (send_packet, recv_packet) { + fn entangle() -> (send_packet, recv_packet) { let p = packet(); (send_packet(p), recv_packet(p)) } diff --git a/src/test/run-pass/issue-2734.rs b/src/test/run-pass/issue-2734.rs index ff773d9ae1704..7e5d8287e9213 100644 --- a/src/test/run-pass/issue-2734.rs +++ b/src/test/run-pass/issue-2734.rs @@ -11,7 +11,7 @@ trait hax { } impl A: hax { } -fn perform_hax(x: @T) -> hax { +fn perform_hax(x: @T) -> hax { x as hax } diff --git a/src/test/run-pass/issue-2735.rs b/src/test/run-pass/issue-2735.rs index 4b45d4dcc74eb..cded0615f71fd 100644 --- a/src/test/run-pass/issue-2735.rs +++ b/src/test/run-pass/issue-2735.rs @@ -11,7 +11,7 @@ trait hax { } impl A: hax { } -fn perform_hax(x: @T) -> hax { +fn perform_hax(x: @T) -> hax { x as hax } diff --git a/src/test/run-pass/issue-2834.rs b/src/test/run-pass/issue-2834.rs index b617e458bc9d7..dad0427adccfe 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-2904.rs b/src/test/run-pass/issue-2904.rs index c228c8199f208..ee49d0bef9e37 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -57,7 +57,7 @@ fn square_from_char(c: char) -> square { } } -fn read_board_grid(+in: rdr) -> ~[~[square]] { +fn read_board_grid(+in: rdr) -> ~[~[square]] { let in = (move in) as io::Reader; let mut grid = ~[]; for in.each_line |line| { diff --git a/src/test/run-pass/issue-2930.rs b/src/test/run-pass/issue-2930.rs index f57f3312eefdf..1ad5158206734 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 9deba54a1a87c..1d51f611cfe7f 100644 --- a/src/test/run-pass/pipe-bank-proto.rs +++ b/src/test/run-pass/pipe-bank-proto.rs @@ -45,7 +45,7 @@ macro_rules! move_it ( { $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } } ) -fn switch(+endp: pipes::RecvPacket, +fn switch(+endp: pipes::RecvPacket, f: fn(+v: Option) -> U) -> U { f(pipes::try_recv(move endp)) } diff --git a/src/test/run-pass/pipe-select.rs b/src/test/run-pass/pipe-select.rs index 020d0fe06191a..8ad5230e5356a 100644 --- a/src/test/run-pass/pipe-select.rs +++ b/src/test/run-pass/pipe-select.rs @@ -24,7 +24,7 @@ proto! oneshot ( ) proto! stream ( - Stream:send { + Stream:send { send(T) -> Stream } ) diff --git a/src/test/run-pass/send-type-inference.rs b/src/test/run-pass/send-type-inference.rs index df21dcdda9869..d7dff980459ce 100644 --- a/src/test/run-pass/send-type-inference.rs +++ b/src/test/run-pass/send-type-inference.rs @@ -14,9 +14,9 @@ use comm::send; use comm::Port; // tests that ctrl's type gets inferred properly -type command = {key: K, val: V}; +type command = {key: K, val: V}; -fn cache_server(c: Chan>>) { +fn cache_server(c: Chan>>) { let ctrl = Port(); send(c, Chan(&ctrl)); } diff --git a/src/test/run-pass/type-param-constraints.rs b/src/test/run-pass/type-param-constraints.rs index 2d4e14eb0aa2d..aa0485f79945d 100644 --- a/src/test/run-pass/type-param-constraints.rs +++ b/src/test/run-pass/type-param-constraints.rs @@ -13,7 +13,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 c0e70d374fd1d..b78c78ad9e982 100644 --- a/src/test/run-pass/uniq-cc-generic.rs +++ b/src/test/run-pass/uniq-cc-generic.rs @@ -18,7 +18,7 @@ type pointy = { d : fn~() -> uint, }; -fn make_uniq_closure(a: A) -> fn~() -> uint { +fn make_uniq_closure(a: A) -> fn~() -> uint { fn~() -> uint { ptr::addr_of(&a) as uint } } diff --git a/src/test/run-pass/unique-kinds.rs b/src/test/run-pass/unique-kinds.rs index 701cf371cf68b..f3637ef7d6eed 100644 --- a/src/test/run-pass/unique-kinds.rs +++ b/src/test/run-pass/unique-kinds.rs @@ -12,11 +12,11 @@ use cmp::Eq; fn sendable() { - fn f(i: T, j: T) { + fn f(i: T, j: T) { assert i == j; } - fn g(i: T, j: T) { + fn g(i: T, j: T) { assert i != j; }