diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index df98e469bbcff..3a51a2a212ced 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -35,13 +35,13 @@ pub mod linear { const INITIAL_CAPACITY: uint = 32u; // 2^5 - struct Bucket { + struct Bucket { hash: uint, key: K, value: V, } - pub struct LinearMap { + pub struct LinearMap { k0: u64, k1: u64, resize_at: uint, @@ -408,7 +408,7 @@ pub mod linear { pure fn ne(&self, other: &LinearMap) -> bool { !self.eq(other) } } - pub struct LinearSet { + pub struct LinearSet { priv map: LinearMap } diff --git a/src/libcore/io.rs b/src/libcore/io.rs index cf49ee0becc47..6d618627ece41 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -1111,7 +1111,7 @@ pub mod fsync { // Artifacts that need to fsync on destruction - pub struct Res { + pub struct Res { arg: Arg, } diff --git a/src/libcore/oldcomm.rs b/src/libcore/oldcomm.rs index 89300be9ab4d6..dc245f5bffd56 100644 --- a/src/libcore/oldcomm.rs +++ b/src/libcore/oldcomm.rs @@ -68,7 +68,7 @@ use vec; * 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) } @@ -84,7 +84,7 @@ 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) } @@ -120,7 +120,7 @@ pub fn listen(f: fn(Chan) -> U) -> U { f(po.chan()) } -struct PortPtr { +struct PortPtr { po: *rust_port, drop { unsafe { @@ -238,7 +238,7 @@ fn peek_chan(ch: Chan) -> bool { } /// Receive on a raw port pointer -fn recv_(p: *rust_port) -> T { +fn recv_(p: *rust_port) -> T { unsafe { let yield = 0; let yieldp = ptr::addr_of(&yield); diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 33826d10c3c0c..5af9950ff0879 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -151,7 +151,7 @@ type Buffer = { #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] -pub struct Buffer { +pub struct Buffer { header: BufferHeader, data: T, } @@ -212,10 +212,18 @@ impl PacketHeader { } #[doc(hidden)] +#[cfg(stage0)] pub struct Packet { header: PacketHeader, mut payload: Option, } +#[doc(hidden)] +#[cfg(stage1)] +#[cfg(stage2)] +pub struct Packet { + header: PacketHeader, + mut payload: Option, +} #[doc(hidden)] pub trait HasBuffer { @@ -256,12 +264,11 @@ fn unibuffer() -> ~Buffer> { } move b } - #[doc(hidden)] #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] -fn unibuffer() -> ~Buffer> { +fn unibuffer() -> ~Buffer> { let b = ~Buffer { header: BufferHeader(), data: Packet { @@ -277,6 +284,7 @@ fn unibuffer() -> ~Buffer> { } #[doc(hidden)] +#[cfg(stage0)] pub fn packet() -> *Packet { let b = unibuffer(); let p = ptr::addr_of(&(b.data)); @@ -284,6 +292,16 @@ pub fn packet() -> *Packet { unsafe { forget(move b) } p } +#[doc(hidden)] +#[cfg(stage1)] +#[cfg(stage2)] +pub fn packet() -> *Packet { + let b = unibuffer(); + let p = ptr::addr_of(&(b.data)); + // We'll take over memory management from here. + unsafe { forget(move b) } + p +} #[doc(hidden)] pub fn entangle_buffer( @@ -387,11 +405,19 @@ fn swap_state_rel(dst: &mut State, src: State) -> State { } #[doc(hidden)] +#[cfg(stage0)] pub unsafe fn get_buffer(p: *PacketHeader) -> ~Buffer { transmute((*p).buf_header()) } +#[doc(hidden)] +#[cfg(stage1)] +#[cfg(stage2)] +pub unsafe fn get_buffer(p: *PacketHeader) -> ~Buffer { + transmute((*p).buf_header()) +} // This could probably be done with SharedMutableState to avoid move_it!(). +#[cfg(stage0)] struct BufferResource { buffer: ~Buffer, @@ -413,7 +439,31 @@ struct BufferResource { } } } +#[cfg(stage1)] +#[cfg(stage2)] +struct BufferResource { + buffer: ~Buffer, + drop { + unsafe { + let b = move_it!(self.buffer); + //let p = ptr::addr_of(*b); + //error!("drop %?", p); + let old_count = atomic_sub_rel(&mut b.header.ref_count, 1); + //let old_count = atomic_xchng_rel(b.header.ref_count, 0); + if old_count == 1 { + // The new count is 0. + + // go go gadget drop glue + } + else { + forget(move b) + } + } + } +} + +#[cfg(stage0)] fn BufferResource(b: ~Buffer) -> BufferResource { //let p = ptr::addr_of(*b); //error!("take %?", p); @@ -424,8 +474,21 @@ fn BufferResource(b: ~Buffer) -> BufferResource { buffer: move b } } +#[cfg(stage1)] +#[cfg(stage2)] +fn BufferResource(b: ~Buffer) -> BufferResource { + //let p = ptr::addr_of(*b); + //error!("take %?", p); + atomic_add_acq(&mut b.header.ref_count, 1); + + BufferResource { + // tjc: ???? + buffer: move b + } +} #[doc(hidden)] +#[cfg(stage0)] pub fn send(p: SendPacketBuffered, payload: T) -> bool { let header = p.header(); @@ -467,6 +530,49 @@ pub fn send(p: SendPacketBuffered, } } } +#[doc(hidden)] +#[cfg(stage1)] +#[cfg(stage2)] +pub fn send(p: SendPacketBuffered, payload: T) -> bool { + let header = p.header(); + let p_ = p.unwrap(); + let p = unsafe { &*p_ }; + assert ptr::addr_of(&(p.header)) == header; + assert p.payload.is_none(); + p.payload = move Some(move payload); + let old_state = swap_state_rel(&mut p.header.state, Full); + match old_state { + Empty => { + // Yay, fastpath. + + // The receiver will eventually clean this up. + //unsafe { forget(p); } + return true; + } + Full => fail ~"duplicate send", + Blocked => { + debug!("waking up task for %?", p_); + let old_task = swap_task(&mut p.header.blocked_task, ptr::null()); + if !old_task.is_null() { + unsafe { + rustrt::task_signal_event( + old_task, + ptr::addr_of(&(p.header)) as *libc::c_void); + rustrt::rust_task_deref(old_task); + } + } + + // The receiver will eventually clean this up. + //unsafe { forget(p); } + return true; + } + Terminated => { + // The receiver will never receive this. Rely on drop_glue + // to clean everything up. + return false; + } + } +} /** Receives a message from a pipe. @@ -812,13 +918,24 @@ pub fn select(endpoints: ~[RecvPacketBuffered]) message. */ +#[cfg(stage0)] pub type SendPacket = SendPacketBuffered>; +#[cfg(stage1)] +#[cfg(stage2)] +pub type SendPacket = SendPacketBuffered>; #[doc(hidden)] +#[cfg(stage0)] pub fn SendPacket(p: *Packet) -> SendPacket { SendPacketBuffered(p) } +#[cfg(stage1)] +#[cfg(stage2)] +pub fn SendPacket(p: *Packet) -> SendPacket { + SendPacketBuffered(p) +} +#[cfg(stage0)] pub struct SendPacketBuffered { mut p: Option<*Packet>, mut buffer: Option>, @@ -837,7 +954,31 @@ pub struct SendPacketBuffered { // } else { "some" }); } } } +#[cfg(stage1)] +#[cfg(stage2)] +pub struct SendPacketBuffered { + mut p: Option<*Packet>, + mut buffer: Option>, +} +impl SendPacketBuffered : ::ops::Drop { + fn finalize(&self) { + //if self.p != none { + // debug!("drop send %?", option::get(self.p)); + //} + if self.p != None { + let mut p = None; + p <-> self.p; + sender_terminate(option::unwrap(move p)) + } + //unsafe { error!("send_drop: %?", + // if self.buffer == none { + // "none" + // } else { "some" }); } + } +} + +#[cfg(stage0)] pub fn SendPacketBuffered(p: *Packet) -> SendPacketBuffered { //debug!("take send %?", p); @@ -849,8 +990,50 @@ pub fn SendPacketBuffered(p: *Packet) } } } +#[cfg(stage1)] +#[cfg(stage2)] +pub fn SendPacketBuffered(p: *Packet) + -> SendPacketBuffered { + //debug!("take send %?", p); + SendPacketBuffered { + p: Some(p), + buffer: unsafe { + Some(BufferResource( + get_buffer(ptr::addr_of(&((*p).header))))) + } + } +} + +#[cfg(stage0)] +impl SendPacketBuffered { + fn unwrap() -> *Packet { + let mut p = None; + p <-> self.p; + option::unwrap(move p) + } + + pure fn header() -> *PacketHeader { + match self.p { + Some(packet) => unsafe { + let packet = &*packet; + let header = ptr::addr_of(&(packet.header)); + //forget(packet); + header + }, + None => fail ~"packet already consumed" + } + } -impl SendPacketBuffered { + fn reuse_buffer() -> BufferResource { + //error!("send reuse_buffer"); + let mut tmp = None; + tmp <-> self.buffer; + option::unwrap(move tmp) + } +} +#[cfg(stage1)] +#[cfg(stage2)] +impl SendPacketBuffered { fn unwrap() -> *Packet { let mut p = None; p <-> self.p; @@ -879,13 +1062,25 @@ impl SendPacketBuffered { /// Represents the receive end of a pipe. It can receive exactly one /// message. +#[cfg(stage0)] pub type RecvPacket = RecvPacketBuffered>; +#[cfg(stage1)] +#[cfg(stage2)] +pub type RecvPacket = RecvPacketBuffered>; #[doc(hidden)] +#[cfg(stage0)] pub fn RecvPacket(p: *Packet) -> RecvPacket { RecvPacketBuffered(p) } +#[doc(hidden)] +#[cfg(stage1)] +#[cfg(stage2)] +pub fn RecvPacket(p: *Packet) -> RecvPacket { + RecvPacketBuffered(p) +} +#[cfg(stage0)] pub struct RecvPacketBuffered { mut p: Option<*Packet>, mut buffer: Option>, @@ -904,6 +1099,29 @@ pub struct RecvPacketBuffered { // } else { "some" }); } } } +#[cfg(stage1)] +#[cfg(stage2)] +pub struct RecvPacketBuffered { + mut p: Option<*Packet>, + mut buffer: Option>, +} + +impl RecvPacketBuffered : ::ops::Drop { + fn finalize(&self) { + //if self.p != none { + // debug!("drop recv %?", option::get(self.p)); + //} + if self.p != None { + let mut p = None; + p <-> self.p; + receiver_terminate(option::unwrap(move p)) + } + //unsafe { error!("recv_drop: %?", + // if self.buffer == none { + // "none" + // } else { "some" }); } + } +} impl RecvPacketBuffered { fn unwrap() -> *Packet { @@ -934,6 +1152,7 @@ impl RecvPacketBuffered : Selectable { } } +#[cfg(stage0)] pub fn RecvPacketBuffered(p: *Packet) -> RecvPacketBuffered { //debug!("take recv %?", p); @@ -945,12 +1164,33 @@ pub fn RecvPacketBuffered(p: *Packet) } } } +#[cfg(stage1)] +#[cfg(stage2)] +pub fn RecvPacketBuffered(p: *Packet) + -> RecvPacketBuffered { + //debug!("take recv %?", p); + RecvPacketBuffered { + p: Some(p), + buffer: unsafe { + Some(BufferResource( + get_buffer(ptr::addr_of(&((*p).header))))) + } + } +} #[doc(hidden)] +#[cfg(stage0)] pub fn entangle() -> (SendPacket, RecvPacket) { let p = packet(); (SendPacket(p), RecvPacket(p)) } +#[doc(hidden)] +#[cfg(stage1)] +#[cfg(stage2)] +pub fn entangle() -> (SendPacket, RecvPacket) { + let p = packet(); + (SendPacket(p), RecvPacket(p)) +} /** Spawn a task to provide a service. @@ -1042,24 +1282,50 @@ pub trait Peekable { } #[doc(hidden)] +#[cfg(stage0)] struct Chan_ { - mut endp: Option>, + mut endp: Option> +} +#[doc(hidden)] +#[cfg(stage1)] +#[cfg(stage2)] +struct Chan_ { + mut endp: Option> } /// An endpoint that can send many messages. +#[cfg(stage0)] pub enum Chan { Chan_(Chan_) } +#[cfg(stage1)] +#[cfg(stage2)] +pub enum Chan { + Chan_(Chan_) +} #[doc(hidden)] +#[cfg(stage0)] struct Port_ { mut endp: Option>, } +#[doc(hidden)] +#[cfg(stage1)] +#[cfg(stage2)] +struct Port_ { + mut endp: Option>, +} /// An endpoint that can receive many messages. +#[cfg(stage0)] pub enum Port { Port_(Port_) } +#[cfg(stage1)] +#[cfg(stage2)] +pub enum Port { + Port_(Port_) +} /** Creates a `(chan, port)` pair. @@ -1145,9 +1411,15 @@ impl Port: Selectable { } /// Treat many ports as one. +#[cfg(stage0)] pub struct PortSet { mut ports: ~[pipes::Port], } +#[cfg(stage1)] +#[cfg(stage2)] +pub struct PortSet { + mut ports: ~[pipes::Port], +} pub fn PortSet() -> PortSet{ PortSet { @@ -1210,7 +1482,11 @@ impl PortSet : Peekable { } /// A channel that can be shared between many senders. +#[cfg(stage0)] pub type SharedChan = private::Exclusive>; +#[cfg(stage1)] +#[cfg(stage2)] +pub type SharedChan = private::Exclusive>; impl SharedChan: GenericChan { fn send(x: T) { @@ -1278,9 +1554,17 @@ proto! oneshot ( ) /// The send end of a oneshot pipe. +#[cfg(stage0)] pub type ChanOne = oneshot::client::Oneshot; +#[cfg(stage1)] +#[cfg(stage2)] +pub type ChanOne = oneshot::client::Oneshot; /// The receive end of a oneshot pipe. +#[cfg(stage0)] pub type PortOne = oneshot::server::Oneshot; +#[cfg(stage1)] +#[cfg(stage2)] +pub type PortOne = oneshot::server::Oneshot; /// Initialiase a (send-endpoint, recv-endpoint) oneshot pipe pair. pub fn oneshot() -> (PortOne, ChanOne) { diff --git a/src/libcore/private.rs b/src/libcore/private.rs index 332c763f151e8..b6ac711d7649c 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -238,7 +238,7 @@ 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) -> SharedMutableState { @@ -341,11 +341,11 @@ 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 { let data = ExData { diff --git a/src/libcore/private/global.rs b/src/libcore/private/global.rs index 69319abc00930..ee20fb665bea6 100644 --- a/src/libcore/private/global.rs +++ b/src/libcore/private/global.rs @@ -41,7 +41,7 @@ use sys::Closure; use task::spawn; use uint; -pub type GlobalDataKey = &fn(v: T); +pub type GlobalDataKey = &fn(v: T); pub unsafe fn global_data_clone_create( key: GlobalDataKey, create: &fn() -> ~T) -> T { diff --git a/src/libcore/reflect.rs b/src/libcore/reflect.rs index 55eb53bc0266a..81a36e1ae13ee 100644 --- a/src/libcore/reflect.rs +++ b/src/libcore/reflect.rs @@ -41,7 +41,7 @@ pub fn align(size: uint, align: uint) -> uint { } /// Adaptor to wrap around visitors implementing MovePtr. -pub struct MovePtrAdaptor { +pub struct MovePtrAdaptor { inner: V } pub fn MovePtrAdaptor(v: V) -> MovePtrAdaptor { diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs index 05a4e35b249e4..42765ef139ff5 100644 --- a/src/libcore/task/local_data.rs +++ b/src/libcore/task/local_data.rs @@ -45,7 +45,7 @@ use task; * * 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 diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 0a2f6634214e6..3db6fa00f16dd 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -77,7 +77,7 @@ use cast; use container::Map; use oldcomm; use option; -use pipes::{Chan, GenericChan, GenericPort, Port}; +use pipes::{Chan, GenericChan, GenericPort, Port, stream}; use pipes; use prelude::*; use private; diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 002e04ca475e4..26f4310bf1cfa 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -569,7 +569,7 @@ struct FnSig { * by the meta information because, in some cases, the * meta information is inferred. */ #[deriving_eq] -struct FnTyBase { +struct FnTyBase { meta: M, // Either FnMeta or FnVid sig: FnSig // Types of arguments/return type } diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index ce0c7a94c7cc0..8374a65f63c30 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -598,6 +598,20 @@ fn convert_methods(ccx: @crate_ctxt, } } +fn ensure_no_ty_param_bounds(ccx: @crate_ctxt, + span: span, + ty_params: &[ast::ty_param], + thing: &static/str) { + for ty_params.each |ty_param| { + if ty_param.bounds.len() > 0 { + ccx.tcx.sess.span_err( + span, + fmt!("trait bounds are not allowed in %s definitions", + thing)); + } + } +} + fn convert(ccx: @crate_ctxt, it: @ast::item) { let tcx = ccx.tcx; let rp = tcx.region_paramd_items.find(it.id); @@ -607,6 +621,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) { // These don't define types. ast::item_foreign_mod(_) | ast::item_mod(_) => {} ast::item_enum(ref enum_definition, ref ty_params) => { + ensure_no_ty_param_bounds(ccx, it.span, *ty_params, "enumeration"); let tpt = ty_of_item(ccx, it); write_ty_to_tcx(tcx, it.id, tpt.ty); get_enum_variant_types(ccx, @@ -644,6 +659,8 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) { let _ = convert_methods(ccx, provided_methods, rp, bounds); } ast::item_struct(struct_def, tps) => { + ensure_no_ty_param_bounds(ccx, it.span, tps, "structure"); + // Write the class type let tpt = ty_of_item(ccx, it); write_ty_to_tcx(tcx, it.id, tpt.ty); @@ -651,6 +668,11 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) { convert_struct(ccx, rp, struct_def, tps, tpt, it.id); } + ast::item_ty(_, ref ty_params) => { + ensure_no_ty_param_bounds(ccx, it.span, *ty_params, "type"); + let tpt = ty_of_item(ccx, it); + write_ty_to_tcx(tcx, it.id, tpt.ty); + } _ => { // This call populates the type cache with the converted type // of the item in passing. All we have to do here is to write diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index 6c831427b031e..b2b1188388f45 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -31,7 +31,7 @@ struct ValsAndBindings { mut bindings: ~[(V, VarValue)], } -struct Node { +struct Node { root: V, possible_types: T, rank: uint, diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 0c40fe283af0b..edffa32e501ee 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -79,7 +79,7 @@ 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 { @@ -130,9 +130,9 @@ 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 { @@ -267,14 +267,14 @@ fn PoisonOnFail(failed: &r/mut bool) -> PoisonOnFail { ****************************************************************************/ #[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: () } @@ -426,10 +426,10 @@ fn borrow_rwlock(state: &r/mut RWARCInner) -> &r/RWlock { // 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 { /// Access the pre-downgrade RWARC in write mode. diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index 3118a0c1ba545..16e8b63da8174 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -23,7 +23,14 @@ use core::pipes; use core::prelude::*; /// An extension of `pipes::stream` that allows both sending and receiving. -pub struct DuplexStream { +#[cfg(stage0)] +pub struct DuplexStream { + priv chan: Chan, + priv port: Port, +} +#[cfg(stage1)] +#[cfg(stage2)] +pub struct DuplexStream { priv chan: Chan, priv port: Port, } diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index afc3e72e636cb..bd684baf6b300 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -63,7 +63,7 @@ and an `Unflattener` that converts the bytes to a value. Create using the constructors in the `serial` and `pod` modules. */ -pub struct FlatPort, P: BytePort> { +pub struct FlatPort { unflattener: U, byte_port: P } @@ -74,7 +74,7 @@ byte vectors, and a `ByteChan` that transmits the bytes. Create using the constructors in the `serial` and `pod` modules. */ -pub struct FlatChan, C: ByteChan> { +pub struct FlatChan { flattener: F, byte_chan: C } @@ -181,14 +181,12 @@ pub mod pod { use core::pipes; use core::prelude::*; - pub type ReaderPort = + pub type ReaderPort = FlatPort, ReaderBytePort>; - pub type WriterChan = + pub type WriterChan = FlatChan, WriterByteChan>; - pub type PipePort = - FlatPort, PipeBytePort>; - pub type PipeChan = - FlatChan, PipeByteChan>; + pub type PipePort = FlatPort, PipeBytePort>; + pub type PipeChan = FlatChan, PipeByteChan>; /// Create a `FlatPort` from a `Reader` pub fn reader_port( @@ -352,11 +350,11 @@ pub mod flatteners { // FIXME #4074: Copy + Owned != POD - pub struct PodUnflattener { + pub struct PodUnflattener { bogus: () } - pub struct PodFlattener { + pub struct PodFlattener { bogus: () } @@ -398,14 +396,13 @@ pub mod flatteners { pub type DeserializeBuffer = ~fn(buf: &[u8]) -> T; - pub struct DeserializingUnflattener> { + pub struct DeserializingUnflattener { deserialize_buffer: DeserializeBuffer } pub type SerializeValue = ~fn(val: &T) -> ~[u8]; - pub struct SerializingFlattener> { + pub struct SerializingFlattener { serialize_value: SerializeValue } @@ -518,11 +515,11 @@ pub mod bytepipes { use core::pipes; use core::prelude::*; - pub struct ReaderBytePort { + pub struct ReaderBytePort { reader: R } - pub struct WriterByteChan { + pub struct WriterByteChan { writer: W } @@ -767,9 +764,9 @@ mod test { test_some_tcp_stream(reader_port, writer_chan, 9667); } - type ReaderPortFactory> = + type ReaderPortFactory = ~fn(TcpSocketBuf) -> FlatPort>; - type WriterChanFactory> = + type WriterChanFactory = ~fn(TcpSocketBuf) -> FlatChan>; fn test_some_tcp_stream, F: Flattener>( @@ -893,7 +890,7 @@ mod test { use core::sys; use core::task; - type PortLoader = + type PortLoader

= ~fn(~[u8]) -> FlatPort, P>; fn reader_port_loader(bytes: ~[u8] diff --git a/src/libstd/map.rs b/src/libstd/map.rs index f3016e9df21a8..2fa2825eb4cd7 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -24,9 +24,9 @@ use core::uint; use core::vec; /// A convenience type to treat a hashmap as a set -pub type Set = HashMap; +pub type Set = HashMap; -pub type HashMap = chained::T; +pub type HashMap = chained::T; pub trait StdMap { /// Return the number of elements in the map @@ -142,12 +142,12 @@ pub mod chained { mut next: Option<@Entry> } - struct HashMap_ { + struct HashMap_ { mut count: uint, mut chains: ~[mut Option<@Entry>] } - pub type T = @HashMap_; + pub type T = @HashMap_; enum SearchResult { NotFound, diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index 5231d51e31ef1..fcd9f8379b2f4 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -22,7 +22,7 @@ extern "C" mod rusti { fn init() -> T; } -pub struct PriorityQueue { +pub struct PriorityQueue { priv data: ~[T], } diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 03ef98d09c5c0..6ded82d5ae4c4 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -83,7 +83,7 @@ struct SemInner { blocked: Q } #[doc(hidden)] -enum Sem = Exclusive>; +enum Sem = Exclusive>; #[doc(hidden)] fn new_sem(count: int, q: Q) -> Sem { @@ -167,7 +167,7 @@ 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 { fn finalize(&self) { diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 1f285b992c7a7..82090f8dd62c7 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -35,7 +35,7 @@ use core::prelude::*; // * symmetric difference: ^ // These would be convenient since the methods work like `each` -pub struct TreeMap { +pub struct TreeMap { priv root: Option<~TreeNode>, priv length: uint } @@ -202,7 +202,7 @@ impl TreeMap { } /// Lazy forward iterator over a map -pub struct TreeMapIterator { +pub struct TreeMapIterator { priv stack: ~[&~TreeNode], priv node: &Option<~TreeNode>, priv current: Option<&~TreeNode> @@ -240,7 +240,7 @@ impl TreeMapIterator { } } -pub struct TreeSet { +pub struct TreeSet { priv map: TreeMap } @@ -518,7 +518,7 @@ impl TreeSet { } /// Lazy forward iterator over a set -pub struct TreeSetIterator { +pub struct TreeSetIterator { priv iter: TreeMapIterator } @@ -540,7 +540,7 @@ impl TreeSetIterator { // Nodes keep track of their level in the tree, starting at 1 in the // leaves and with a red child sharing the level of the parent. -struct TreeNode { +struct TreeNode { key: K, value: V, left: Option<~TreeNode>, diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index 9f46ebef4401b..81285e5e5635a 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -235,10 +235,17 @@ struct Exec { discovered_outputs: WorkMap } +#[cfg(stage0)] struct Work { prep: @Mut, res: Option>> } +#[cfg(stage1)] +#[cfg(stage2)] +struct Work { + prep: @Mut, + res: Option>> +} fn json_encode>(t: &T) -> ~str { do io::with_str_writer |wr| { diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index 8a5b8a127d035..0433aab51fc3e 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -110,6 +110,7 @@ pub trait ext_ctxt_ast_builder { fn ty_option(ty: @ast::Ty) -> @ast::Ty; fn ty_infer() -> @ast::Ty; fn ty_nil_ast_builder() -> @ast::Ty; + fn strip_bounds(bounds: &[ast::ty_param]) -> ~[ast::ty_param]; } impl ext_ctxt: ext_ctxt_ast_builder { @@ -370,6 +371,12 @@ impl ext_ctxt: ext_ctxt_ast_builder { } } + fn strip_bounds(bounds: &[ast::ty_param]) -> ~[ast::ty_param] { + do bounds.map |ty_param| { + ast::ty_param { bounds: @~[], ..copy *ty_param } + } + } + fn item_ty_poly(name: ident, span: span, ty: @ast::Ty, diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 774a559625828..e7a8cbb9891f8 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -248,7 +248,7 @@ impl state: to_type_decls { ast::enum_def(enum_def_ { variants: items_msg, common: None }), - self.ty_params + cx.strip_bounds(self.ty_params) ) ] } @@ -281,7 +281,7 @@ impl state: to_type_decls { self.data_name()], dummy_sp()) .add_tys(cx.ty_vars_global(self.ty_params))))), - self.ty_params)); + cx.strip_bounds(self.ty_params))); } else { items.push( @@ -299,7 +299,7 @@ impl state: to_type_decls { dummy_sp()) .add_tys(cx.ty_vars_global(self.ty_params))), self.proto.buffer_ty_path(cx)])), - self.ty_params)); + cx.strip_bounds(self.ty_params))); }; items } @@ -417,7 +417,7 @@ impl protocol: gen_init { cx.ident_of(~"__Buffer"), dummy_sp(), cx.ty_rec(fields), - params) + cx.strip_bounds(params)) } fn compile(cx: ext_ctxt) -> @ast::item { diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 67f6c4bed3f95..86dea693f8af6 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -33,6 +33,7 @@ use core::str; use core::to_bytes; /// The specific types of unsupported syntax +#[deriving_eq] pub enum ObsoleteSyntax { ObsoleteLowerCaseKindBounds, ObsoleteLet, @@ -45,16 +46,8 @@ pub enum ObsoleteSyntax { ObsoleteModeInFnType, ObsoleteMoveInit, ObsoleteBinaryMove, - ObsoleteUnsafeBlock -} - -impl ObsoleteSyntax : cmp::Eq { - pure fn eq(&self, other: &ObsoleteSyntax) -> bool { - (*self) as uint == (*other) as uint - } - pure fn ne(&self, other: &ObsoleteSyntax) -> bool { - !(*self).eq(other) - } + ObsoleteUnsafeBlock, + ObsoleteUnenforcedBound } impl ObsoleteSyntax: to_bytes::IterBytes { @@ -123,6 +116,11 @@ impl Parser { ObsoleteUnsafeBlock => ( "non-standalone unsafe block", "use an inner `unsafe { ... }` block instead" + ), + ObsoleteUnenforcedBound => ( + "unenforced type parameter bound", + "use trait bounds on the functions that take the type as \ + arguments, not on the types themselves" ) }; diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index e4a09c3c349b8..9de875485db53 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -18,7 +18,7 @@ use core::dvec::DVec; use std::map::HashMap; use std::map; -type hash_interner = +type hash_interner = {map: HashMap, vect: DVec}; diff --git a/src/test/auxiliary/issue-2526.rs b/src/test/auxiliary/issue-2526.rs index a14cc3758b19b..fc5cf1275183b 100644 --- a/src/test/auxiliary/issue-2526.rs +++ b/src/test/auxiliary/issue-2526.rs @@ -17,7 +17,7 @@ extern mod std; export context; -struct arc_destruct { +struct arc_destruct { _data: int, } diff --git a/src/test/auxiliary/test_comm.rs b/src/test/auxiliary/test_comm.rs index af321b9959f2b..6fd39368baecd 100644 --- a/src/test/auxiliary/test_comm.rs +++ b/src/test/auxiliary/test_comm.rs @@ -24,7 +24,7 @@ use core::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_t(@port_ptr) } @@ -35,7 +35,7 @@ pub fn port() -> port { } } -struct port_ptr { +struct port_ptr { po: *rust_port, } diff --git a/src/test/bench/task-perf-word-count-generic.rs b/src/test/bench/task-perf-word-count-generic.rs index 21709a487e81f..17444018356ee 100644 --- a/src/test/bench/task-perf-word-count-generic.rs +++ b/src/test/bench/task-perf-word-count-generic.rs @@ -122,15 +122,15 @@ mod map_reduce { use std::map::HashMap; use std::map; - pub type putter = fn(&K, V); + pub type putter = fn(&K, V); - pub type mapper = fn~(K1, putter); + pub type mapper = fn~(K1, putter); - pub type getter = fn() -> Option; + pub type getter = fn() -> Option; - pub type reducer = fn~(&K, getter); + pub type reducer = fn~(&K, getter); - enum ctrl_proto { + enum ctrl_proto { find_reducer(K, Chan>>), mapper_done } @@ -148,7 +148,7 @@ mod map_reduce { } ) - pub enum reduce_proto { + pub enum reduce_proto { emit_val(V), done, addref, diff --git a/src/test/compile-fail/issue-2718-a.rs b/src/test/compile-fail/issue-2718-a.rs index 2332d54037fbd..925350d9b8804 100644 --- a/src/test/compile-fail/issue-2718-a.rs +++ b/src/test/compile-fail/issue-2718-a.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub struct send_packet { +pub struct send_packet { p: T } diff --git a/src/test/run-fail/bug-811.rs b/src/test/run-fail/bug-811.rs index 739bf097d4fda..31158df4185f7 100644 --- a/src/test/run-fail/bug-811.rs +++ b/src/test/run-fail/bug-811.rs @@ -14,7 +14,7 @@ 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; } diff --git a/src/test/run-fail/issue-2444.rs b/src/test/run-fail/issue-2444.rs index b1d8c99faa519..9172364a2f916 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-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs index ec73704ca27ba..ee8cf89d528a5 100644 --- a/src/test/run-pass/auto-encode.rs +++ b/src/test/run-pass/auto-encode.rs @@ -135,11 +135,6 @@ struct Spanned { node: T, } -enum AnEnum { - AVariant, - AnotherVariant -} - #[auto_encode] #[auto_decode] struct SomeStruct { v: ~[uint] } diff --git a/src/test/run-pass/box-unbox.rs b/src/test/run-pass/box-unbox.rs index 3558501471318..ad32ffc75c9c1 100644 --- a/src/test/run-pass/box-unbox.rs +++ b/src/test/run-pass/box-unbox.rs @@ -10,7 +10,7 @@ -struct Box {c: @T} +struct Box {c: @T} fn unbox(b: Box) -> T { return *b.c; } diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs index 6bc881884522a..bccb42c493892 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -27,7 +27,7 @@ impl cat_type : cmp::Eq { // for any int value that's less than the meows field // ok: T should be in scope when resolving the trait ref for map -struct cat { +struct cat { // Yes, you can have negative meows priv mut meows : int, diff --git a/src/test/run-pass/generic-exterior-box.rs b/src/test/run-pass/generic-exterior-box.rs index 738bb73b0be4f..c2abcc7528300 100644 --- a/src/test/run-pass/generic-exterior-box.rs +++ b/src/test/run-pass/generic-exterior-box.rs @@ -10,7 +10,7 @@ -struct Recbox {x: @T} +struct Recbox {x: @T} fn reclift(t: T) -> Recbox { return Recbox {x: @t}; } diff --git a/src/test/run-pass/generic-exterior-unique.rs b/src/test/run-pass/generic-exterior-unique.rs index 2095578aefad8..a4a576abc758c 100644 --- a/src/test/run-pass/generic-exterior-unique.rs +++ b/src/test/run-pass/generic-exterior-unique.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Recbox {x: ~T} +struct Recbox {x: ~T} fn reclift(t: T) -> Recbox { return Recbox {x: ~t}; } diff --git a/src/test/run-pass/issue-2288.rs b/src/test/run-pass/issue-2288.rs index 52b3baba58e36..0fa06e2f2129b 100644 --- a/src/test/run-pass/issue-2288.rs +++ b/src/test/run-pass/issue-2288.rs @@ -11,7 +11,7 @@ trait clam { fn chowder(y: A); } -struct foo { +struct foo { x: A, } diff --git a/src/test/run-pass/issue-2311-2.rs b/src/test/run-pass/issue-2311-2.rs index 10befa7422836..21201d0a95705 100644 --- a/src/test/run-pass/issue-2311-2.rs +++ b/src/test/run-pass/issue-2311-2.rs @@ -9,7 +9,7 @@ // except according to those terms. trait clam { } -struct foo { +struct foo { x: A, } diff --git a/src/test/run-pass/issue-2445-b.rs b/src/test/run-pass/issue-2445-b.rs index 35d3d0897098b..f1b7d45e440ec 100644 --- a/src/test/run-pass/issue-2445-b.rs +++ b/src/test/run-pass/issue-2445-b.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct c1 { +struct c1 { x: T, } diff --git a/src/test/run-pass/issue-2445.rs b/src/test/run-pass/issue-2445.rs index 7cf681c9f94ef..fada6a7b02e11 100644 --- a/src/test/run-pass/issue-2445.rs +++ b/src/test/run-pass/issue-2445.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct c1 { +struct c1 { x: T, } diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index f8f2fc461c3ff..68a318eab4e3e 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -34,7 +34,7 @@ pub mod pipes { pure fn ne(&self, other: &state) -> bool { !(*self).eq(other) } } - pub type packet = { + pub type packet = { mut state: state, mut blocked_task: Option, mut payload: Option @@ -157,7 +157,7 @@ pub mod pipes { } } - pub struct send_packet { + pub struct send_packet { mut p: Option<*packet>, } @@ -185,7 +185,7 @@ pub mod pipes { } } - pub struct recv_packet { + pub struct recv_packet { mut p: Option<*packet>, } diff --git a/src/test/run-pass/issue-3149.rs b/src/test/run-pass/issue-3149.rs index 533106ff93621..c578f1144a785 100644 --- a/src/test/run-pass/issue-3149.rs +++ b/src/test/run-pass/issue-3149.rs @@ -22,7 +22,7 @@ pure fn Matrix4(m11: T, m12: T, m13: T, m14: T, } } -struct Matrix4 { +struct Matrix4 { m11: T, m12: T, m13: T, m14: T, m21: T, m22: T, m23: T, m24: T, m31: T, m32: T, m33: T, m34: T, diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index d072df4d8e880..cf0a0a07397c0 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -29,7 +29,7 @@ fn align(size: uint, align: uint) -> uint { ((size + align) - 1u) & !(align - 1u) } -enum ptr_visit_adaptor = Inner; +enum ptr_visit_adaptor = Inner; impl ptr_visit_adaptor { diff --git a/src/test/run-pass/resource-generic.rs b/src/test/run-pass/resource-generic.rs index e528cd32974ba..7165d6089e85f 100644 --- a/src/test/run-pass/resource-generic.rs +++ b/src/test/run-pass/resource-generic.rs @@ -13,7 +13,7 @@ struct Arg {val: T, fin: extern fn(T)} -struct finish { +struct finish { arg: Arg } diff --git a/src/test/run-pass/send-type-inference.rs b/src/test/run-pass/send-type-inference.rs index 8476e256cd24c..8cb597a0d792c 100644 --- a/src/test/run-pass/send-type-inference.rs +++ b/src/test/run-pass/send-type-inference.rs @@ -9,7 +9,7 @@ // except according to those terms. // tests that ctrl's type gets inferred properly -type command = {key: K, val: V}; +type command = {key: K, val: V}; fn cache_server(c: oldcomm::Chan>>) { let ctrl = oldcomm::Port();