diff --git a/doc/rust.md b/doc/rust.md index d16c2a6c072..eeedc7473a0 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -449,7 +449,7 @@ Two examples of paths with type arguments: ~~~~ # use std::map; # fn f() { -# fn id(t: T) -> T { t } +# fn id(t: T) -> T { t } type t = map::hashmap; // Type arguments used in a type expression let x = id::(10); // Type arguments used in a call expression # } @@ -1056,7 +1056,7 @@ An example of a pure function that uses an unchecked block: ~~~~ # use std::list::*; -fn pure_foldl(ls: List, u: U, f: fn(&&T, &&U) -> U) -> U { +fn pure_foldl(ls: List, u: U, f: fn(&&T, &&U) -> U) -> U { match ls { Nil => u, Cons(hd, tl) => f(hd, pure_foldl(*tl, f(hd, u), f)) @@ -1110,7 +1110,7 @@ type can always be moved, but they can only be copied when the parameter is given a [`copy` bound](#type-kinds). ~~~~ -fn id(x: T) -> T { x } +fn id(x: T) -> T { x } ~~~~ Similarly, [trait](#traits) bounds can be specified for type @@ -2638,7 +2638,7 @@ Every struct item defines a type. Within the body of an item that has type parameter declarations, the names of its type parameters are types: ~~~~~~~ -fn map(f: fn(A) -> B, xs: ~[A]) -> ~[B] { +fn map(f: fn(A) -> B, xs: ~[A]) -> ~[B] { if xs.len() == 0 { return ~[]; } let first: B = f(xs[0]); let rest: ~[B] = map(f, xs.slice(1, xs.len())); @@ -2706,7 +2706,7 @@ Putting `x` into a shared box involves copying, and the `T` parameter is assumed to be noncopyable. To change that, a bound is declared: ~~~~ -fn box(x: T) -> @T { @x } +fn box(x: T) -> @T { @x } ~~~~ Calling this second version of `box` on a noncopyable type is not diff --git a/doc/tutorial.md b/doc/tutorial.md index 8234a8f7518..25531e59759 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1583,20 +1583,20 @@ unless you explicitly declare that type parameter to have copyable // This does not compile fn head_bad(v: ~[T]) -> T { v[0] } // This does -fn head(v: ~[T]) -> T { v[0] } +fn head(v: ~[T]) -> T { v[0] } ~~~~ When instantiating a generic function, you can only instantiate it with types that fit its kinds. So you could not apply `head` to a resource type. Rust has several kinds that can be used as type bounds: -* `copy` - Copyable types. All types are copyable unless they +* `Copy` - Copyable types. All types are copyable unless they are classes with destructors or otherwise contain classes with destructors. -* `send` - Sendable types. All types are sendable unless they +* `Send` - Sendable types. All types are sendable unless they contain shared boxes, closures, or other local-heap-allocated types. -* `const` - Constant types. These are types that do not contain +* `Const` - Constant types. These are types that do not contain mutable fields nor shared boxes. > ***Note:*** Rust type kinds are syntactically very similar to @@ -2002,7 +2002,7 @@ and one for values. This means that this code is valid: ~~~~ mod buffalo { type buffalo = int; - fn buffalo(buffalo: buffalo) -> buffalo { buffalo } + fn buffalo(+buffalo: buffalo) -> buffalo { buffalo } } fn main() { let buffalo: buffalo::buffalo = 1; diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index 0f9df3c98e4..c4dd4bcf4bc 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -239,7 +239,7 @@ fn check_variants_of_ast(crate: ast::crate, codemap: codemap::codemap, pprust::ty_to_str, replace_ty_in_crate, cx); } -fn check_variants_T( +fn check_variants_T( crate: ast::crate, codemap: codemap::codemap, filename: &Path, diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 4cf0b8f332d..717993e78c1 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -89,7 +89,7 @@ pure fn build_sized_opt(size: Option, // Appending #[inline(always)] -pure fn append(lhs: @[T], rhs: &[const T]) -> @[T] { +pure fn append(lhs: @[T], rhs: &[const T]) -> @[T] { do build_sized(lhs.len() + rhs.len()) |push| { for vec::each(lhs) |x| { push(x); } for uint::range(0, rhs.len()) |i| { push(rhs[i]); } @@ -125,7 +125,7 @@ pure fn from_fn(n_elts: uint, op: iter::InitOp) -> @[T] { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value `t`. */ -pure fn from_elem(n_elts: uint, t: T) -> @[T] { +pure fn from_elem(n_elts: uint, t: T) -> @[T] { do build_sized(n_elts) |push| { let mut i: uint = 0u; while i < n_elts { push(t); i += 1u; } @@ -133,7 +133,7 @@ pure fn from_elem(n_elts: uint, t: T) -> @[T] { } #[cfg(notest)] -impl @[T]: Add<&[const T],@[T]> { +impl @[T]: Add<&[const T],@[T]> { #[inline(always)] pure fn add(rhs: &[const T]) -> @[T] { append(self, rhs) diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index f9d68975944..177ecdca9a2 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -48,7 +48,7 @@ export listen; * 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_(@PortPtr) } @@ -64,16 +64,16 @@ enum Port { * data will be silently dropped. Channels may be duplicated and * themselves transmitted over other channels. */ -enum Chan { +enum Chan { Chan_(port_id) } /// Constructs a port -fn Port() -> Port { +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(v) } @@ -82,7 +82,7 @@ impl Port { } -impl Chan { +impl Chan { fn chan() -> Chan { self } fn send(+v: T) { send(self, v) } @@ -92,12 +92,12 @@ impl Chan { } /// Open a new receiving channel for the duration of a function -fn listen(f: fn(Chan) -> U) -> U { +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 { @@ -121,7 +121,7 @@ struct PortPtr { } } -fn PortPtr(po: *rust_port) -> PortPtr { +fn PortPtr(po: *rust_port) -> PortPtr { PortPtr { po: po } @@ -135,7 +135,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, @@ -167,7 +167,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. */ -fn Chan(p: Port) -> Chan { +fn Chan(p: Port) -> Chan { Chan_(rustrt::get_port_id((**p).po)) } @@ -175,7 +175,7 @@ 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. */ -fn send(ch: Chan, +data: T) { +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); @@ -190,22 +190,22 @@ 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. */ -fn recv(p: Port) -> T { recv_((**p).po) } +fn recv(p: Port) -> T { recv_((**p).po) } /// Returns true if there are messages available -fn peek(p: Port) -> bool { peek_((**p).po) } +fn peek(p: Port) -> bool { peek_((**p).po) } #[doc(hidden)] -fn recv_chan(ch: comm::Chan) -> T { +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 = 0u; let yieldp = ptr::addr_of(yield); let mut res; @@ -231,7 +231,7 @@ fn peek_(p: *rust_port) -> bool { } /// Receive on one of two ports -fn select2(p_a: Port, p_b: Port) +fn select2(p_a: Port, p_b: Port) -> Either { let ports = ~[(**p_a).po, (**p_b).po]; let yield = 0u, yieldp = ptr::addr_of(yield); diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 1c56587434b..a1973c1d6ef 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -96,7 +96,7 @@ pure fn from_elem(+data: T) -> DList { list } -fn from_vec(+vec: &[T]) -> DList { +fn from_vec(+vec: &[T]) -> DList { do vec::foldl(DList(), vec) |list,data| { list.push(data); // Iterating left-to-right -- add newly to the tail. list @@ -417,7 +417,7 @@ impl DList { } } -impl DList { +impl DList { /// Remove data from the head of the list. O(1). fn pop() -> Option { self.pop_n().map (|nobe| nobe.data) } /// Remove data from the tail of the list. O(1). diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index 153fa69d4b8..41f88b72ca1 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -210,7 +210,7 @@ impl DVec { } } -impl DVec { +impl DVec { /** * Append all elements of a vector to the end of the list * @@ -327,7 +327,7 @@ impl DVec { } } -impl DVec: Index { +impl DVec: Index { pure fn index(&&idx: uint) -> A { self.get_elt(idx) } diff --git a/src/libcore/either.rs b/src/libcore/either.rs index 00706280ebc..bd68fab3b8e 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -29,7 +29,7 @@ fn either(f_left: fn((&T)) -> V, } } -fn lefts(eithers: &[Either]) -> ~[T] { +fn lefts(eithers: &[Either]) -> ~[T] { //! Extracts from a vector of either all the left values let mut result: ~[T] = ~[]; @@ -42,7 +42,7 @@ fn lefts(eithers: &[Either]) -> ~[T] { return result; } -fn rights(eithers: &[Either]) -> ~[U] { +fn rights(eithers: &[Either]) -> ~[U] { //! Extracts from a vector of either all the right values let mut result: ~[U] = ~[]; @@ -55,7 +55,7 @@ fn rights(eithers: &[Either]) -> ~[U] { return result; } -fn partition(eithers: &[Either]) +fn partition(eithers: &[Either]) -> {lefts: ~[T], rights: ~[U]} { /*! * Extracts from a vector of either all the left values and right values @@ -75,7 +75,7 @@ fn partition(eithers: &[Either]) return {lefts: lefts, rights: rights}; } -pure fn flip(eith: &Either) -> Either { +pure fn flip(eith: &Either) -> Either { //! Flips between left and right of a given either match *eith { @@ -84,7 +84,7 @@ pure fn flip(eith: &Either) -> Either { } } -pure fn to_result(eith: &Either) -> Result { +pure fn to_result(eith: &Either) -> Result { /*! * Converts either::t to a result::t * diff --git a/src/libcore/future.rs b/src/libcore/future.rs index cd0d2b25e95..141fafcf7d7 100644 --- a/src/libcore/future.rs +++ b/src/libcore/future.rs @@ -43,7 +43,7 @@ priv enum FutureState { } /// Methods on the `future` type -impl Future { +impl Future { fn get() -> A { //! Get the value of the future @@ -74,7 +74,7 @@ fn from_value(+val: A) -> Future { Future {state: Forced(val)} } -fn from_port(+port: future_pipe::client::waiting) -> Future { +fn from_port(+port: future_pipe::client::waiting) -> Future { /*! * Create a future from a port * @@ -105,7 +105,7 @@ fn from_fn(+f: @fn() -> A) -> Future { Future {state: Pending(f)} } -fn spawn(+blk: fn~() -> A) -> Future { +fn spawn(+blk: fn~() -> A) -> Future { /*! * Create a future from a unique closure. * @@ -156,7 +156,7 @@ fn get_ref(future: &r/Future) -> &r/A { } } -fn get(future: &Future) -> A { +fn get(future: &Future) -> A { //! Get the value of the future *get_ref(future) @@ -169,7 +169,7 @@ fn with(future: &Future, blk: fn((&A)) -> B) -> B { } proto! future_pipe ( - waiting:recv { + waiting:recv { completed(T) -> ! } ) diff --git a/src/libcore/iter-trait.rs b/src/libcore/iter-trait.rs index b3f31211340..d9e5f3a0aee 100644 --- a/src/libcore/iter-trait.rs +++ b/src/libcore/iter-trait.rs @@ -28,7 +28,7 @@ impl IMPL_T: iter::EqIter { } } -impl IMPL_T: iter::CopyableIter { +impl IMPL_T: iter::CopyableIter { pure fn filter_to_vec(pred: fn(A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } @@ -45,7 +45,7 @@ impl IMPL_T: iter::CopyableIter { pure fn find(p: fn(A) -> bool) -> Option { iter::find(self, p) } } -impl IMPL_T: iter::CopyableOrderedIter { +impl IMPL_T: iter::CopyableOrderedIter { pure fn min() -> A { iter::min(self) } pure fn max() -> A { iter::max(self) } } diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index e21c9b3c1bb..30bd66bf9f8 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -28,14 +28,14 @@ trait TimesIx{ pure fn timesi(it: fn(uint) -> bool); } -trait CopyableIter { +trait CopyableIter { pure fn filter_to_vec(pred: fn(A) -> bool) -> ~[A]; pure fn map_to_vec(op: fn(A) -> B) -> ~[B]; pure fn to_vec() -> ~[A]; pure fn find(p: fn(A) -> bool) -> Option; } -trait CopyableOrderedIter { +trait CopyableOrderedIter { pure fn min() -> A; pure fn max() -> A; } @@ -82,7 +82,7 @@ pure fn any>(self: IA, blk: fn(A) -> bool) -> bool { return false; } -pure fn filter_to_vec>(self: IA, +pure fn filter_to_vec>(self: IA, prd: fn(A) -> bool) -> ~[A] { do vec::build_sized_opt(self.size_hint()) |push| { for self.each |a| { @@ -91,7 +91,7 @@ pure fn filter_to_vec>(self: IA, } } -pure fn map_to_vec>(self: IA, op: fn(A) -> B) +pure fn map_to_vec>(self: IA, op: fn(A) -> B) -> ~[B] { do vec::build_sized_opt(self.size_hint()) |push| { for self.each |a| { @@ -100,7 +100,7 @@ pure fn map_to_vec>(self: IA, op: fn(A) -> B) } } -pure fn flat_map_to_vec,IB:BaseIter>( +pure fn flat_map_to_vec,IB:BaseIter>( self: IA, op: fn(A) -> IB) -> ~[B] { do vec::build |push| { @@ -120,7 +120,7 @@ pure fn foldl>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B { return b; } -pure fn to_vec>(self: IA) -> ~[A] { +pure fn to_vec>(self: IA) -> ~[A] { foldl::(self, ~[], |r, a| vec::append(copy r, ~[a])) } @@ -163,7 +163,7 @@ pure fn repeat(times: uint, blk: fn() -> bool) { } } -pure fn min>(self: IA) -> A { +pure fn min>(self: IA) -> A { match do foldl::,IA>(self, None) |a, b| { match a { Some(a_) if a_ < b => { @@ -179,7 +179,7 @@ pure fn min>(self: IA) -> A { } } -pure fn max>(self: IA) -> A { +pure fn max>(self: IA) -> A { match do foldl::,IA>(self, None) |a, b| { match a { Some(a_) if a_ > b => { @@ -195,7 +195,7 @@ pure fn max>(self: IA) -> A { } } -pure fn find>(self: IA, +pure fn find>(self: IA, p: fn(A) -> bool) -> Option { for self.each |i| { if p(i) { return Some(i) } @@ -271,7 +271,7 @@ pure fn from_fn>(n_elts: uint, op: InitOp) -> BT { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value `t`. */ -pure fn from_elem>(n_elts: uint, t: T) -> BT { +pure fn from_elem>(n_elts: uint, t: T) -> BT { do build_sized(n_elts) |push| { let mut i: uint = 0u; while i < n_elts { push(t); i += 1u; } @@ -280,7 +280,7 @@ pure fn from_elem>(n_elts: uint, t: T) -> BT { /// Appending two generic sequences #[inline(always)] -pure fn append,BT: Buildable>( +pure fn append,BT: Buildable>( lhs: IT, rhs: IT) -> BT { let size_opt = lhs.size_hint().chain( |sz1| rhs.size_hint().map(|sz2| sz1+sz2)); @@ -293,7 +293,7 @@ pure fn append,BT: Buildable>( /// Copies a generic sequence, possibly converting it to a different /// type of sequence. #[inline(always)] -pure fn copy_seq,BT: Buildable>( +pure fn copy_seq,BT: Buildable>( v: IT) -> BT { do build_sized_opt(v.size_hint()) |push| { for v.each |x| { push(x); } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 5b7aee4d74c..980f1899566 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -16,7 +16,7 @@ enum Option { Some(T), } -pure fn get(opt: Option) -> T { +pure fn get(opt: Option) -> T { /*! * Gets the value out of an option * @@ -45,7 +45,7 @@ pure fn get_ref(opt: &r/Option) -> &r/T { } } -pure fn expect(opt: Option, reason: ~str) -> T { +pure fn expect(opt: Option, reason: ~str) -> T { /*! * Gets the value out of an option, printing a specified message on * failure @@ -128,7 +128,7 @@ pure fn is_some(opt: Option) -> bool { !is_none(opt) } -pure fn get_default(opt: Option, def: T) -> T { +pure fn get_default(opt: Option, def: T) -> T { //! Returns the contained value or a default match opt { Some(x) => x, None => def } @@ -226,7 +226,7 @@ impl &Option { pure fn get_ref() -> &self/T { get_ref(self) } } -impl Option { +impl Option { /** * Gets the value out of an option * diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index da4b1b04673..27baf3d931e 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -152,7 +152,7 @@ fn buffer_header() -> BufferHeader { BufferHeader() } // This is for protocols to associate extra data to thread around. #[doc(hidden)] -type Buffer = { +type Buffer = { header: BufferHeader, data: T, }; @@ -191,7 +191,7 @@ struct PacketHeader { reinterpret_cast(&self.buffer) } - fn set_buffer(b: ~Buffer) unsafe { + fn set_buffer(b: ~Buffer) unsafe { self.buffer = reinterpret_cast(&b); } } @@ -205,7 +205,7 @@ fn PacketHeader() -> PacketHeader { } #[doc(hidden)] -type Packet = { +type Packet = { header: PacketHeader, mut payload: Option, }; @@ -213,7 +213,7 @@ type Packet = { // XXX remove me #[cfg(stage0)] #[allow(non_camel_case_types)] -type packet = Packet; +type packet = Packet; #[doc(hidden)] trait HasBuffer { @@ -221,7 +221,7 @@ 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; } @@ -235,14 +235,14 @@ trait has_buffer { } #[cfg(stage0)] // XXX remove me -impl packet: has_buffer { +impl packet: has_buffer { fn set_buffer(b: *libc::c_void) { self.header.buffer = b; } } #[doc(hidden)] -fn mk_packet() -> Packet { +fn mk_packet() -> Packet { { header: PacketHeader(), mut payload: None @@ -250,7 +250,7 @@ fn mk_packet() -> Packet { } #[doc(hidden)] -fn unibuffer() -> ~Buffer> { +fn unibuffer() -> ~Buffer> { let b = ~{ header: BufferHeader(), data: { @@ -267,7 +267,7 @@ fn unibuffer() -> ~Buffer> { } #[doc(hidden)] -fn packet() -> *Packet { +fn packet() -> *Packet { let b = unibuffer(); let p = ptr::addr_of(b.data); // We'll take over memory management from here. @@ -276,7 +276,7 @@ fn packet() -> *Packet { } #[doc(hidden)] -fn entangle_buffer( +fn entangle_buffer( +buffer: ~Buffer, init: fn(*libc::c_void, x: &T) -> *Packet) -> (SendPacketBuffered, RecvPacketBuffered) @@ -368,12 +368,12 @@ fn swap_state_rel(+dst: &mut State, src: State) -> State { } #[doc(hidden)] -unsafe fn get_buffer(p: *PacketHeader) -> ~Buffer { +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 { @@ -393,7 +393,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); @@ -404,7 +404,7 @@ fn BufferResource(+b: ~Buffer) -> BufferResource { } #[doc(hidden)] -fn send(+p: SendPacketBuffered, +fn send(+p: SendPacketBuffered, +payload: T) -> bool { let header = p.header(); let p_ = p.unwrap(); @@ -448,7 +448,7 @@ fn send(+p: SendPacketBuffered, Fails if the sender closes the connection. */ -fn recv(+p: RecvPacketBuffered) -> T { +fn recv(+p: RecvPacketBuffered) -> T { option::unwrap_expect(try_recv(p), "connection closed") } @@ -458,7 +458,7 @@ Returns `none` if the sender has closed the connection without sending a message, or `Some(T)` if a message was received. */ -fn try_recv(+p: RecvPacketBuffered) +fn try_recv(+p: RecvPacketBuffered) -> Option { let p_ = p.unwrap(); @@ -552,7 +552,7 @@ fn try_recv(+p: RecvPacketBuffered) } /// Returns true if messages are available. -pure fn peek(p: &RecvPacketBuffered) -> bool { +pure fn peek(p: &RecvPacketBuffered) -> bool { match unsafe {(*p.header()).state} { Empty => false, Blocked => fail ~"peeking on blocked packet", @@ -560,14 +560,14 @@ pure fn peek(p: &RecvPacketBuffered) -> bool { } } -impl RecvPacketBuffered { +impl RecvPacketBuffered { 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 => { @@ -596,7 +596,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 => { @@ -704,7 +704,7 @@ Sometimes messages will be available on both endpoints at once. In this case, `select2` may return either `left` or `right`. */ -fn select2( +fn select2( +a: RecvPacketBuffered, +b: RecvPacketBuffered) -> Either<(Option, RecvPacketBuffered), @@ -746,7 +746,7 @@ fn select2i(a: &A, b: &B) -> Either<(), ()> { list of the remaining endpoints. */ -fn select(+endpoints: ~[RecvPacketBuffered]) +fn select(+endpoints: ~[RecvPacketBuffered]) -> (uint, Option, ~[RecvPacketBuffered]) { let ready = wait_many(endpoints.map(|p| p.header())); @@ -760,25 +760,25 @@ fn select(+endpoints: ~[RecvPacketBuffered]) message. */ -type SendPacket = SendPacketBuffered>; +type SendPacket = SendPacketBuffered>; #[doc(hidden)] -fn SendPacket(p: *Packet) -> SendPacket { +fn SendPacket(p: *Packet) -> SendPacket { SendPacketBuffered(p) } // XXX remove me #[cfg(stage0)] #[allow(non_camel_case_types)] -type send_packet = SendPacket; +type send_packet = SendPacket; // XXX remove me #[cfg(stage0)] -fn send_packet(p: *packet) -> SendPacket { +fn send_packet(p: *packet) -> SendPacket { SendPacket(p) } -struct SendPacketBuffered { +struct SendPacketBuffered { mut p: Option<*Packet>, mut buffer: Option>, drop { @@ -821,7 +821,7 @@ struct SendPacketBuffered { } } -fn SendPacketBuffered(p: *Packet) +fn SendPacketBuffered(p: *Packet) -> SendPacketBuffered { //debug!("take send %?", p); SendPacketBuffered { @@ -836,30 +836,30 @@ fn SendPacketBuffered(p: *Packet) // XXX remove me #[cfg(stage0)] #[allow(non_camel_case_types)] -type send_packet_buffered = +type send_packet_buffered = SendPacketBuffered; /// Represents the receive end of a pipe. It can receive exactly one /// message. -type RecvPacket = RecvPacketBuffered>; +type RecvPacket = RecvPacketBuffered>; #[doc(hidden)] -fn RecvPacket(p: *Packet) -> RecvPacket { +fn RecvPacket(p: *Packet) -> RecvPacket { RecvPacketBuffered(p) } // XXX remove me #[cfg(stage0)] #[allow(non_camel_case_types)] -type recv_packet = RecvPacket; +type recv_packet = RecvPacket; // XXX remove me #[cfg(stage0)] -fn recv_packet(p: *packet) -> RecvPacket { +fn recv_packet(p: *packet) -> RecvPacket { RecvPacket(p) } -struct RecvPacketBuffered : Selectable { +struct RecvPacketBuffered : Selectable { mut p: Option<*Packet>, mut buffer: Option>, drop { @@ -902,7 +902,7 @@ struct RecvPacketBuffered : Selectable { } } -fn RecvPacketBuffered(p: *Packet) +fn RecvPacketBuffered(p: *Packet) -> RecvPacketBuffered { //debug!("take recv %?", p); RecvPacketBuffered { @@ -917,11 +917,11 @@ fn RecvPacketBuffered(p: *Packet) // XXX remove me #[cfg(stage0)] #[allow(non_camel_case_types)] -type recv_packet_buffered = +type recv_packet_buffered = RecvPacketBuffered; #[doc(hidden)] -fn entangle() -> (SendPacket, RecvPacket) { +fn entangle() -> (SendPacket, RecvPacket) { let p = packet(); (SendPacket(p), RecvPacket(p)) } @@ -933,7 +933,7 @@ endpoint. The send endpoint is returned to the caller and the receive endpoint is passed to the new task. */ -fn spawn_service( +fn spawn_service( init: extern fn() -> (SendPacketBuffered, RecvPacketBuffered), +service: fn~(+RecvPacketBuffered)) @@ -957,7 +957,7 @@ fn spawn_service( receive state. */ -fn spawn_service_recv( +fn spawn_service_recv( init: extern fn() -> (RecvPacketBuffered, SendPacketBuffered), +service: fn~(+SendPacketBuffered)) @@ -980,13 +980,13 @@ fn spawn_service_recv( // Streams - Make pipes a little easier in general. proto! streamp ( - Open:send { + Open:send { data(T) -> Open } ) /// A trait for things that can send multiple messages. -trait Channel { +trait Channel { // It'd be nice to call this send, but it'd conflict with the // built in send kind. @@ -998,7 +998,7 @@ trait Channel { } /// A trait for things that can receive multiple messages. -trait Recv { +trait Recv { /// Receives a message, or fails if the connection closes. fn recv() -> T; @@ -1016,18 +1016,18 @@ trait Recv { } #[doc(hidden)] -type Chan_ = { mut endp: Option> }; +type Chan_ = { mut endp: Option> }; /// An endpoint that can send many messages. -enum Chan { +enum Chan { Chan_(Chan_) } #[doc(hidden)] -type Port_ = { mut endp: Option> }; +type Port_ = { mut endp: Option> }; /// An endpoint that can receive many messages. -enum Port { +enum Port { Port_(Port_) } @@ -1036,13 +1036,13 @@ enum Port { These allow sending or receiving an unlimited number of messages. */ -fn stream() -> (Chan, Port) { +fn stream() -> (Chan, Port) { let (c, s) = streamp::init(); (Chan_({ mut endp: Some(c) }), Port_({ mut endp: Some(s) })) } -impl Chan: Channel { +impl Chan: Channel { fn send(+x: T) { let mut endp = None; endp <-> self.endp; @@ -1063,7 +1063,7 @@ impl Chan: Channel { } } -impl Port: Recv { +impl Port: Recv { fn recv() -> T { let mut endp = None; endp <-> self.endp; @@ -1097,7 +1097,7 @@ impl Port: Recv { } /// Treat many ports as one. -struct PortSet : Recv { +struct PortSet : Recv { mut ports: ~[pipes::Port], fn add(+port: pipes::Port) { @@ -1146,13 +1146,13 @@ struct PortSet : Recv { } } -fn PortSet() -> PortSet{ +fn PortSet() -> PortSet{ PortSet { ports: ~[] } } -impl Port: Selectable { +impl Port: Selectable { pure fn header() -> *PacketHeader unchecked { match self.endp { Some(endp) => endp.header(), @@ -1162,9 +1162,9 @@ impl Port: Selectable { } /// A channel that can be shared between many senders. -type SharedChan = unsafe::Exclusive>; +type SharedChan = unsafe::Exclusive>; -impl SharedChan: Channel { +impl SharedChan: Channel { fn send(+x: T) { let mut xx = Some(x); do self.with |chan| { @@ -1185,19 +1185,19 @@ impl SharedChan: Channel { } /// Converts a `chan` into a `shared_chan`. -fn SharedChan(+c: Chan) -> SharedChan { +fn SharedChan(+c: Chan) -> SharedChan { unsafe::exclusive(c) } /// Receive a message from one of two endpoints. -trait Select2 { +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 Recv> +impl, Right: Selectable Recv> (Left, Right): Select2 { fn select() -> Either { @@ -1220,18 +1220,18 @@ impl, Right: Selectable Recv> } proto! oneshot ( - Oneshot:send { + Oneshot:send { send(T) -> ! } ) /// The send end of a oneshot pipe. -type ChanOne = oneshot::client::Oneshot; +type ChanOne = oneshot::client::Oneshot; /// The receive end of a oneshot pipe. -type PortOne = oneshot::server::Oneshot; +type PortOne = oneshot::server::Oneshot; /// Initialiase a (send-endpoint, recv-endpoint) oneshot pipe pair. -fn oneshot() -> (ChanOne, PortOne) { +fn oneshot() -> (ChanOne, PortOne) { oneshot::init() } @@ -1239,13 +1239,13 @@ fn oneshot() -> (ChanOne, PortOne) { * Receive a message from a oneshot pipe, failing if the connection was * closed. */ -fn recv_one(+port: PortOne) -> T { +fn recv_one(+port: PortOne) -> T { let oneshot::send(message) = recv(port); message } /// Receive a message from a oneshot pipe unless the connection was closed. -fn try_recv_one (+port: PortOne) -> Option { +fn try_recv_one (+port: PortOne) -> Option { let message = try_recv(port); if message.is_none() { None } @@ -1256,7 +1256,7 @@ fn try_recv_one (+port: PortOne) -> Option { } /// Send a message on a oneshot pipe, failing if the connection was closed. -fn send_one(+chan: ChanOne, +data: T) { +fn send_one(+chan: ChanOne, +data: T) { oneshot::client::send(chan, data); } @@ -1264,7 +1264,7 @@ fn send_one(+chan: ChanOne, +data: T) { * Send a message on a oneshot pipe, or return false if the connection was * closed. */ -fn try_send_one(+chan: ChanOne, +data: T) +fn try_send_one(+chan: ChanOne, +data: T) -> bool { oneshot::client::try_send(chan, data).is_some() } diff --git a/src/libcore/priv.rs b/src/libcore/priv.rs index 9330d376cad..046621897f8 100644 --- a/src/libcore/priv.rs +++ b/src/libcore/priv.rs @@ -27,7 +27,7 @@ type GlobalPtr = *libc::uintptr_t; * or, if no channel exists creates and installs a new channel and sets up a * new task to receive from it. */ -unsafe fn chan_from_global_ptr( +unsafe fn chan_from_global_ptr( global: GlobalPtr, task_fn: fn() -> task::TaskBuilder, +f: fn~(comm::Port) diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index 35135b1fd23..77a5dbbc310 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -165,12 +165,12 @@ impl Rng { } /// Choose an item randomly, failing if values is empty - fn choose(values: &[T]) -> T { + fn choose(values: &[T]) -> T { self.choose_option(values).get() } /// Choose Some(item) randomly, returning None if values is empty - fn choose_option(values: &[T]) -> Option { + fn choose_option(values: &[T]) -> Option { if values.is_empty() { None } else { @@ -182,7 +182,7 @@ impl Rng { * Choose an item respecting the relative weights, failing if the sum of * the weights is 0 */ - fn choose_weighted(v : &[Weighted]) -> T { + fn choose_weighted(v : &[Weighted]) -> T { self.choose_weighted_option(v).get() } @@ -190,7 +190,7 @@ impl Rng { * Choose Some(item) respecting the relative weights, returning none if * the sum of the weights is 0 */ - fn choose_weighted_option(v: &[Weighted]) -> Option { + fn choose_weighted_option(v: &[Weighted]) -> Option { let mut total = 0u; for v.each |item| { total += item.weight; @@ -213,7 +213,7 @@ impl Rng { * Return a vec containing copies of the items, in order, where * the weight of the item determines how many copies there are */ - fn weighted_vec(v: &[Weighted]) -> ~[T] { + fn weighted_vec(v: &[Weighted]) -> ~[T] { let mut r = ~[]; for v.each |item| { for uint::range(0u, item.weight) |_i| { @@ -224,7 +224,7 @@ impl Rng { } /// Shuffle a vec - fn shuffle(values: &[T]) -> ~[T] { + fn shuffle(values: &[T]) -> ~[T] { let mut m = vec::from_slice(values); self.shuffle_mut(m); return m; diff --git a/src/libcore/result.rs b/src/libcore/result.rs index e4028a466e0..7f3f35acc90 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -18,7 +18,7 @@ enum Result { * * If the result is an error */ -pure fn get(res: Result) -> T { +pure fn get(res: Result) -> T { match res { Ok(t) => t, Err(the_err) => unchecked { @@ -50,7 +50,7 @@ pure fn get_ref(res: &a/Result) -> &a/T { * * If the result is not an error */ -pure fn get_err(res: Result) -> U { +pure fn get_err(res: Result) -> U { match res { Err(u) => u, Ok(_) => fail ~"get_err called on ok result" @@ -76,7 +76,7 @@ pure fn is_err(res: Result) -> bool { * `ok` result variants are converted to `either::right` variants, `err` * result variants are converted to `either::left`. */ -pure fn to_either(res: Result) -> Either { +pure fn to_either(res: Result) -> Either { match res { Ok(res) => either::Right(res), Err(fail_) => either::Left(fail_) @@ -97,7 +97,7 @@ pure fn to_either(res: Result) -> Either { * ok(parse_buf(buf)) * } */ -fn chain(res: Result, op: fn(T) -> Result) +fn chain(res: Result, op: fn(T) -> Result) -> Result { match res { Ok(t) => op(t), @@ -113,7 +113,7 @@ fn chain(res: Result, op: fn(T) -> Result) * immediately returned. This function can be used to pass through a * successful result while handling an error. */ -fn chain_err( +fn chain_err( res: Result, op: fn(V) -> Result) -> Result { @@ -173,7 +173,7 @@ fn iter_err(res: Result, f: fn(E)) { * parse_buf(buf) * } */ -fn map(res: Result, op: fn(T) -> U) +fn map(res: Result, op: fn(T) -> U) -> Result { match res { Ok(t) => Ok(op(t)), @@ -189,7 +189,7 @@ fn map(res: Result, op: fn(T) -> U) * is immediately returned. This function can be used to pass through a * successful result while handling an error. */ -fn map_err(res: Result, op: fn(E) -> F) +fn map_err(res: Result, op: fn(E) -> F) -> Result { match res { Ok(t) => Ok(t), @@ -217,10 +217,10 @@ impl Result { } } -impl Result { +impl Result { fn get() -> T { get(self) } - fn map_err(op: fn(E) -> F) -> Result { + fn map_err(op: fn(E) -> F) -> Result { match self { Ok(t) => Ok(t), Err(e) => Err(op(e)) @@ -228,10 +228,10 @@ impl Result { } } -impl Result { +impl Result { fn get_err() -> E { get_err(self) } - fn map(op: fn(T) -> U) -> Result { + fn map(op: fn(T) -> U) -> Result { match self { Ok(t) => Ok(op(t)), Err(e) => Err(e) @@ -239,12 +239,12 @@ impl Result { } } -impl Result { - fn chain(op: fn(T) -> Result) -> Result { +impl Result { + fn chain(op: fn(T) -> Result) -> Result { chain(self, op) } - fn chain_err(op: fn(E) -> Result) -> Result { + fn chain_err(op: fn(E) -> Result) -> Result { chain_err(self, op) } } @@ -266,7 +266,7 @@ impl Result { * assert incd == ~[2u, 3u, 4u]; * } */ -fn map_vec( +fn map_vec( ts: &[T], op: fn(T) -> Result) -> Result<~[V],U> { let mut vs: ~[V] = ~[]; @@ -280,7 +280,7 @@ fn map_vec( return Ok(vs); } -fn map_opt( +fn map_opt( o_t: Option, op: fn(T) -> Result) -> Result,U> { match o_t { @@ -301,7 +301,7 @@ fn map_opt( * used in 'careful' code contexts where it is both appropriate and easy * to accommodate an error like the vectors being of different lengths. */ -fn map_vec2(ss: &[S], ts: &[T], +fn map_vec2(ss: &[S], ts: &[T], op: fn(S,T) -> Result) -> Result<~[V],U> { assert vec::same_length(ss, ts); @@ -324,7 +324,7 @@ fn map_vec2(ss: &[S], ts: &[T], * error. This could be implemented using `map2()` but it is more efficient * on its own as no result vector is built. */ -fn iter_vec2(ss: &[S], ts: &[T], +fn iter_vec2(ss: &[S], ts: &[T], op: fn(S,T) -> Result<(),U>) -> Result<(),U> { assert vec::same_length(ss, ts); diff --git a/src/libcore/send_map.rs b/src/libcore/send_map.rs index 3eb8e581cbc..a292d011644 100644 --- a/src/libcore/send_map.rs +++ b/src/libcore/send_map.rs @@ -8,7 +8,7 @@ use cmp::Eq; use hash::Hash; use to_bytes::IterBytes; -trait SendMap { +trait SendMap { // FIXME(#3148) ^^^^ once find_ref() works, we can drop V:copy fn insert(&mut self, +k: K, +v: V) -> bool; @@ -315,7 +315,7 @@ mod linear { } } - impl LinearMap { + impl LinearMap { fn find(&const self, k: &K) -> Option { match self.bucket_for_key(self.buckets, k) { FoundEntry(idx) => { @@ -342,17 +342,17 @@ mod linear { } - impl LinearMap { + impl LinearMap { fn each(&self, blk: fn(+K,+V) -> bool) { self.each_ref(|k,v| blk(copy *k, copy *v)); } } - impl LinearMap { + impl LinearMap { fn each_key(&self, blk: fn(+K) -> bool) { self.each_key_ref(|k| blk(copy *k)); } } - impl LinearMap { + impl LinearMap { fn each_value(&self, blk: fn(+V) -> bool) { self.each_value_ref(|v| blk(copy *v)); } diff --git a/src/libcore/task.rs b/src/libcore/task.rs index 6db50291b95..32ce963ebbb 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -380,7 +380,7 @@ impl TaskBuilder { spawn_raw(x.opts, x.gen_body(f)); } /// Runs a task, while transfering ownership of one argument to the child. - fn spawn_with(+arg: A, +f: fn~(+A)) { + fn spawn_with(+arg: A, +f: fn~(+A)) { let arg = ~mut Some(arg); do self.spawn { f(option::swap_unwrap(arg)) @@ -398,7 +398,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 { @@ -413,7 +413,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(); @@ -437,7 +437,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; @@ -504,7 +504,7 @@ fn spawn_supervised(+f: fn~()) { task().supervised().spawn(f) } -fn spawn_with(+arg: A, +f: fn~(+A)) { +fn spawn_with(+arg: A, +f: fn~(+A)) { /*! * Runs a task, while transfering ownership of one argument to the * child. @@ -518,7 +518,7 @@ fn spawn_with(+arg: A, +f: fn~(+A)) { task().spawn_with(arg, f) } -fn spawn_listener(+f: fn~(comm::Port)) -> comm::Chan { +fn spawn_listener(+f: fn~(comm::Port)) -> comm::Chan { /*! * Runs a new task while providing a channel from the parent to the child * @@ -528,7 +528,7 @@ fn spawn_listener(+f: fn~(comm::Port)) -> comm::Chan { task().spawn_listener(f) } -fn spawn_conversation +fn spawn_conversation (+f: fn~(comm::Port, comm::Chan)) -> (comm::Port, comm::Chan) { /*! @@ -557,7 +557,7 @@ fn spawn_sched(mode: SchedMode, +f: fn~()) { task().sched_mode(mode).spawn(f) } -fn try(+f: fn~() -> T) -> Result { +fn try(+f: fn~() -> T) -> Result { /*! * Execute a function in another task and return either the return value * of the function or result::err. @@ -1314,10 +1314,10 @@ fn spawn_raw(+opts: TaskOpts, +f: fn~()) { * * These two cases aside, the interface is safe. */ -type LocalDataKey = &fn(+@T); +type LocalDataKey = &fn(+@T); trait LocalData { } -impl @T: LocalData { } +impl @T: LocalData { } impl LocalData: Eq { pure fn eq(&&other: LocalData) -> bool unsafe { @@ -1365,7 +1365,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. @@ -1375,7 +1375,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)> { @@ -1393,7 +1393,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> { @@ -1414,21 +1414,21 @@ unsafe fn local_get_helper( } } -unsafe fn local_pop( +unsafe fn local_pop( task: *rust_task, key: LocalDataKey) -> Option<@T> { local_get_helper(task, key, true) } -unsafe fn local_get( +unsafe fn local_get( task: *rust_task, key: LocalDataKey) -> Option<@T> { local_get_helper(task, key, false) } -unsafe fn local_set( +unsafe fn local_set( task: *rust_task, key: LocalDataKey, +data: @T) { let map = get_task_local_map(task); @@ -1460,7 +1460,7 @@ unsafe fn local_set( } } -unsafe fn local_modify( +unsafe fn local_modify( task: *rust_task, key: LocalDataKey, modify_fn: fn(Option<@T>) -> Option<@T>) { @@ -1476,7 +1476,7 @@ unsafe fn local_modify( * Remove a task-local data value from the table, returning the * reference that was originally created to insert it. */ -unsafe fn local_data_pop( +unsafe fn local_data_pop( key: LocalDataKey) -> Option<@T> { local_pop(rustrt::rust_get_task(), key) @@ -1485,7 +1485,7 @@ unsafe fn local_data_pop( * Retrieve a task-local data value. It will also be kept alive in the * table until explicitly removed. */ -unsafe fn local_data_get( +unsafe fn local_data_get( key: LocalDataKey) -> Option<@T> { local_get(rustrt::rust_get_task(), key) @@ -1494,7 +1494,7 @@ 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). */ -unsafe fn local_data_set( +unsafe fn local_data_set( key: LocalDataKey, +data: @T) { local_set(rustrt::rust_get_task(), key, data) @@ -1503,7 +1503,7 @@ unsafe fn local_data_set( * Modify a task-local data value. If the function returns 'none', the * data is removed (and its reference dropped). */ -unsafe fn local_data_modify( +unsafe fn local_data_modify( key: LocalDataKey, modify_fn: fn(Option<@T>) -> Option<@T>) { diff --git a/src/libcore/to_str.rs b/src/libcore/to_str.rs index 6303bbbf0e5..76d684a16cd 100644 --- a/src/libcore/to_str.rs +++ b/src/libcore/to_str.rs @@ -50,13 +50,13 @@ impl &str: ToStr { fn to_str() -> ~str { str::from_slice(self) } } -impl (A, B): ToStr { +impl (A, B): ToStr { fn to_str() -> ~str { let (a, b) = self; ~"(" + a.to_str() + ~", " + b.to_str() + ~")" } } -impl (A, B, C): ToStr { +impl (A, B, C): ToStr { fn to_str() -> ~str { let (a, b, c) = self; ~"(" + a.to_str() + ~", " + b.to_str() + ~", " + c.to_str() + ~")" diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index 2ab8af78b8a..4114adef8f0 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -12,7 +12,7 @@ trait TupleOps { pure fn swap() -> (U, T); } -impl (T, U): TupleOps { +impl (T, U): TupleOps { /// Return the first element of self pure fn first() -> T { @@ -39,7 +39,7 @@ trait ExtendedTupleOps { fn map(f: fn(A, B) -> C) -> ~[C]; } -impl (&[A], &[B]): ExtendedTupleOps { +impl (&[A], &[B]): ExtendedTupleOps { fn zip() -> ~[(A, B)] { let (a, b) = self; @@ -52,7 +52,7 @@ impl (&[A], &[B]): ExtendedTupleOps { } } -impl (~[A], ~[B]): ExtendedTupleOps { +impl (~[A], ~[B]): ExtendedTupleOps { fn zip() -> ~[(A, B)] { // XXX: Bad copy diff --git a/src/libcore/unsafe.rs b/src/libcore/unsafe.rs index 2b57d694cbf..5539aa7d89e 100644 --- a/src/libcore/unsafe.rs +++ b/src/libcore/unsafe.rs @@ -137,7 +137,7 @@ fn ArcDestruct(data: *libc::c_void) -> ArcDestruct { } } -unsafe fn unwrap_shared_mutable_state(+rc: SharedMutableState) +unsafe fn unwrap_shared_mutable_state(+rc: SharedMutableState) -> T { struct DeathThroes { mut ptr: Option<~ArcData>, @@ -207,9 +207,9 @@ unsafe fn unwrap_shared_mutable_state(+rc: SharedMutableState) * Data races between tasks can result in crashes and, with sufficient * cleverness, arbitrary type coercion. */ -type SharedMutableState = ArcDestruct; +type SharedMutableState = ArcDestruct; -unsafe fn shared_mutable_state(+data: T) -> SharedMutableState { +unsafe fn shared_mutable_state(+data: T) -> SharedMutableState { let data = ~ArcData { count: 1, unwrapper: 0, data: Some(data) }; unsafe { let ptr = unsafe::transmute(data); @@ -218,7 +218,7 @@ unsafe fn shared_mutable_state(+data: T) -> SharedMutableState { } #[inline(always)] -unsafe fn get_shared_mutable_state(rc: &a/SharedMutableState) +unsafe fn get_shared_mutable_state(rc: &a/SharedMutableState) -> &a/mut T { unsafe { let ptr: ~ArcData = unsafe::reinterpret_cast(&(*rc).data); @@ -230,7 +230,7 @@ unsafe fn get_shared_mutable_state(rc: &a/SharedMutableState) } } #[inline(always)] -unsafe fn get_shared_immutable_state(rc: &a/SharedMutableState) +unsafe fn get_shared_immutable_state(rc: &a/SharedMutableState) -> &a/T { unsafe { let ptr: ~ArcData = unsafe::reinterpret_cast(&(*rc).data); @@ -242,7 +242,7 @@ unsafe fn get_shared_immutable_state(rc: &a/SharedMutableState) } } -unsafe fn clone_shared_mutable_state(rc: &SharedMutableState) +unsafe fn clone_shared_mutable_state(rc: &SharedMutableState) -> SharedMutableState { unsafe { let ptr: ~ArcData = unsafe::reinterpret_cast(&(*rc).data); @@ -312,20 +312,20 @@ 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. */ -struct Exclusive { x: SharedMutableState> } +struct Exclusive { x: SharedMutableState> } -fn exclusive(+user_data: T) -> Exclusive { +fn exclusive(+user_data: T) -> Exclusive { let data = ExData { lock: LittleLock(), mut failed: false, mut data: user_data }; Exclusive { x: unsafe { shared_mutable_state(data) } } } -impl Exclusive { +impl Exclusive { // Duplicate an exclusive ARC, as std::arc::clone. fn clone() -> Exclusive { Exclusive { x: unsafe { clone_shared_mutable_state(&self.x) } } @@ -353,7 +353,7 @@ impl Exclusive { } // FIXME(#2585) make this a by-move method on the exclusive -fn unwrap_exclusive(+arc: Exclusive) -> T { +fn unwrap_exclusive(+arc: Exclusive) -> T { let Exclusive { x: x } = arc; let inner = unsafe { unwrap_shared_mutable_state(x) }; let ExData { data: data, _ } = inner; diff --git a/src/libcore/util.rs b/src/libcore/util.rs index bb33bad1f85..e2128693ace 100644 --- a/src/libcore/util.rs +++ b/src/libcore/util.rs @@ -17,7 +17,7 @@ pure fn ignore(+_x: T) { } /// Sets `*ptr` to `new_value`, invokes `op()`, and then restores the /// original value of `*ptr`. #[inline(always)] -fn with( +fn with( ptr: &mut T, +new_value: T, op: &fn() -> R) -> R diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 4dedde8e177..2ae6a7b2780 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -199,7 +199,7 @@ pure fn from_fn(n_elts: uint, op: iter::InitOp) -> ~[T] { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value `t`. */ -pure fn from_elem(n_elts: uint, t: T) -> ~[T] { +pure fn from_elem(n_elts: uint, t: T) -> ~[T] { let mut v = ~[]; unchecked{reserve(v, n_elts)} let mut i: uint = 0u; @@ -211,7 +211,7 @@ pure fn from_elem(n_elts: uint, t: T) -> ~[T] { } /// Creates a new unique vector with the same contents as the slice -pure fn from_slice(t: &[T]) -> ~[T] { +pure fn from_slice(t: &[T]) -> ~[T] { from_fn(t.len(), |i| t[i]) } @@ -281,10 +281,10 @@ pure fn from_mut(+v: ~[mut T]) -> ~[T] { // Accessors /// Returns the first element of a vector -pure fn head(v: &[const T]) -> T { v[0] } +pure fn head(v: &[const T]) -> T { v[0] } /// Returns a vector containing all but the first element of a slice -pure fn tail(v: &[const T]) -> ~[T] { +pure fn tail(v: &[const T]) -> ~[T] { return slice(v, 1u, len(v)); } @@ -292,18 +292,18 @@ pure fn tail(v: &[const T]) -> ~[T] { * Returns a vector containing all but the first `n` \ * elements of a slice */ -pure fn tailn(v: &[const T], n: uint) -> ~[T] { +pure fn tailn(v: &[const T], n: uint) -> ~[T] { slice(v, n, len(v)) } /// Returns a vector containing all but the last element of a slice -pure fn init(v: &[const T]) -> ~[T] { +pure fn init(v: &[const T]) -> ~[T] { assert len(v) != 0u; slice(v, 0u, len(v) - 1u) } /// Returns the last element of the slice `v`, failing if the slice is empty. -pure fn last(v: &[const T]) -> T { +pure fn last(v: &[const T]) -> T { if len(v) == 0u { fail ~"last_unsafe: empty vector" } v[len(v) - 1u] } @@ -312,13 +312,13 @@ pure fn last(v: &[const T]) -> T { * Returns `Some(x)` where `x` is the last element of the slice `v`, * or `none` if the vector is empty. */ -pure fn last_opt(v: &[const T]) -> Option { +pure fn last_opt(v: &[const T]) -> Option { if len(v) == 0u { return None; } Some(v[len(v) - 1u]) } /// Returns a copy of the elements from [`start`..`end`) from `v`. -pure fn slice(v: &[const T], start: uint, end: uint) -> ~[T] { +pure fn slice(v: &[const T], start: uint, end: uint) -> ~[T] { assert (start <= end); assert (end <= len(v)); let mut result = ~[]; @@ -365,7 +365,7 @@ pure fn const_view(v: &[const T], start: uint, end: uint) -> &[const T] { } /// Split the vector `v` by applying each element against the predicate `f`. -fn split(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { +fn split(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { let ln = len(v); if (ln == 0u) { return ~[] } @@ -388,7 +388,7 @@ fn split(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { * Split the vector `v` by applying each element against the predicate `f` up * to `n` times. */ -fn splitn(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { +fn splitn(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { let ln = len(v); if (ln == 0u) { return ~[] } @@ -414,7 +414,7 @@ fn splitn(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { * Reverse split the vector `v` by applying each element against the predicate * `f`. */ -fn rsplit(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { +fn rsplit(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { let ln = len(v); if (ln == 0u) { return ~[] } @@ -438,7 +438,7 @@ fn rsplit(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { * Reverse split the vector `v` by applying each element against the predicate * `f` up to `n times. */ -fn rsplitn(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { +fn rsplitn(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { let ln = len(v); if (ln == 0u) { return ~[] } @@ -589,7 +589,7 @@ fn push_slow(&v: ~[const T], +initval: T) { } #[inline(always)] -fn push_all(&v: ~[const T], rhs: &[const T]) { +fn push_all(&v: ~[const T], rhs: &[const T]) { reserve(v, v.len() + rhs.len()); for uint::range(0u, rhs.len()) |i| { @@ -627,7 +627,7 @@ fn truncate(&v: ~[const T], newlen: uint) { // Appending #[inline(always)] -pure fn append(+lhs: ~[T], rhs: &[const T]) -> ~[T] { +pure fn append(+lhs: ~[T], rhs: &[const T]) -> ~[T] { let mut v <- lhs; unchecked { push_all(v, rhs); @@ -643,7 +643,7 @@ pure fn append_one(+lhs: ~[T], +x: T) -> ~[T] { } #[inline(always)] -pure fn append_mut(lhs: &[mut T], rhs: &[const T]) -> ~[mut T] { +pure fn append_mut(lhs: &[mut T], rhs: &[const T]) -> ~[mut T] { let mut v = ~[mut]; let mut i = 0u; while i < lhs.len() { @@ -671,7 +671,7 @@ pure fn append_mut(lhs: &[mut T], rhs: &[const T]) -> ~[mut T] { * * n - The number of elements to add * * initval - The value for the new elements */ -fn grow(&v: ~[const T], n: uint, initval: T) { +fn grow(&v: ~[const T], n: uint, initval: T) { reserve_at_least(v, len(v) + n); let mut i: uint = 0u; @@ -705,7 +705,7 @@ fn grow_fn(&v: ~[const T], n: uint, op: iter::InitOp) { * of the vector, expands the vector by replicating `initval` to fill the * intervening space. */ -fn grow_set(&v: ~[mut T], index: uint, initval: T, val: T) { +fn grow_set(&v: ~[mut T], index: uint, initval: T, val: T) { if index >= len(v) { grow(v, index - len(v) + 1u, initval); } v[index] = val; } @@ -747,7 +747,7 @@ pure fn flat_map(v: &[T], f: fn(T) -> ~[U]) -> ~[U] { } /// Apply a function to each pair of elements and return the results -pure fn map2(v0: &[T], v1: &[U], +pure fn map2(v0: &[T], v1: &[U], f: fn(T, U) -> V) -> ~[V] { let v0_len = len(v0); if v0_len != len(v1) { fail; } @@ -766,7 +766,7 @@ pure fn map2(v0: &[T], v1: &[U], * If function `f` returns `none` then that element is excluded from * the resulting vector. */ -pure fn filter_map(v: &[T], f: fn(T) -> Option) +pure fn filter_map(v: &[T], f: fn(T) -> Option) -> ~[U] { let mut result = ~[]; for each(v) |elem| { @@ -785,7 +785,7 @@ pure fn filter_map(v: &[T], f: fn(T) -> Option) * Apply function `f` to each element of `v` and return a vector containing * only those elements for which `f` returned true. */ -pure fn filter(v: &[T], f: fn(T) -> bool) -> ~[T] { +pure fn filter(v: &[T], f: fn(T) -> bool) -> ~[T] { let mut result = ~[]; for each(v) |elem| { if f(elem) { unsafe { push(result, elem); } } @@ -798,14 +798,14 @@ pure fn filter(v: &[T], f: fn(T) -> bool) -> ~[T] { * * Flattens a vector of vectors of T into a single vector of T. */ -pure fn concat(v: &[~[T]]) -> ~[T] { +pure fn concat(v: &[~[T]]) -> ~[T] { let mut r = ~[]; for each(v) |inner| { unsafe { push_all(r, inner); } } return r; } /// Concatenate a vector of vectors, placing a given separator between each -pure fn connect(v: &[~[T]], sep: T) -> ~[T] { +pure fn connect(v: &[~[T]], sep: T) -> ~[T] { let mut r: ~[T] = ~[]; let mut first = true; for each(v) |inner| { @@ -816,7 +816,7 @@ pure fn connect(v: &[~[T]], sep: T) -> ~[T] { } /// Reduce a vector from left to right -pure fn foldl(z: T, v: &[U], p: fn(T, U) -> T) -> T { +pure fn foldl(z: T, v: &[U], p: fn(T, U) -> T) -> T { let mut accum = z; do iter(v) |elt| { accum = p(accum, elt); @@ -825,7 +825,7 @@ pure fn foldl(z: T, v: &[U], p: fn(T, U) -> T) -> T { } /// Reduce a vector from right to left -pure fn foldr(v: &[T], z: U, p: fn(T, U) -> U) -> U { +pure fn foldr(v: &[T], z: U, p: fn(T, U) -> U) -> U { let mut accum = z; do riter(v) |elt| { accum = p(elt, accum); @@ -914,7 +914,7 @@ pure fn count(v: &[T], x: T) -> uint { * When function `f` returns true then an option containing the element * is returned. If `f` matches no elements then none is returned. */ -pure fn find(v: &[T], f: fn(T) -> bool) -> Option { +pure fn find(v: &[T], f: fn(T) -> bool) -> Option { find_between(v, 0u, len(v), f) } @@ -925,7 +925,7 @@ pure fn find(v: &[T], f: fn(T) -> bool) -> Option { * [`start`, `end`). When function `f` returns true then an option containing * the element is returned. If `f` matches no elements then none is returned. */ -pure fn find_between(v: &[T], start: uint, end: uint, +pure fn find_between(v: &[T], start: uint, end: uint, f: fn(T) -> bool) -> Option { option::map(position_between(v, start, end, f), |i| v[i]) } @@ -937,7 +937,7 @@ pure fn find_between(v: &[T], start: uint, end: uint, * `f` returns true then an option containing the element is returned. If `f` * matches no elements then none is returned. */ -pure fn rfind(v: &[T], f: fn(T) -> bool) -> Option { +pure fn rfind(v: &[T], f: fn(T) -> bool) -> Option { rfind_between(v, 0u, len(v), f) } @@ -948,7 +948,7 @@ pure fn rfind(v: &[T], f: fn(T) -> bool) -> Option { * [`start`, `end`). When function `f` returns true then an option containing * the element is returned. If `f` matches no elements then none is returned. */ -pure fn rfind_between(v: &[T], start: uint, end: uint, +pure fn rfind_between(v: &[T], start: uint, end: uint, f: fn(T) -> bool) -> Option { option::map(rposition_between(v, start, end, f), |i| v[i]) } @@ -1028,7 +1028,7 @@ pure fn rposition_between(v: &[T], start: uint, end: uint, /** * Convert a vector of pairs into a pair of vectors, by reference. As unzip(). */ -pure fn unzip_slice(v: &[(T, U)]) -> (~[T], ~[U]) { +pure fn unzip_slice(v: &[(T, U)]) -> (~[T], ~[U]) { let mut as = ~[], bs = ~[]; for each(v) |p| { let (a, b) = p; @@ -1063,7 +1063,7 @@ pure fn unzip(+v: ~[(T, U)]) -> (~[T], ~[U]) { /** * Convert two vectors to a vector of pairs, by reference. As zip(). */ -pure fn zip_slice(v: &[const T], u: &[const U]) +pure fn zip_slice(v: &[const T], u: &[const U]) -> ~[(T, U)] { let mut zipped = ~[]; let sz = len(v); @@ -1113,7 +1113,7 @@ fn reverse(v: ~[mut T]) { /// Returns a vector with the order of elements reversed -pure fn reversed(v: &[const T]) -> ~[T] { +pure fn reversed(v: &[const T]) -> ~[T] { let mut rs: ~[T] = ~[]; let mut i = len::(v); if i == 0u { return rs; } else { i -= 1u; } @@ -1317,7 +1317,7 @@ pure fn riteri(v: &[T], f: fn(uint, T)) { * The total number of permutations produced is `len(v)!`. If `v` contains * repeated elements, then some permutations are repeated. */ -pure fn permute(v: &[const T], put: fn(~[T])) { +pure fn permute(v: &[const T], put: fn(~[T])) { let ln = len(v); if ln == 0u { put(~[]); @@ -1337,7 +1337,7 @@ pure fn permute(v: &[const T], put: fn(~[T])) { } } -pure fn windowed(nn: uint, xx: &[TT]) -> ~[~[TT]] { +pure fn windowed(nn: uint, xx: &[TT]) -> ~[~[TT]] { let mut ww = ~[]; assert 1u <= nn; vec::iteri (xx, |ii, _x| { @@ -1480,14 +1480,14 @@ impl @[T]: Ord { } #[cfg(notest)] -impl ~[T]: Add<&[const T],~[T]> { +impl ~[T]: Add<&[const T],~[T]> { #[inline(always)] pure fn add(rhs: &[const T]) -> ~[T] { append(copy self, rhs) } } -impl ~[mut T]: Add<&[const T],~[mut T]> { +impl ~[mut T]: Add<&[const T],~[mut T]> { #[inline(always)] pure fn add(rhs: &[const T]) -> ~[mut T] { append_mut(self, rhs) @@ -1522,7 +1522,7 @@ trait CopyableVector { } /// Extension methods for vectors -impl &[const T]: CopyableVector { +impl &[const T]: CopyableVector { /// Returns the first element of a vector #[inline] pure fn head() -> T { head(self) } @@ -1541,7 +1541,7 @@ impl &[const T]: CopyableVector { } trait ImmutableVector { - pure fn foldr(z: U, p: fn(T, U) -> U) -> U; + pure fn foldr(z: U, p: fn(T, U) -> U) -> U; pure fn iter(f: fn(T)); pure fn iteri(f: fn(uint, T)); pure fn riter(f: fn(T)); @@ -1551,7 +1551,7 @@ trait ImmutableVector { fn map_r(f: fn(x: &T) -> U) -> ~[U]; pure fn alli(f: fn(uint, T) -> bool) -> bool; pure fn flat_map(f: fn(T) -> ~[U]) -> ~[U]; - pure fn filter_map(f: fn(T) -> Option) -> ~[U]; + pure fn filter_map(f: fn(T) -> Option) -> ~[U]; } trait ImmutableEqVector { @@ -1565,7 +1565,7 @@ trait ImmutableEqVector { impl &[T]: ImmutableVector { /// Reduce a vector from right to left #[inline] - pure fn foldr(z: U, p: fn(T, U) -> U) -> U { foldr(self, z, p) } + pure fn foldr(z: U, p: fn(T, U) -> U) -> U { foldr(self, z, p) } /** * Iterates over a vector * @@ -1641,7 +1641,7 @@ impl &[T]: ImmutableVector { * the resulting vector. */ #[inline] - pure fn filter_map(f: fn(T) -> Option) -> ~[U] { + pure fn filter_map(f: fn(T) -> Option) -> ~[U] { filter_map(self, f) } } @@ -1679,7 +1679,7 @@ trait ImmutableCopyableVector { } /// Extension methods for vectors -impl &[T]: ImmutableCopyableVector { +impl &[T]: ImmutableCopyableVector { /** * Construct a new vector from the elements of a vector for which some * predicate holds. @@ -1785,7 +1785,7 @@ mod unsafe { * Unchecked vector indexing. */ #[inline(always)] - unsafe fn get(v: &[const T], i: uint) -> T { + unsafe fn get(v: &[const T], i: uint) -> T { as_buf(v, |p, _len| *ptr::offset(p, i)) } @@ -1938,7 +1938,7 @@ impl &[A]: iter::EqIter { } } -impl &[A]: iter::CopyableIter { +impl &[A]: iter::CopyableIter { pure fn filter_to_vec(pred: fn(A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } @@ -1955,7 +1955,7 @@ impl &[A]: iter::CopyableIter { pure fn find(p: fn(A) -> bool) -> Option { iter::find(self, p) } } -impl &[A]: iter::CopyableOrderedIter { +impl &[A]: iter::CopyableOrderedIter { pure fn min() -> A { iter::min(self) } pure fn max() -> A { iter::max(self) } } diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index b5af4af06c3..fb9a7e7e489 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -69,10 +69,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. -fn ARC(+data: T) -> ARC { +fn ARC(+data: T) -> ARC { ARC { x: unsafe { shared_mutable_state(data) } } } @@ -80,7 +80,7 @@ fn ARC(+data: T) -> ARC { * Access the underlying data in an atomically reference counted * wrapper. */ -fn get(rc: &a/ARC) -> &a/T { +fn get(rc: &a/ARC) -> &a/T { unsafe { get_shared_immutable_state(&rc.x) } } @@ -91,7 +91,7 @@ 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. */ -fn clone(rc: &ARC) -> ARC { +fn clone(rc: &ARC) -> ARC { ARC { x: unsafe { clone_shared_mutable_state(&rc.x) } } } @@ -104,7 +104,7 @@ 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 } = rc; unsafe { unwrap_shared_mutable_state(x) } } @@ -114,19 +114,19 @@ fn unwrap(+rc: ARC) -> T { ****************************************************************************/ #[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. -fn MutexARC(+user_data: T) -> MutexARC { +fn MutexARC(+user_data: T) -> MutexARC { mutex_arc_with_condvars(user_data, 1) } /** * Create a mutex-protected ARC with the supplied data and a specified number * of condvars (as sync::mutex_with_condvars). */ -fn mutex_arc_with_condvars(+user_data: T, +fn mutex_arc_with_condvars(+user_data: T, num_condvars: uint) -> MutexARC { let data = MutexARCInner { lock: mutex_with_condvars(num_condvars), @@ -134,7 +134,7 @@ fn mutex_arc_with_condvars(+user_data: T, MutexARC { x: unsafe { shared_mutable_state(data) } } } -impl &MutexARC { +impl &MutexARC { /// Duplicate a mutex-protected ARC, as arc::clone. fn clone() -> MutexARC { // NB: Cloning the underlying mutex is not necessary. Its reference @@ -197,7 +197,7 @@ impl &MutexARC { * Will additionally fail if another task has failed while accessing the arc. */ // FIXME(#2585) make this a by-move method on the arc -fn unwrap_mutex_arc(+arc: MutexARC) -> T { +fn unwrap_mutex_arc(+arc: MutexARC) -> T { let MutexARC { x: x } = arc; let inner = unsafe { unwrap_shared_mutable_state(x) }; let MutexARCInner { failed: failed, data: data, _ } = inner; @@ -240,27 +240,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. -fn RWARC(+user_data: T) -> RWARC { +fn RWARC(+user_data: T) -> RWARC { rw_arc_with_condvars(user_data, 1) } /** * Create a reader/writer ARC with the supplied data and a specified number * of condvars (as sync::rwlock_with_condvars). */ -fn rw_arc_with_condvars(+user_data: T, +fn rw_arc_with_condvars(+user_data: T, num_condvars: uint) -> RWARC { let data = RWARCInner { lock: rwlock_with_condvars(num_condvars), @@ -268,7 +268,7 @@ fn rw_arc_with_condvars(+user_data: T, RWARC { x: unsafe { shared_mutable_state(data) }, cant_nest: () } } -impl &RWARC { +impl &RWARC { /// Duplicate a rwlock-protected ARC, as arc::clone. fn clone() -> RWARC { RWARC { x: unsafe { clone_shared_mutable_state(&self.x) }, @@ -375,7 +375,7 @@ impl &RWARC { * in write mode. */ // FIXME(#2585) make this a by-move method on the arc -fn unwrap_rw_arc(+arc: RWARC) -> T { +fn unwrap_rw_arc(+arc: RWARC) -> T { let RWARC { x: x, _ } = arc; let inner = unsafe { unwrap_shared_mutable_state(x) }; let RWARCInner { failed: failed, data: data, _ } = inner; @@ -389,19 +389,19 @@ 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 { unsafe::transmute_immut(&mut state.lock) } } // FIXME (#3154) ice with struct/& prevents these from being structs. /// The "write permission" token used for RWARC.write_downgrade(). -enum RWWriteMode = +enum RWWriteMode = (&mut T, sync::RWlockWriteMode, PoisonOnFail); /// The "read permission" token used for RWARC.write_downgrade(). -enum RWReadMode = (&T, sync::RWlockReadMode); +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 { @@ -427,7 +427,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/c_vec.rs b/src/libstd/c_vec.rs index 5b0e9b0ffdd..53964fb0ddb 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -107,7 +107,7 @@ unsafe fn c_vec_with_dtor(base: *mut T, len: uint, dtor: fn@()) * * Fails if `ofs` is greater or equal to the length of the vector */ -fn get(t: CVec, ofs: uint) -> T { +fn get(t: CVec, ofs: uint) -> T { assert ofs < len(t); return unsafe { *ptr::mut_offset((*t).base, ofs) }; } @@ -117,7 +117,7 @@ fn get(t: CVec, ofs: uint) -> T { * * Fails if `ofs` is greater or equal to the length of the vector */ -fn set(t: CVec, ofs: uint, v: T) { +fn set(t: CVec, ofs: uint, v: T) { assert ofs < len(t); unsafe { *ptr::mut_offset((*t).base, ofs) = v }; } diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index d286b496923..d78e11452bc 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -13,7 +13,7 @@ use pipes::{Channel, Recv, Chan, Port, Selectable}; export DuplexStream; /// An extension of `pipes::stream` that allows both sending and receiving. -struct DuplexStream : Channel, Recv, Selectable { +struct DuplexStream : Channel, Recv, Selectable { priv chan: Chan, priv port: Port , @@ -43,7 +43,7 @@ struct DuplexStream : Channel, Recv, Selectable { } /// Creates a bidirectional stream. -fn DuplexStream() +fn DuplexStream() -> (DuplexStream, DuplexStream) { let (c2, p1) = pipes::stream(); diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 6cd229bc689..f9def4b2332 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -16,7 +16,7 @@ trait Deque { // FIXME (#2343) eventually, a proper datatype plus an exported impl would // be preferrable. -fn create() -> Deque { +fn create() -> Deque { type Cell = Option; let initial_capacity: uint = 32u; // 2^5 @@ -24,7 +24,7 @@ fn create() -> Deque { * Grow is only called on full elts, so nelts is also len(elts), unlike * elsewhere. */ - fn grow(nelts: uint, lo: uint, -elts: ~[mut Cell]) -> + fn grow(nelts: uint, lo: uint, -elts: ~[mut Cell]) -> ~[mut Cell] { assert (nelts == vec::len(elts)); let mut rv = ~[mut]; @@ -40,7 +40,7 @@ fn create() -> Deque { return rv; } - fn get(elts: DVec>, i: uint) -> T { + fn get(elts: DVec>, i: uint) -> T { match elts.get_elt(i) { Some(t) => t, _ => fail } } @@ -49,7 +49,7 @@ fn create() -> Deque { mut hi: uint, elts: DVec>}; - impl Repr: Deque { + impl Repr: Deque { fn size() -> uint { return self.nelts; } fn add_front(t: T) { let oldlo: uint = self.lo; @@ -193,7 +193,7 @@ mod tests { type EqFn = fn@(T, T) -> bool; - fn test_parameterized( + fn test_parameterized( e: EqFn, a: T, b: T, c: T, d: T) { let deq: deque::Deque = deque::create::(); diff --git a/src/libstd/fun_treemap.rs b/src/libstd/fun_treemap.rs index e7a92e5d8cc..3761b511402 100644 --- a/src/libstd/fun_treemap.rs +++ b/src/libstd/fun_treemap.rs @@ -33,7 +33,7 @@ enum TreeNode { fn init() -> Treemap { @Empty } /// Insert a value into the map -fn insert(m: Treemap, +k: K, +v: V) +fn insert(m: Treemap, +k: K, +v: V) -> Treemap { @match m { @Empty => Node(@k, @v, @Empty, @Empty), @@ -48,7 +48,7 @@ fn insert(m: Treemap, +k: K, +v: V) } /// Find a value based on the key -fn find(m: Treemap, +k: K) -> Option { +fn find(m: Treemap, +k: K) -> Option { match *m { Empty => None, Node(@kk, @v, left, right) => { @@ -60,7 +60,7 @@ fn find(m: Treemap, +k: K) -> Option { } /// Visit all pairs in the map in order. -fn traverse(m: Treemap, f: fn(K, V)) { +fn traverse(m: Treemap, f: fn(K, V)) { match *m { Empty => (), /* diff --git a/src/libstd/json.rs b/src/libstd/json.rs index f2207f2a913..1adb41e8d10 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -720,7 +720,7 @@ impl ~[A]: ToJson { fn to_json() -> Json { List(@self.map(|elt| elt.to_json())) } } -impl hashmap<~str, A>: ToJson { +impl hashmap<~str, A>: ToJson { fn to_json() -> Json { let d = map::str_hash(); for self.each() |key, value| { diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 71b820b4022..96d4e32d02b 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -13,7 +13,7 @@ enum List { } /// Cregate a list from a vector -fn from_vec(v: &[T]) -> @List { +fn from_vec(v: &[T]) -> @List { vec::foldr(v, @Nil::, |h, t| @Cons(h, t)) } @@ -30,7 +30,7 @@ fn from_vec(v: &[T]) -> @List { * * z - The initial value * * f - The function to apply */ -fn foldl(+z: T, ls: @List, f: fn((&T), (&U)) -> T) -> T { +fn foldl(+z: T, ls: @List, f: fn((&T), (&U)) -> T) -> T { let mut accum: T = z; do iter(ls) |elt| { accum = f(&accum, &elt);} accum @@ -43,7 +43,7 @@ fn foldl(+z: T, ls: @List, f: fn((&T), (&U)) -> T) -> T { * When function `f` returns true then an option containing the element * is returned. If `f` matches no elements then none is returned. */ -fn find(ls: @List, f: fn((&T)) -> bool) -> Option { +fn find(ls: @List, f: fn((&T)) -> bool) -> Option { let mut ls = ls; loop { ls = match *ls { @@ -57,7 +57,7 @@ fn find(ls: @List, f: fn((&T)) -> bool) -> Option { } /// Returns true if a list contains an element with the given value -fn has(ls: @List, +elt: T) -> bool { +fn has(ls: @List, +elt: T) -> bool { for each(ls) |e| { if e == elt { return true; } } @@ -65,7 +65,7 @@ fn has(ls: @List, +elt: T) -> bool { } /// Returns true if the list is empty -pure fn is_empty(ls: @List) -> bool { +pure fn is_empty(ls: @List) -> bool { match *ls { Nil => true, _ => false @@ -73,7 +73,7 @@ pure fn is_empty(ls: @List) -> bool { } /// Returns true if the list is not empty -pure fn is_not_empty(ls: @List) -> bool { +pure fn is_not_empty(ls: @List) -> bool { return !is_empty(ls); } @@ -85,7 +85,7 @@ fn len(ls: @List) -> uint { } /// Returns all but the first element of a list -pure fn tail(ls: @List) -> @List { +pure fn tail(ls: @List) -> @List { match *ls { Cons(_, tl) => return tl, Nil => fail ~"list empty" @@ -93,7 +93,7 @@ pure fn tail(ls: @List) -> @List { } /// Returns the first element of a list -pure fn head(ls: @List) -> T { +pure fn head(ls: @List) -> T { match *ls { Cons(hd, _) => hd, // makes me sad @@ -102,7 +102,7 @@ pure fn head(ls: @List) -> T { } /// Appends one list to another -pure fn append(l: @List, m: @List) -> @List { +pure fn append(l: @List, m: @List) -> @List { match *l { Nil => return m, Cons(x, xs) => { @@ -115,7 +115,7 @@ pure fn append(l: @List, m: @List) -> @List { /* /// Push one element into the front of a list, returning a new list /// THIS VERSION DOESN'T ACTUALLY WORK -pure fn push(ll: &mut @list, +vv: T) { +pure fn push(ll: &mut @list, +vv: T) { ll = &mut @cons(vv, *ll) } */ diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 603cff98721..5436ea1a803 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -24,7 +24,7 @@ type set = hashmap; type hashmap = chained::t; -trait map { +trait map { /// Return the number of elements in the map pure fn size() -> uint; @@ -123,7 +123,7 @@ mod chained { found_after(@entry, @entry) } - priv impl t { + priv impl t { pure fn search_rem(k: &K, h: uint, idx: uint, e_root: @entry) -> search_result { let mut e0 = e_root; @@ -207,7 +207,7 @@ mod chained { } } - impl t: map { + impl t: map { pure fn size() -> uint { self.count } fn contains_key(+k: K) -> bool { @@ -330,7 +330,7 @@ mod chained { } } - impl t: ToStr { + impl t: ToStr { fn to_writer(wr: io::Writer) { if self.count == 0u { wr.write_str(~"{}"); @@ -356,7 +356,7 @@ mod chained { } } - impl t: ops::Index { + impl t: ops::Index { pure fn index(&&k: K) -> V { unchecked { self.get(k) @@ -368,7 +368,7 @@ mod chained { vec::to_mut(vec::from_elem(nchains, None)) } - fn mk() -> t { + fn mk() -> t { let slf: t = @hashmap_ {count: 0u, chains: chains(initial_capacity)}; slf @@ -380,48 +380,48 @@ Function: hashmap Construct a hashmap. */ -fn hashmap() +fn hashmap() -> hashmap { chained::mk() } /// Construct a hashmap for string-slice keys -fn str_slice_hash() -> hashmap<&str, V> { +fn str_slice_hash() -> hashmap<&str, V> { return hashmap(); } /// Construct a hashmap for string keys -fn str_hash() -> hashmap<~str, V> { +fn str_hash() -> hashmap<~str, V> { return hashmap(); } /// Construct a hashmap for boxed string keys -fn box_str_hash() -> hashmap<@~str, V> { +fn box_str_hash() -> hashmap<@~str, V> { hashmap() } /// Construct a hashmap for byte string keys -fn bytes_hash() -> hashmap<~[u8], V> { +fn bytes_hash() -> hashmap<~[u8], V> { return hashmap(); } /// Construct a hashmap for int keys -fn int_hash() -> hashmap { +fn int_hash() -> hashmap { return hashmap(); } /// Construct a hashmap for uint keys -fn uint_hash() -> hashmap { +fn uint_hash() -> hashmap { return hashmap(); } /// Convenience function for adding keys to a hashmap with nil type keys -fn set_add(set: set, +key: K) -> bool { +fn set_add(set: set, +key: K) -> bool { set.insert(key, ()) } /// Convert a set into a vector. -fn vec_from_set(s: set) -> ~[T] { +fn vec_from_set(s: set) -> ~[T] { let mut v = ~[]; vec::reserve(v, s.size()); do s.each_key() |k| { @@ -432,7 +432,7 @@ fn vec_from_set(s: set) -> ~[T] { } /// Construct a hashmap from a vector -fn hash_from_vec( +fn hash_from_vec( items: &[(K, V)]) -> hashmap { let map = hashmap(); do vec::iter(items) |item| { @@ -443,27 +443,27 @@ fn hash_from_vec( } /// Construct a hashmap from a vector with string keys -fn hash_from_strs(items: &[(~str, V)]) -> hashmap<~str, V> { +fn hash_from_strs(items: &[(~str, V)]) -> hashmap<~str, V> { hash_from_vec(items) } /// Construct a hashmap from a vector with byte keys -fn hash_from_bytes(items: &[(~[u8], V)]) -> hashmap<~[u8], V> { +fn hash_from_bytes(items: &[(~[u8], V)]) -> hashmap<~[u8], V> { hash_from_vec(items) } /// Construct a hashmap from a vector with int keys -fn hash_from_ints(items: &[(int, V)]) -> hashmap { +fn hash_from_ints(items: &[(int, V)]) -> hashmap { hash_from_vec(items) } /// Construct a hashmap from a vector with uint keys -fn hash_from_uints(items: &[(uint, V)]) -> hashmap { +fn hash_from_uints(items: &[(uint, V)]) -> hashmap { hash_from_vec(items) } // XXX Transitional -impl Managed>: +impl Managed>: map { pure fn size() -> uint { unchecked { diff --git a/src/libstd/par.rs b/src/libstd/par.rs index 1735765a474..d6e498c0a23 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -18,7 +18,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] { @@ -73,7 +73,7 @@ fn map_slices( } /// A parallel version of map. -fn map(xs: ~[A], f: fn~(A) -> B) -> ~[B] { +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)) @@ -82,7 +82,7 @@ fn map(xs: ~[A], f: fn~(A) -> B) -> ~[B] { } /// A parallel version of mapi. -fn mapi(xs: ~[A], +fn mapi(xs: ~[A], f: fn~(uint, A) -> B) -> ~[B] { let slices = map_slices(xs, || { fn~(base: uint, slice : &[A], copy f) -> ~[B] { @@ -103,7 +103,7 @@ 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. */ -fn mapi_factory( +fn mapi_factory( xs: &[A], f: fn() -> fn~(uint, A) -> B) -> ~[B] { let slices = map_slices(xs, || { let f = f(); @@ -120,7 +120,7 @@ fn mapi_factory( } /// Returns true if the function holds for all elements in the vector. -fn alli(xs: ~[A], f: fn~(uint, A) -> bool) -> bool { +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| { @@ -131,7 +131,7 @@ fn alli(xs: ~[A], f: fn~(uint, A) -> bool) -> bool { } /// Returns true if the function holds for any elements in the vector. -fn any(xs: ~[A], f: fn~(A) -> bool) -> bool { +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/serialization.rs b/src/libstd/serialization.rs index 411d18b72fc..743e2fc2bf1 100644 --- a/src/libstd/serialization.rs +++ b/src/libstd/serialization.rs @@ -93,7 +93,7 @@ fn emit_from_vec(s: S, v: ~[T], f: fn(T)) { } } -fn read_to_vec(d: D, f: fn() -> T) -> ~[T] { +fn read_to_vec(d: D, f: fn() -> T) -> ~[T] { do d.read_vec |len| { do vec::from_fn(len) |i| { d.read_vec_elt(i, || f()) @@ -112,11 +112,11 @@ impl S: serializer_helpers { } trait deserializer_helpers { - fn read_to_vec(f: fn() -> T) -> ~[T]; + fn read_to_vec(f: fn() -> T) -> ~[T]; } impl D: deserializer_helpers { - fn read_to_vec(f: fn() -> T) -> ~[T] { + fn read_to_vec(f: fn() -> T) -> ~[T] { read_to_vec(self, f) } } @@ -256,7 +256,7 @@ fn serialize_Option(s: S, v: Option, st: fn(T)) { } } -fn deserialize_Option(d: D, st: fn() -> T) +fn deserialize_Option(d: D, st: fn() -> T) -> Option { do d.read_enum(~"option") { do d.read_enum_variant |i| { diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 25cb53f7eaa..a65d41a2d32 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -12,14 +12,14 @@ use map::map; // FIXME (#2347): Should not be @; there's a bug somewhere in rustc that // requires this to be. -type SmallIntMap_ = {v: DVec>}; +type SmallIntMap_ = {v: DVec>}; -enum SmallIntMap { +enum SmallIntMap { SmallIntMap_(@SmallIntMap_) } /// Create a smallintmap -fn mk() -> SmallIntMap { +fn mk() -> SmallIntMap { let v = DVec(); return SmallIntMap_(@{v: v}); } @@ -29,7 +29,7 @@ fn mk() -> SmallIntMap { * the specified key then the original value is replaced. */ #[inline(always)] -fn insert(self: SmallIntMap, key: uint, +val: T) { +fn insert(self: SmallIntMap, key: uint, +val: T) { //io::println(fmt!("%?", key)); self.v.grow_set_elt(key, None, Some(val)); } @@ -38,7 +38,7 @@ fn insert(self: SmallIntMap, key: uint, +val: T) { * Get the value for the specified key. If the key does not exist * in the map then returns none */ -pure fn find(self: SmallIntMap, key: uint) -> Option { +pure fn find(self: SmallIntMap, key: uint) -> Option { if key < self.v.len() { return self.v.get_elt(key); } return None::; } @@ -50,7 +50,7 @@ pure fn find(self: SmallIntMap, key: uint) -> Option { * * If the key does not exist in the map */ -pure fn get(self: SmallIntMap, key: uint) -> T { +pure fn get(self: SmallIntMap, key: uint) -> T { match find(self, key) { None => { error!("smallintmap::get(): key not present"); @@ -61,12 +61,12 @@ pure fn get(self: SmallIntMap, key: uint) -> T { } /// Returns true if the map contains a value for the specified key -fn contains_key(self: SmallIntMap, key: uint) -> bool { +fn contains_key(self: SmallIntMap, key: uint) -> bool { return !option::is_none(find(self, key)); } /// Implements the map::map interface for smallintmap -impl SmallIntMap: map::map { +impl SmallIntMap: map::map { pure fn size() -> uint { let mut sz = 0u; for self.v.each |item| { @@ -137,7 +137,7 @@ impl SmallIntMap: map::map { } } -impl SmallIntMap: ops::Index { +impl SmallIntMap: ops::Index { pure fn index(&&key: uint) -> V { unchecked { get(self, key) @@ -146,6 +146,6 @@ impl SmallIntMap: ops::Index { } /// Cast the given smallintmap to a map::map -fn as_map(s: SmallIntMap) -> map::map { +fn as_map(s: SmallIntMap) -> map::map { s as map::map:: } diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 64ea19d35f9..488ae16c751 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -19,12 +19,12 @@ type Le = pure fn(v1: &T, v2: &T) -> bool; * Has worst case O(n log n) performance, best case O(n), but * is not space efficient. This is a stable sort. */ -fn merge_sort(le: Le, v: &[const T]) -> ~[T] { +fn merge_sort(le: Le, v: &[const T]) -> ~[T] { type Slice = (uint, uint); return merge_sort_(le, v, (0u, len(v))); - fn merge_sort_(le: Le, v: &[const T], slice: Slice) + fn merge_sort_(le: Le, v: &[const T], slice: Slice) -> ~[T] { let begin = slice.first(); let end = slice.second(); @@ -39,7 +39,7 @@ fn merge_sort(le: Le, v: &[const T]) -> ~[T] { return merge(le, merge_sort_(le, v, a), merge_sort_(le, v, b)); } - fn merge(le: Le, a: &[T], b: &[T]) -> ~[T] { + fn merge(le: Le, a: &[T], b: &[T]) -> ~[T] { let mut rs = ~[]; vec::reserve(rs, len(a) + len(b)); let a_len = len(a); @@ -58,7 +58,7 @@ fn merge_sort(le: Le, v: &[const T]) -> ~[T] { } } -fn part(compare_func: Le, arr: &[mut T], left: uint, +fn part(compare_func: Le, arr: &[mut T], left: uint, right: uint, pivot: uint) -> uint { let pivot_value = arr[pivot]; arr[pivot] <-> arr[right]; @@ -75,7 +75,7 @@ fn part(compare_func: Le, arr: &[mut T], left: uint, return storage_index; } -fn qsort(compare_func: Le, arr: &[mut T], left: uint, +fn qsort(compare_func: Le, arr: &[mut T], left: uint, right: uint) { if right > left { let pivot = (left + right) / 2u; @@ -94,12 +94,12 @@ fn qsort(compare_func: Le, arr: &[mut T], left: uint, * Has worst case O(n^2) performance, average case O(n log n). * This is an unstable sort. */ -fn quick_sort(compare_func: Le, arr: &[mut T]) { +fn quick_sort(compare_func: Le, arr: &[mut T]) { if len::(arr) == 0u { return; } qsort::(compare_func, arr, 0u, len::(arr) - 1u); } -fn qsort3(arr: &[mut T], left: int, right: int) { +fn qsort3(arr: &[mut T], left: int, right: int) { if right <= left { return; } let v: T = arr[right]; let mut i: int = left - 1; @@ -156,7 +156,7 @@ fn qsort3(arr: &[mut T], left: int, right: int) { * * This is an unstable sort. */ -fn quick_sort3(arr: &[mut T]) { +fn quick_sort3(arr: &[mut T]) { if arr.len() <= 1 { return; } qsort3(arr, 0, (arr.len() - 1) as int); } @@ -165,7 +165,7 @@ trait Sort { fn qsort(self); } -impl &[mut T] : Sort { +impl &[mut T] : Sort { fn qsort(self) { quick_sort3(self); } } diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 45ab8d4c427..986a6e05225 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -70,10 +70,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: q })) } @@ -88,7 +88,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 { diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index 25bc5e58c4e..bda489c3ba7 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -26,7 +26,7 @@ export delayed_send, sleep, recv_timeout; * * ch - a channel of type T to send a `val` on * * val - a value of type T to send over the provided `ch` */ -fn delayed_send(iotask: IoTask, +fn delayed_send(iotask: IoTask, msecs: uint, ch: comm::Chan, +val: T) { unsafe { let timer_done_po = core::comm::Port::<()>(); @@ -102,7 +102,7 @@ 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. */ -fn recv_timeout(iotask: IoTask, +fn recv_timeout(iotask: IoTask, msecs: uint, wait_po: comm::Port) -> Option { let timeout_po = comm::Port::<()>(); diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 9d6c8dade61..a43821a0d37 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -32,7 +32,7 @@ enum TreeNode = { fn TreeMap() -> TreeMap { @mut None } /// Insert a value into the map -fn insert(m: &mut TreeEdge, +k: K, +v: V) { +fn insert(m: &mut TreeEdge, +k: K, +v: V) { match copy *m { None => { *m = Some(@TreeNode({key: k, @@ -54,7 +54,7 @@ fn insert(m: &mut TreeEdge, +k: K, +v: V) { } /// Find a value based on the key -fn find(m: &const TreeEdge, +k: K) +fn find(m: &const TreeEdge, +k: K) -> Option { match copy *m { None => None, @@ -73,7 +73,7 @@ fn find(m: &const TreeEdge, +k: K) } /// Visit all pairs in the map in order. -fn traverse(m: &const TreeEdge, f: fn(K, V)) { +fn traverse(m: &const TreeEdge, f: fn(K, V)) { match copy *m { None => (), Some(node) => { diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 97dcb922c43..474f0ede109 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -259,7 +259,7 @@ impl def_id : core::to_bytes::IterBytes { } } -fn new_def_hash() -> std::map::hashmap { +fn new_def_hash() -> std::map::hashmap { return std::map::hashmap::(); } diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 99296f72eb7..66553162b25 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -271,7 +271,7 @@ fn print_macro_backtrace(cm: codemap::codemap, sp: span) { } } -fn expect(diag: span_handler, +fn expect(diag: span_handler, opt: Option, msg: fn() -> ~str) -> T { match opt { Some(t) => t, diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs index 32db095a1df..bb5af8402df 100644 --- a/src/libsyntax/ext/simplext.rs +++ b/src/libsyntax/ext/simplext.rs @@ -88,7 +88,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: ~[@expr]) -> } } -fn option_flatten_map(f: fn@(T) -> Option, v: ~[T]) -> +fn option_flatten_map(f: fn@(T) -> Option, v: ~[T]) -> Option<~[U]> { let mut res = ~[]; for v.each |elem| { diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 6fc05e1f5bd..478288ba4cd 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -41,21 +41,21 @@ trait parser_common { fn check_restricted_keywords(); fn check_restricted_keywords_(w: ~str); fn expect_gt(); - fn parse_seq_to_before_gt(sep: Option, + fn parse_seq_to_before_gt(sep: Option, f: fn(parser) -> T) -> ~[T]; - fn parse_seq_to_gt(sep: Option, + fn parse_seq_to_gt(sep: Option, f: fn(parser) -> T) -> ~[T]; - fn parse_seq_lt_gt(sep: Option, + fn parse_seq_lt_gt(sep: Option, f: fn(parser) -> T) -> spanned<~[T]>; - fn parse_seq_to_end(ket: token::token, sep: seq_sep, + fn parse_seq_to_end(ket: token::token, sep: seq_sep, f: fn(parser) -> T) -> ~[T]; - fn parse_seq_to_before_end(ket: token::token, sep: seq_sep, + fn parse_seq_to_before_end(ket: token::token, sep: seq_sep, f: fn(parser) -> T) -> ~[T]; - fn parse_unspanned_seq(bra: token::token, + fn parse_unspanned_seq(bra: token::token, ket: token::token, sep: seq_sep, f: fn(parser) -> T) -> ~[T]; - fn parse_seq(bra: token::token, ket: token::token, sep: seq_sep, + fn parse_seq(bra: token::token, ket: token::token, sep: seq_sep, f: fn(parser) -> T) -> spanned<~[T]>; } @@ -198,7 +198,7 @@ impl parser: parser_common { } } - fn parse_seq_to_before_gt(sep: Option, + fn parse_seq_to_before_gt(sep: Option, f: fn(parser) -> T) -> ~[T] { let mut first = true; let mut v = ~[]; @@ -217,7 +217,7 @@ impl parser: parser_common { return v; } - fn parse_seq_to_gt(sep: Option, + fn parse_seq_to_gt(sep: Option, f: fn(parser) -> T) -> ~[T] { let v = self.parse_seq_to_before_gt(sep, f); self.expect_gt(); @@ -225,7 +225,7 @@ impl parser: parser_common { return v; } - fn parse_seq_lt_gt(sep: Option, + fn parse_seq_lt_gt(sep: Option, f: fn(parser) -> T) -> spanned<~[T]> { let lo = self.span.lo; self.expect(token::LT); @@ -235,7 +235,7 @@ impl parser: parser_common { return spanned(lo, hi, result); } - fn parse_seq_to_end(ket: token::token, sep: seq_sep, + fn parse_seq_to_end(ket: token::token, sep: seq_sep, f: fn(parser) -> T) -> ~[T] { let val = self.parse_seq_to_before_end(ket, sep, f); self.bump(); @@ -243,7 +243,7 @@ impl parser: parser_common { } - fn parse_seq_to_before_end(ket: token::token, sep: seq_sep, + fn parse_seq_to_before_end(ket: token::token, sep: seq_sep, f: fn(parser) -> T) -> ~[T] { let mut first: bool = true; let mut v: ~[T] = ~[]; @@ -261,7 +261,7 @@ impl parser: parser_common { return v; } - fn parse_unspanned_seq(bra: token::token, + fn parse_unspanned_seq(bra: token::token, ket: token::token, sep: seq_sep, f: fn(parser) -> T) -> ~[T] { @@ -273,7 +273,7 @@ impl parser: parser_common { // NB: Do not use this function unless you actually plan to place the // spanned list in the AST. - fn parse_seq(bra: token::token, ket: token::token, sep: seq_sep, + fn parse_seq(bra: token::token, ket: token::token, sep: seq_sep, f: fn(parser) -> T) -> spanned<~[T]> { let lo = self.span.lo; self.expect(bra); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 03a4c016b50..a38cc701dc3 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2278,15 +2278,7 @@ struct parser { let mut bounds = ~[]; if self.eat(token::COLON) { while is_ident(self.token) { - if self.eat_keyword(~"send") { - push(bounds, bound_send); } - else if self.eat_keyword(~"copy") { - push(bounds, bound_copy) } - else if self.eat_keyword(~"const") { - push(bounds, bound_const); - } else if self.eat_keyword(~"owned") { - push(bounds, bound_owned); - } else if is_ident(self.token) { + if is_ident(self.token) { // XXX: temporary until kinds become traits let maybe_bound = match self.token { token::IDENT(sid, _) => { diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index c2099fa447f..cd7f75b15be 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -386,7 +386,7 @@ fn contextual_keyword_table() -> hashmap<~str, ()> { ~"else", ~"move", ~"priv", ~"pub", - ~"self", ~"send", ~"static", + ~"self", ~"static", ~"use" ]; for keys.each |word| { @@ -421,7 +421,6 @@ fn restricted_keyword_table() -> hashmap<~str, ()> { ~"if", ~"impl", ~"import", ~"let", ~"log", ~"loop", ~"match", ~"mod", ~"move", ~"mut", - ~"owned", ~"pure", ~"ref", ~"return", ~"struct", diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 3bf95983053..942963797cb 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1658,10 +1658,10 @@ fn print_bounds(s: ps, bounds: @~[ast::ty_param_bound]) { for vec::each(*bounds) |bound| { nbsp(s); match bound { - ast::bound_copy => word(s.s, ~"copy"), - ast::bound_send => word(s.s, ~"send"), - ast::bound_const => word(s.s, ~"const"), - ast::bound_owned => word(s.s, ~"owned"), + ast::bound_copy => word(s.s, ~"Copy"), + ast::bound_send => word(s.s, ~"Send"), + ast::bound_const => word(s.s, ~"Const"), + ast::bound_owned => word(s.s, ~"Owned"), ast::bound_trait(t) => print_type(s, t) } } diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 59cdb6b98a7..ac2af21d087 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -8,18 +8,18 @@ use cmp::Eq; use hash::Hash; use to_bytes::IterBytes; -type hash_interner = +type hash_interner = {map: hashmap, vect: DVec}; -fn mk() -> interner { +fn mk() -> interner { let m = map::hashmap::(); let hi: hash_interner = {map: m, vect: DVec()}; return hi as interner::; } -fn mk_prefill(init: ~[T]) -> interner { +fn mk_prefill(init: ~[T]) -> interner { let rv = mk(); for init.each() |v| { rv.intern(v); } return rv; @@ -27,14 +27,14 @@ fn mk_prefill(init: ~[T]) -> interner { /* when traits can extend traits, we should extend index to get [] */ -trait interner { +trait interner { fn intern(T) -> uint; fn gensym(T) -> uint; pure fn get(uint) -> T; fn len() -> uint; } -impl hash_interner: interner { +impl hash_interner: interner { fn intern(val: T) -> uint { match self.map.find(val) { Some(idx) => return idx, diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index 22946e556e8..0665c73137c 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -271,7 +271,7 @@ fn basic_options() -> @options { } // Seems out of place, but it uses session, so I'm putting it here -fn expect(sess: session, opt: Option, msg: fn() -> ~str) -> T { +fn expect(sess: session, opt: Option, msg: fn() -> ~str) -> T { diagnostic::expect(sess.diagnostic(), opt, msg) } diff --git a/src/rustc/front/core_inject.rs b/src/rustc/front/core_inject.rs index 7bdd2f06485..f198a2ca79d 100644 --- a/src/rustc/front/core_inject.rs +++ b/src/rustc/front/core_inject.rs @@ -22,7 +22,7 @@ fn use_core(crate: @ast::crate) -> bool { fn inject_libcore_ref(sess: session, crate: @ast::crate) -> @ast::crate { - fn spanned(x: T) -> @ast::spanned { + fn spanned(x: T) -> @ast::spanned { return @{node: x, span: dummy_sp()}; } diff --git a/src/rustc/front/test.rs b/src/rustc/front/test.rs index e5245febbe8..5ac62379e76 100644 --- a/src/rustc/front/test.rs +++ b/src/rustc/front/test.rs @@ -212,7 +212,7 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item { return @item; } -fn nospan(t: T) -> ast::spanned { +fn nospan(t: T) -> ast::spanned { return {node: t, span: dummy_sp()}; } diff --git a/src/rustc/metadata/encoder.rs b/src/rustc/metadata/encoder.rs index 41db162b954..560dc384299 100644 --- a/src/rustc/metadata/encoder.rs +++ b/src/rustc/metadata/encoder.rs @@ -866,7 +866,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::Writer, // Path and definition ID indexing -fn create_index(index: ~[entry], hash_fn: fn@(T) -> uint) -> +fn create_index(index: ~[entry], hash_fn: fn@(T) -> uint) -> ~[@~[entry]] { let mut buckets: ~[@mut ~[entry]] = ~[]; for uint::range(0u, 256u) |_i| { vec::push(buckets, @mut ~[]); }; diff --git a/src/rustc/metadata/filesearch.rs b/src/rustc/metadata/filesearch.rs index 26363806da0..0384225de12 100644 --- a/src/rustc/metadata/filesearch.rs +++ b/src/rustc/metadata/filesearch.rs @@ -67,7 +67,7 @@ fn mk_filesearch(maybe_sysroot: Option, target_triple: str::from_slice(target_triple)} as filesearch } -fn search(filesearch: filesearch, pick: pick) -> Option { +fn search(filesearch: filesearch, pick: pick) -> Option { let mut rslt = None; for filesearch.lib_search_paths().each |lib_search_path| { debug!("searching %s", lib_search_path.to_str()); diff --git a/src/rustc/middle/borrowck.rs b/src/rustc/middle/borrowck.rs index 70f12581245..1286a95aa02 100644 --- a/src/rustc/middle/borrowck.rs +++ b/src/rustc/middle/borrowck.rs @@ -396,7 +396,7 @@ type req_maps = { pure_map: hashmap }; -fn save_and_restore(&save_and_restore_t: T, f: fn() -> U) -> U { +fn save_and_restore(&save_and_restore_t: T, f: fn() -> U) -> U { let old_save_and_restore_t = save_and_restore_t; let u <- f(); save_and_restore_t = old_save_and_restore_t; diff --git a/src/rustc/middle/resolve.rs b/src/rustc/middle/resolve.rs index 18bbb432e39..94786aa8a89 100644 --- a/src/rustc/middle/resolve.rs +++ b/src/rustc/middle/resolve.rs @@ -308,7 +308,7 @@ fn Atom(n: uint) -> Atom { } /// Creates a hash table of atoms. -fn atom_hashmap() -> hashmap { +fn atom_hashmap() -> hashmap { hashmap::() } diff --git a/src/rustc/middle/trans/debuginfo.rs b/src/rustc/middle/trans/debuginfo.rs index 2e5b06f0a55..056d3598a32 100644 --- a/src/rustc/middle/trans/debuginfo.rs +++ b/src/rustc/middle/trans/debuginfo.rs @@ -129,7 +129,7 @@ enum debug_metadata { retval_metadata(@metadata), } -fn cast_safely(val: T) -> U unsafe { +fn cast_safely(val: T) -> U unsafe { let val2 = val; return unsafe::transmute(val2); } @@ -147,7 +147,7 @@ fn md_from_metadata(val: debug_metadata) -> T unsafe { } } -fn cached_metadata(cache: metadata_cache, mdtag: int, +fn cached_metadata(cache: metadata_cache, mdtag: int, eq: fn(md: T) -> bool) -> Option unsafe { if cache.contains_key(mdtag) { let items = cache.get(mdtag); diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index 6fee6f22fe0..d65b0e1978c 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -58,7 +58,7 @@ fn mk_nominal_id(tcx: ty::ctxt, did: ast::def_id, @{did: did, parent_id: parent_id, tps: tps_norm} } -fn new_nominal_id_hash() -> hashmap { +fn new_nominal_id_hash() -> hashmap { return hashmap(); } diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index b8679a3818a..e6476b57e70 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -799,7 +799,7 @@ fn mk_rcache() -> creader_cache { return map::hashmap(); } -fn new_ty_hash() -> map::hashmap { +fn new_ty_hash() -> map::hashmap { map::hashmap() } @@ -2568,7 +2568,7 @@ pure fn hash_bound_region(br: &bound_region) -> uint { } } -fn br_hashmap() -> hashmap { +fn br_hashmap() -> hashmap { map::hashmap() } @@ -3081,7 +3081,7 @@ fn occurs_check(tcx: ctxt, sp: span, vid: TyVid, rt: t) { // Maintains a little union-set tree for inferred modes. `canon()` returns // the current head value for `m0`. -fn canon(tbl: hashmap>, +fn canon(tbl: hashmap>, +m0: ast::inferable) -> ast::inferable { match m0 { ast::infer(id) => match tbl.find(id) { diff --git a/src/rustc/middle/typeck/astconv.rs b/src/rustc/middle/typeck/astconv.rs index 85bac78da97..2ac872117e3 100644 --- a/src/rustc/middle/typeck/astconv.rs +++ b/src/rustc/middle/typeck/astconv.rs @@ -69,7 +69,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 { @@ -80,7 +80,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 { @@ -129,7 +129,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, @@ -152,10 +152,10 @@ const NO_TPS: uint = 2u; // 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}; @@ -164,7 +164,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_maybe_vstore( + fn mk_maybe_vstore( self: AC, rscope: RS, a_seq_ty: ast::mt, vst: ty::vstore, span: span, constr: fn(ty::mt) -> ty::t) -> ty::t { @@ -400,7 +400,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 { @@ -445,7 +445,7 @@ fn ty_of_arg( {mode: mode, ty: ty} } -fn ast_proto_to_proto( +fn ast_proto_to_proto( self: AC, rscope: RS, span: span, ast_proto: ast::proto) -> ty::fn_proto { match ast_proto { ast::proto_bare => @@ -465,7 +465,7 @@ fn ast_proto_to_proto( 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/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index 96d9bf1e2e5..f63f6f2e125 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -1203,7 +1203,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // through the `unpack` function. It there is no expected type or // resolution is not possible (e.g., no constraints yet present), just // returns `none`. - fn unpack_expected(fcx: @fn_ctxt, expected: Option, + fn unpack_expected(fcx: @fn_ctxt, expected: Option, unpack: fn(ty::sty) -> Option) -> Option { match expected { diff --git a/src/rustc/middle/typeck/collect.rs b/src/rustc/middle/typeck/collect.rs index 3206d1709c5..0a06e554724 100644 --- a/src/rustc/middle/typeck/collect.rs +++ b/src/rustc/middle/typeck/collect.rs @@ -75,7 +75,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) diff --git a/src/rustc/middle/typeck/infer.rs b/src/rustc/middle/typeck/infer.rs index cbda05a4012..2aef5ff6b5b 100644 --- a/src/rustc/middle/typeck/infer.rs +++ b/src/rustc/middle/typeck/infer.rs @@ -298,8 +298,8 @@ export assignment; export root, to_str; export int_ty_set_all; -type bound = Option; -type bounds = {lb: bound, ub: bound}; +type bound = Option; +type bounds = {lb: bound, ub: bound}; type cres = Result; // "combine result" type ures = cres<()>; // "unify result" @@ -348,7 +348,7 @@ fn fixup_err_to_str(f: fixup_err) -> ~str { } } -fn new_vals_and_bindings() -> vals_and_bindings { +fn new_vals_and_bindings() -> vals_and_bindings { vals_and_bindings { vals: smallintmap::mk(), mut bindings: ~[] @@ -458,12 +458,12 @@ fn resolve_borrowings(cx: infer_ctxt) { */ trait then { - fn then(f: fn() -> Result) + fn then(f: fn() -> Result) -> Result; } impl ures: then { - fn then(f: fn() -> Result) + fn then(f: fn() -> Result) -> Result { self.chain(|_i| f()) } @@ -474,7 +474,7 @@ trait cres_helpers { fn compare(t: T, f: fn() -> ty::type_err) -> cres; } -impl cres: cres_helpers { +impl cres: cres_helpers { fn to_ures() -> ures { match self { Ok(_v) => Ok(()), @@ -497,7 +497,7 @@ fn uok() -> ures { Ok(()) } -fn rollback_to( +fn rollback_to( vb: &vals_and_bindings, len: uint) { while vb.bindings.len() != len { diff --git a/src/rustc/middle/typeck/infer/to_str.rs b/src/rustc/middle/typeck/infer/to_str.rs index f66685d766b..7acfdcac424 100644 --- a/src/rustc/middle/typeck/infer/to_str.rs +++ b/src/rustc/middle/typeck/infer/to_str.rs @@ -23,7 +23,7 @@ impl ty::region: to_str { } } -impl bound: to_str { +impl bound: to_str { fn to_str(cx: infer_ctxt) -> ~str { match self { Some(v) => v.to_str(cx), @@ -32,7 +32,7 @@ impl bound: to_str { } } -impl bounds: to_str { +impl bounds: to_str { fn to_str(cx: infer_ctxt) -> ~str { fmt!("{%s <: %s}", self.lb.to_str(cx), @@ -48,7 +48,7 @@ impl int_ty_set: to_str { } } -impl var_value: to_str { +impl var_value: to_str { fn to_str(cx: infer_ctxt) -> ~str { match self { redirect(vid) => fmt!("redirect(%s)", vid.to_str()), diff --git a/src/rustc/middle/typeck/infer/unify.rs b/src/rustc/middle/typeck/infer/unify.rs index 36c3093874a..2793d0e4f5a 100644 --- a/src/rustc/middle/typeck/infer/unify.rs +++ b/src/rustc/middle/typeck/infer/unify.rs @@ -3,24 +3,24 @@ use integral::*; use to_str::to_str; use std::smallintmap::SmallIntMap; -enum var_value { +enum var_value { redirect(V), root(T, uint), } -struct vals_and_bindings { +struct vals_and_bindings { vals: SmallIntMap>, mut bindings: ~[(V, var_value)], } -struct node { +struct node { root: V, possible_types: T, rank: uint, } impl infer_ctxt { - fn get( + fn get( vb: &vals_and_bindings, vid: V) -> node { let vid_u = vid.to_uint(); @@ -46,7 +46,7 @@ impl infer_ctxt { } } - fn set( + fn set( vb: &vals_and_bindings, vid: V, +new_v: var_value) { diff --git a/src/rustc/middle/typeck/rscope.rs b/src/rustc/middle/typeck/rscope.rs index 3826d3e527c..0224d6933a7 100644 --- a/src/rustc/middle/typeck/rscope.rs +++ b/src/rustc/middle/typeck/rscope.rs @@ -46,7 +46,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}) } @@ -63,7 +63,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/rustdoc/astsrv.rs b/src/rustdoc/astsrv.rs index a68f998e6fe..385f76873b3 100644 --- a/src/rustdoc/astsrv.rs +++ b/src/rustdoc/astsrv.rs @@ -88,7 +88,7 @@ fn act(po: comm::Port, source: ~str, parse: parser) { } } -fn exec( +fn exec( srv: srv, +f: fn~(ctxt: ctxt) -> T ) -> T { diff --git a/src/rustdoc/attr_pass.rs b/src/rustdoc/attr_pass.rs index d93e49aa841..6244d52c897 100644 --- a/src/rustdoc/attr_pass.rs +++ b/src/rustdoc/attr_pass.rs @@ -89,7 +89,7 @@ fn fold_item( } } -fn parse_item_attrs( +fn parse_item_attrs( srv: astsrv::srv, id: doc::ast_id, +parse_attrs: fn~(~[ast::attribute]) -> T) -> T { diff --git a/src/rustdoc/fold.rs b/src/rustdoc/fold.rs index 5dcbfb664ea..a3a8fa5d6ae 100644 --- a/src/rustdoc/fold.rs +++ b/src/rustdoc/fold.rs @@ -50,7 +50,7 @@ type t = { // This exists because fn types don't infer correctly as record // initializers, but they do as function arguments -fn mk_fold( +fn mk_fold( ctxt: T, +fold_doc: fold_doc, +fold_crate: fold_crate, @@ -80,7 +80,7 @@ fn mk_fold( }) } -fn default_any_fold(ctxt: T) -> fold { +fn default_any_fold(ctxt: T) -> fold { mk_fold( ctxt, |f, d| default_seq_fold_doc(f, d), @@ -97,7 +97,7 @@ fn default_any_fold(ctxt: T) -> fold { ) } -fn default_seq_fold(ctxt: T) -> fold { +fn default_seq_fold(ctxt: T) -> fold { mk_fold( ctxt, |f, d| default_seq_fold_doc(f, d), @@ -114,7 +114,7 @@ fn default_seq_fold(ctxt: T) -> fold { ) } -fn default_par_fold(ctxt: T) -> fold { +fn default_par_fold(ctxt: T) -> fold { mk_fold( ctxt, |f, d| default_seq_fold_doc(f, d), @@ -163,7 +163,7 @@ fn default_seq_fold_item( doc } -fn default_any_fold_mod( +fn default_any_fold_mod( fold: fold, doc: doc::moddoc ) -> doc::moddoc { @@ -189,7 +189,7 @@ fn default_seq_fold_mod( }) } -fn default_par_fold_mod( +fn default_par_fold_mod( fold: fold, doc: doc::moddoc ) -> doc::moddoc { @@ -202,7 +202,7 @@ fn default_par_fold_mod( }) } -fn default_any_fold_nmod( +fn default_any_fold_nmod( fold: fold, doc: doc::nmoddoc ) -> doc::nmoddoc { @@ -228,7 +228,7 @@ fn default_seq_fold_nmod( } } -fn default_par_fold_nmod( +fn default_par_fold_nmod( fold: fold, doc: doc::nmoddoc ) -> doc::nmoddoc { diff --git a/src/test/auxiliary/cci_capture_clause.rs b/src/test/auxiliary/cci_capture_clause.rs index 27400322e40..68d24ed28cb 100644 --- a/src/test/auxiliary/cci_capture_clause.rs +++ b/src/test/auxiliary/cci_capture_clause.rs @@ -2,7 +2,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/cci_nested_lib.rs b/src/test/auxiliary/cci_nested_lib.rs index 8a714740550..6ead738753e 100644 --- a/src/test/auxiliary/cci_nested_lib.rs +++ b/src/test/auxiliary/cci_nested_lib.rs @@ -3,11 +3,11 @@ use dvec::DVec; type entry = {key: A, value: B}; type alist = { eq_fn: fn@(A,A) -> bool, data: DVec> }; -fn alist_add(lst: alist, k: A, v: B) { +fn alist_add(lst: alist, k: A, v: B) { lst.data.push({key:k, value:v}); } -fn alist_get(lst: alist, k: A) -> B { +fn alist_get(lst: alist, k: A) -> B { let eq_fn = lst.eq_fn; for lst.data.each |entry| { if eq_fn(entry.key, k) { return entry.value; } @@ -16,13 +16,13 @@ fn alist_get(lst: alist, k: A) -> B { } #[inline] -fn new_int_alist() -> alist { +fn new_int_alist() -> alist { fn eq_int(&&a: int, &&b: int) -> bool { a == b } return {eq_fn: eq_int, data: DVec()}; } #[inline] -fn new_int_alist_2() -> alist { +fn new_int_alist_2() -> alist { #[inline] fn eq_int(&&a: int, &&b: int) -> bool { a == b } return {eq_fn: eq_int, data: DVec()}; diff --git a/src/test/auxiliary/issue-2526.rs b/src/test/auxiliary/issue-2526.rs index 14fe2b8fee9..ef977507dd2 100644 --- a/src/test/auxiliary/issue-2526.rs +++ b/src/test/auxiliary/issue-2526.rs @@ -7,18 +7,18 @@ use std; export context; -struct arc_destruct { +struct arc_destruct { _data: int, drop {} } -fn arc_destruct(data: int) -> arc_destruct { +fn arc_destruct(data: int) -> arc_destruct { arc_destruct { _data: data } } -fn arc(_data: T) -> arc_destruct { +fn arc(_data: T) -> arc_destruct { arc_destruct(0) } diff --git a/src/test/auxiliary/issue-2631-a.rs b/src/test/auxiliary/issue-2631-a.rs index 35a35420636..4c3a6ea6121 100644 --- a/src/test/auxiliary/issue-2631-a.rs +++ b/src/test/auxiliary/issue-2631-a.rs @@ -10,6 +10,6 @@ use std::map::hashmap; type header_map = hashmap<~str, @DVec<@~str>>; // the unused ty param is necessary so this gets monomorphized -fn request(req: header_map) { +fn request(req: header_map) { let _x = *(*req.get(~"METHOD"))[0u]; } diff --git a/src/test/auxiliary/static-methods-crate.rs b/src/test/auxiliary/static-methods-crate.rs index 954e1f66f51..cd011227c84 100644 --- a/src/test/auxiliary/static-methods-crate.rs +++ b/src/test/auxiliary/static-methods-crate.rs @@ -25,7 +25,7 @@ impl bool: read { } } -fn read(s: ~str) -> T { +fn read(s: ~str) -> T { match readMaybe(s) { Some(x) => x, _ => fail ~"read failed!" diff --git a/src/test/auxiliary/test_comm.rs b/src/test/auxiliary/test_comm.rs index 20c5579e427..fed01e6a30e 100644 --- a/src/test/auxiliary/test_comm.rs +++ b/src/test/auxiliary/test_comm.rs @@ -18,16 +18,16 @@ 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, drop unsafe { debug!("in the port_ptr destructor"); @@ -48,7 +48,7 @@ struct port_ptr { } } -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 @@ -59,11 +59,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 = 0u; let yieldp = ptr::addr_of(yield); let mut res; diff --git a/src/test/bench/pingpong.rs b/src/test/bench/pingpong.rs index 53132293de9..5e0f9072f6c 100644 --- a/src/test/bench/pingpong.rs +++ b/src/test/bench/pingpong.rs @@ -64,7 +64,7 @@ macro_rules! follow ( ) ) -fn switch(+endp: pipes::RecvPacketBuffered, +fn switch(+endp: pipes::RecvPacketBuffered, f: fn(+Option) -> U) -> U { f(pipes::try_recv(endp)) } diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 6d46d2b597e..5437de9643a 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -15,14 +15,14 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str { return (xx as float) * 100f / (yy as float); } - pure fn le_by_val(kv0: &(TT,UU), + pure fn le_by_val(kv0: &(TT,UU), kv1: &(TT,UU)) -> bool { let (_, v0) = *kv0; let (_, v1) = *kv1; return v0 >= v1; } - pure fn le_by_key(kv0: &(TT,UU), + pure fn le_by_key(kv0: &(TT,UU), kv1: &(TT,UU)) -> bool { let (k0, _) = *kv0; let (k1, _) = *kv1; @@ -30,7 +30,7 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str { } // sort by key, then by value - fn sortKV(orig: ~[(TT,UU)]) -> ~[(TT,UU)] { + fn sortKV(orig: ~[(TT,UU)]) -> ~[(TT,UU)] { return sort::merge_sort(le_by_val, sort::merge_sort(le_by_key, orig)); } diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 578e9c433f3..5f907e55a1f 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -14,14 +14,14 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str { return (xx as float) * 100f / (yy as float); } - pure fn le_by_val(kv0: &(TT,UU), + pure fn le_by_val(kv0: &(TT,UU), kv1: &(TT,UU)) -> bool { let (_, v0) = *kv0; let (_, v1) = *kv1; return v0 >= v1; } - pure fn le_by_key(kv0: &(TT,UU), + pure fn le_by_key(kv0: &(TT,UU), kv1: &(TT,UU)) -> bool { let (k0, _) = *kv0; let (k1, _) = *kv1; @@ -29,7 +29,7 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str { } // sort by key, then by value - fn sortKV(orig: ~[(TT,UU)]) -> ~[(TT,UU)] { + fn sortKV(orig: ~[(TT,UU)]) -> ~[(TT,UU)] { return sort::merge_sort(le_by_val, sort::merge_sort(le_by_key, orig)); } diff --git a/src/test/bench/task-perf-word-count-generic.rs b/src/test/bench/task-perf-word-count-generic.rs index 646488c61c8..0469e7e40bf 100644 --- a/src/test/bench/task-perf-word-count-generic.rs +++ b/src/test/bench/task-perf-word-count-generic.rs @@ -39,9 +39,9 @@ trait hash_key { pure fn eq(&&k: self) -> bool; } -fn mk_hash() -> map::hashmap { - pure fn hashfn(k: &K) -> uint { k.hash() } - pure fn hasheq(k1: &K, k2: &K) -> bool { k1.eq(*k2) } +fn mk_hash() -> map::hashmap { + pure fn hashfn(k: &K) -> uint { k.hash() } + pure fn hasheq(k1: &K, k2: &K) -> bool { k1.eq(*k2) } map::hashmap(hashfn, hasheq) } @@ -125,35 +125,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: ~[ctrl_proto::server::open], inputs: ~[K1]) @@ -169,7 +169,7 @@ mod map_reduce { return tasks; } - fn map_task( + fn map_task( map: mapper, ctrl: box>, input: K1) @@ -198,7 +198,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); } @@ -206,7 +206,7 @@ mod map_reduce { ctrl_proto::client::mapper_done(ctrl.unwrap()); } - fn reduce_task( + fn reduce_task( reduce: reducer, key: K, out: Chan>>) @@ -218,7 +218,7 @@ mod map_reduce { let mut ref_count = 0; let mut is_done = false; - fn get(p: Port>, + fn get(p: Port>, &ref_count: int, &is_done: bool) -> Option { while !is_done || ref_count > 0 { @@ -241,7 +241,7 @@ mod map_reduce { reduce(key, || get(p, ref_count, is_done) ); } - fn map_reduce( + fn map_reduce( map: mapper, reduce: reducer, inputs: ~[K1]) diff --git a/src/test/compile-fail/bad-method-typaram-kind.rs b/src/test/compile-fail/bad-method-typaram-kind.rs index 1da4ec8a626..8983d42a90b 100644 --- a/src/test/compile-fail/bad-method-typaram-kind.rs +++ b/src/test/compile-fail/bad-method-typaram-kind.rs @@ -3,11 +3,11 @@ fn foo() { } trait bar { - fn bar(); + fn bar(); } impl uint: bar { - fn bar() { + fn bar() { } } diff --git a/src/test/compile-fail/fn-variance-2.rs b/src/test/compile-fail/fn-variance-2.rs index 6d9bdabae86..487860c01b1 100644 --- a/src/test/compile-fail/fn-variance-2.rs +++ b/src/test/compile-fail/fn-variance-2.rs @@ -1,4 +1,4 @@ -fn reproduce(t: T) -> fn@() -> T { +fn reproduce(t: T) -> fn@() -> T { fn@() -> T { t } } diff --git a/src/test/compile-fail/fn-variance-3.rs b/src/test/compile-fail/fn-variance-3.rs index f9fe3d31fcc..576a9ba7675 100644 --- a/src/test/compile-fail/fn-variance-3.rs +++ b/src/test/compile-fail/fn-variance-3.rs @@ -1,4 +1,4 @@ -fn mk_identity() -> fn@(T) -> T { +fn mk_identity() -> fn@(T) -> T { fn@(t: T) -> T { t } } diff --git a/src/test/compile-fail/infinite-instantiation.rs b/src/test/compile-fail/infinite-instantiation.rs index 090bb5e4f48..682b856afd0 100644 --- a/src/test/compile-fail/infinite-instantiation.rs +++ b/src/test/compile-fail/infinite-instantiation.rs @@ -11,7 +11,7 @@ impl uint: to_opt { } } -impl Option: to_opt { +impl Option: to_opt { fn to_option() -> Option> { Some(self) } diff --git a/src/test/compile-fail/issue-2587-2.rs b/src/test/compile-fail/issue-2587-2.rs index db8d8f9fb7b..36cf99b321c 100644 --- a/src/test/compile-fail/issue-2587-2.rs +++ b/src/test/compile-fail/issue-2587-2.rs @@ -1,4 +1,4 @@ -fn foo(+_t: T) { fail; } +fn foo(+_t: T) { fail; } fn bar(+_t: T) { fail; } diff --git a/src/test/compile-fail/issue-2611-3.rs b/src/test/compile-fail/issue-2611-3.rs index 9a042fd1d0b..5545c0b2a13 100644 --- a/src/test/compile-fail/issue-2611-3.rs +++ b/src/test/compile-fail/issue-2611-3.rs @@ -7,7 +7,7 @@ import iter; import iter::BaseIter; trait A { - fn b(x: C) -> C; + fn b(x: C) -> C; } struct E { @@ -15,7 +15,7 @@ struct E { } impl E: A { - fn b(_x: F) -> F { fail } //~ ERROR in method `b`, type parameter 0 has 1 bound, but + fn b(_x: F) -> F { fail } //~ ERROR in method `b`, type parameter 0 has 1 bound, but } fn main() {} \ No newline at end of file diff --git a/src/test/compile-fail/issue-2611-4.rs b/src/test/compile-fail/issue-2611-4.rs index 977cce73808..22674c06595 100644 --- a/src/test/compile-fail/issue-2611-4.rs +++ b/src/test/compile-fail/issue-2611-4.rs @@ -4,7 +4,7 @@ import iter; import iter::BaseIter; trait A { - fn b(x: C) -> C; + fn b(x: C) -> C; } struct E { @@ -12,7 +12,7 @@ struct E { } impl E: A { - fn b(_x: F) -> F { fail } //~ ERROR in method `b`, type parameter 0 has 2 bounds, but + fn b(_x: F) -> F { fail } //~ ERROR in method `b`, type parameter 0 has 2 bounds, but } fn main() {} \ No newline at end of file diff --git a/src/test/compile-fail/issue-2611-5.rs b/src/test/compile-fail/issue-2611-5.rs index 99afe776f86..b01342282b2 100644 --- a/src/test/compile-fail/issue-2611-5.rs +++ b/src/test/compile-fail/issue-2611-5.rs @@ -4,7 +4,7 @@ import iter; import iter::BaseIter; trait A { - fn b(x: C) -> C; + fn b(x: C) -> C; } struct E { @@ -13,7 +13,7 @@ struct E { impl E: A { // n.b. The error message is awful -- see #3404 - fn b(_x: G) -> G { fail } //~ ERROR method `b` has an incompatible type + fn b(_x: G) -> G { fail } //~ ERROR method `b` has an incompatible type } fn main() {} \ No newline at end of file diff --git a/src/test/compile-fail/issue-2718-a.rs b/src/test/compile-fail/issue-2718-a.rs index 0feaa9b857e..b857af4e2f3 100644 --- a/src/test/compile-fail/issue-2718-a.rs +++ b/src/test/compile-fail/issue-2718-a.rs @@ -1,4 +1,4 @@ -struct send_packet { +struct send_packet { p: T } diff --git a/src/test/compile-fail/issue-2766-a.rs b/src/test/compile-fail/issue-2766-a.rs index f2c6ded88d5..78225ba15ec 100644 --- a/src/test/compile-fail/issue-2766-a.rs +++ b/src/test/compile-fail/issue-2766-a.rs @@ -1,7 +1,7 @@ mod stream { - enum stream { send(T, server::stream), } + enum stream { send(T, server::stream), } mod server { - impl stream { + impl stream { fn recv() -> extern fn(+stream) -> stream::stream { // resolve really should report just one error here. // Change the test case when it changes. @@ -14,7 +14,7 @@ mod stream { recv } } - type stream = pipes::RecvPacket>; + type stream = pipes::RecvPacket>; } } diff --git a/src/test/compile-fail/kindck-owned-trait-contains.rs b/src/test/compile-fail/kindck-owned-trait-contains.rs index 5d12ab9d517..c916bcba7c8 100644 --- a/src/test/compile-fail/kindck-owned-trait-contains.rs +++ b/src/test/compile-fail/kindck-owned-trait-contains.rs @@ -1,10 +1,10 @@ trait repeat { fn get() -> A; } -impl @A: repeat { +impl @A: repeat { fn get() -> A { *self } } -fn repeater(v: @A) -> repeat { +fn repeater(v: @A) -> repeat { // Note: owned kind is not necessary as A appears in the trait type v as repeat:: // No } diff --git a/src/test/compile-fail/kindck-owned-trait-scoped.rs b/src/test/compile-fail/kindck-owned-trait-scoped.rs index 80a0e3bc0d5..5b39d3e4651 100644 --- a/src/test/compile-fail/kindck-owned-trait-scoped.rs +++ b/src/test/compile-fail/kindck-owned-trait-scoped.rs @@ -5,11 +5,11 @@ trait foo { fn foo(i: &self/int) -> int; } -impl T: foo { +impl T: foo { fn foo(i: &self/int) -> int {*i} } -fn to_foo(t: T) { +fn to_foo(t: T) { // This version is ok because, although T may contain borrowed // pointers, it never escapes the fn body. We know this because // the type of foo includes a region which will be resolved to @@ -19,13 +19,13 @@ fn to_foo(t: T) { assert x.foo(v) == 3; } -fn to_foo_2(t: T) -> foo { +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 } -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 35009847c73..ea57fe5a6cf 100644 --- a/src/test/compile-fail/kindck-owned-trait.rs +++ b/src/test/compile-fail/kindck-owned-trait.rs @@ -1,10 +1,10 @@ trait foo { fn foo(); } -fn to_foo(t: T) -> foo { +fn to_foo(t: T) -> foo { t as foo //~ ERROR value may contain borrowed pointers; use `owned` 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 e689292c45e..3e6a2f2946d 100644 --- a/src/test/compile-fail/kindck-owned.rs +++ b/src/test/compile-fail/kindck-owned.rs @@ -1,8 +1,8 @@ -fn copy1(t: T) -> fn@() -> T { +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 } } diff --git a/src/test/compile-fail/liveness-use-after-send.rs b/src/test/compile-fail/liveness-use-after-send.rs index 6dfa9a997ff..5447c88e567 100644 --- a/src/test/compile-fail/liveness-use-after-send.rs +++ b/src/test/compile-fail/liveness-use-after-send.rs @@ -1,4 +1,4 @@ -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/non-const.rs b/src/test/compile-fail/non-const.rs index 37ba5830b10..d2cf08fc847 100644 --- a/src/test/compile-fail/non-const.rs +++ b/src/test/compile-fail/non-const.rs @@ -1,6 +1,6 @@ // Test that various non const things are rejected. -fn foo(_x: T) { } +fn foo(_x: T) { } struct r { x:int, diff --git a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs index 39eb825b80b..bd65fa41fd5 100644 --- a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs +++ b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs @@ -5,7 +5,7 @@ use core; -fn last(v: ~[const T]) -> core::Option { +fn last(v: ~[const T]) -> core::Option { fail; } diff --git a/src/test/compile-fail/tps-invariant-trait.rs b/src/test/compile-fail/tps-invariant-trait.rs index 88039f234b5..b1525229658 100644 --- a/src/test/compile-fail/tps-invariant-trait.rs +++ b/src/test/compile-fail/tps-invariant-trait.rs @@ -7,7 +7,7 @@ enum box_impl = { mut f: T }; -impl box_impl: box_trait { +impl box_impl: box_trait { fn get() -> T { return self.f; } fn set(t: T) { self.f = t; } } diff --git a/src/test/compile-fail/unique-unique-kind.rs b/src/test/compile-fail/unique-unique-kind.rs index afa8134e083..eea832c91a4 100644 --- a/src/test/compile-fail/unique-unique-kind.rs +++ b/src/test/compile-fail/unique-unique-kind.rs @@ -1,4 +1,4 @@ -fn f(_i: T) { +fn f(_i: T) { } fn main() { diff --git a/src/test/compile-fail/vec-concat-bug.rs b/src/test/compile-fail/vec-concat-bug.rs index afbb57f5878..c21e337af60 100644 --- a/src/test/compile-fail/vec-concat-bug.rs +++ b/src/test/compile-fail/vec-concat-bug.rs @@ -1,4 +1,4 @@ -fn concat(v: ~[const ~[const T]]) -> ~[T] { +fn concat(v: ~[const ~[const T]]) -> ~[T] { let mut r = ~[]; // Earlier versions of our type checker accepted this: diff --git a/src/test/run-fail/bug-811.rs b/src/test/run-fail/bug-811.rs index e376085772b..a6575143765 100644 --- a/src/test/run-fail/bug-811.rs +++ b/src/test/run-fail/bug-811.rs @@ -4,8 +4,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 ed8bd9173b5..20620ac62e8 100644 --- a/src/test/run-fail/issue-2444.rs +++ b/src/test/run-fail/issue-2444.rs @@ -3,7 +3,7 @@ use 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 40d3067d4df..44ce6e524ca 100644 --- a/src/test/run-fail/port-type.rs +++ b/src/test/run-fail/port-type.rs @@ -5,7 +5,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 410bc9b570b..23cc80233fe 100644 --- a/src/test/run-pass/alignment-gep-tup-like-1.rs +++ b/src/test/run-pass/alignment-gep-tup-like-1.rs @@ -2,7 +2,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 dda856efb37..098c82b18d4 100644 --- a/src/test/run-pass/alignment-gep-tup-like-2.rs +++ b/src/test/run-pass/alignment-gep-tup-like-2.rs @@ -8,12 +8,12 @@ type _rec = { mut rec: Option<@rec> }; -fn make_cycle(a: A) { +fn make_cycle(a: A) { let g: @rec = @rec({val: a, mut rec: None}); 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/auto-instantiate.rs b/src/test/run-pass/auto-instantiate.rs index 522ead87c73..941a20f85e0 100644 --- a/src/test/run-pass/auto-instantiate.rs +++ b/src/test/run-pass/auto-instantiate.rs @@ -2,7 +2,7 @@ // -*- rust -*- -fn f(x: T, y: U) -> {a: T, b: U} { return {a: x, b: y}; } +fn f(x: T, y: U) -> {a: T, b: U} { return {a: x, b: y}; } fn main() { log(debug, f({x: 3, y: 4, z: 5}, 4).a.x); diff --git a/src/test/run-pass/autobind.rs b/src/test/run-pass/autobind.rs index ad3b1366fca..70e513a879d 100644 --- a/src/test/run-pass/autobind.rs +++ b/src/test/run-pass/autobind.rs @@ -1,4 +1,4 @@ -fn f(x: ~[T]) -> T { return x[0]; } +fn f(x: ~[T]) -> T { return x[0]; } fn g(act: fn(~[int]) -> int) -> int { return act(~[1, 2, 3]); } diff --git a/src/test/run-pass/bounded-fn-type.rs b/src/test/run-pass/bounded-fn-type.rs index b21050f4d43..09f05d86d07 100644 --- a/src/test/run-pass/bounded-fn-type.rs +++ b/src/test/run-pass/bounded-fn-type.rs @@ -1,7 +1,7 @@ fn ignore(_x: T) {} fn main() { - let f: fn@:send() = ||(); + let f: fn@:Send() = ||(); ignore(f); } diff --git a/src/test/run-pass/box-unbox.rs b/src/test/run-pass/box-unbox.rs index e189066c09f..27cb9846b3d 100644 --- a/src/test/run-pass/box-unbox.rs +++ b/src/test/run-pass/box-unbox.rs @@ -1,8 +1,8 @@ -type box = {c: @T}; +type box = {c: @T}; -fn unbox(b: box) -> T { return *b.c; } +fn unbox(b: box) -> T { return *b.c; } fn main() { let foo: int = 17; 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 316d98cd84a..665ee3cfe25 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -14,7 +14,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 : map { +struct cat : map { priv { // Yes, you can have negative meows mut meows : int, @@ -94,7 +94,7 @@ struct cat : map { fn clear() { } } -fn cat(in_x : int, in_y : int, in_name: T) -> cat { +fn cat(in_x : int, in_y : int, in_name: T) -> cat { cat { meows: in_x, how_hungry: in_y, diff --git a/src/test/run-pass/class-trait-bounded-param.rs b/src/test/run-pass/class-trait-bounded-param.rs index 91b3f68d5b2..2ffd41229a5 100644 --- a/src/test/run-pass/class-trait-bounded-param.rs +++ b/src/test/run-pass/class-trait-bounded-param.rs @@ -3,7 +3,7 @@ use std; use std::map::{map, hashmap, int_hash}; -class keys> +class keys> : iter::base_iter { let map: M; 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 ed0388b2bce..83f92e7a72d 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 @@ -6,7 +6,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/const-bound.rs b/src/test/run-pass/const-bound.rs index e5e60f184f2..9d0d33524ef 100644 --- a/src/test/run-pass/const-bound.rs +++ b/src/test/run-pass/const-bound.rs @@ -2,7 +2,7 @@ // are const. -fn foo(x: T) -> T { x } +fn foo(x: T) -> T { x } fn main() { foo(1); diff --git a/src/test/run-pass/expr-alt-generic-box2.rs b/src/test/run-pass/expr-alt-generic-box2.rs index ad3436c2b8f..ef0b2c2078d 100644 --- a/src/test/run-pass/expr-alt-generic-box2.rs +++ b/src/test/run-pass/expr-alt-generic-box2.rs @@ -4,7 +4,7 @@ // -*- rust -*- type compare = fn@(T, T) -> bool; -fn test_generic(expected: T, eq: compare) { +fn test_generic(expected: T, eq: compare) { let actual: T = match true { true => { expected }, _ => fail ~"wat" }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-alt-generic-unique1.rs b/src/test/run-pass/expr-alt-generic-unique1.rs index a227931180f..264f03ee2c3 100644 --- a/src/test/run-pass/expr-alt-generic-unique1.rs +++ b/src/test/run-pass/expr-alt-generic-unique1.rs @@ -3,7 +3,7 @@ // -*- rust -*- type compare = fn@(~T, ~T) -> bool; -fn test_generic(expected: ~T, eq: compare) { +fn test_generic(expected: ~T, eq: compare) { let actual: ~T = match true { true => { expected }, _ => fail ~"wat" }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-alt-generic-unique2.rs b/src/test/run-pass/expr-alt-generic-unique2.rs index d92cde5d82a..e5c8d2acd87 100644 --- a/src/test/run-pass/expr-alt-generic-unique2.rs +++ b/src/test/run-pass/expr-alt-generic-unique2.rs @@ -4,7 +4,7 @@ // -*- rust -*- type compare = fn@(T, T) -> bool; -fn test_generic(expected: T, eq: compare) { +fn test_generic(expected: T, eq: compare) { let actual: T = match true { true => expected, _ => fail ~"wat" }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-alt-generic.rs b/src/test/run-pass/expr-alt-generic.rs index 0d1f5e2bbe8..d17d7db9038 100644 --- a/src/test/run-pass/expr-alt-generic.rs +++ b/src/test/run-pass/expr-alt-generic.rs @@ -4,7 +4,7 @@ // -*- rust -*- type compare = fn@(T, T) -> bool; -fn test_generic(expected: T, eq: compare) { +fn test_generic(expected: T, eq: compare) { let actual: T = match true { true => { expected }, _ => fail ~"wat" }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-block-generic-box2.rs b/src/test/run-pass/expr-block-generic-box2.rs index 7935cec7f5d..8fc566d5843 100644 --- a/src/test/run-pass/expr-block-generic-box2.rs +++ b/src/test/run-pass/expr-block-generic-box2.rs @@ -4,7 +4,7 @@ // -*- rust -*- type compare = fn@(T, T) -> bool; -fn test_generic(expected: T, eq: compare) { +fn test_generic(expected: T, eq: compare) { let actual: T = { expected }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-block-generic-unique1.rs b/src/test/run-pass/expr-block-generic-unique1.rs index df94544acd1..0ccabb2c081 100644 --- a/src/test/run-pass/expr-block-generic-unique1.rs +++ b/src/test/run-pass/expr-block-generic-unique1.rs @@ -3,7 +3,7 @@ // -*- rust -*- type compare = fn@(~T, ~T) -> bool; -fn test_generic(expected: ~T, eq: compare) { +fn test_generic(expected: ~T, eq: compare) { let actual: ~T = { expected }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-block-generic-unique2.rs b/src/test/run-pass/expr-block-generic-unique2.rs index 51bb0274e7f..cda0148cfe8 100644 --- a/src/test/run-pass/expr-block-generic-unique2.rs +++ b/src/test/run-pass/expr-block-generic-unique2.rs @@ -4,7 +4,7 @@ // -*- rust -*- type compare = fn@(T, T) -> bool; -fn test_generic(expected: T, eq: compare) { +fn test_generic(expected: T, eq: compare) { let actual: T = { expected }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-block-generic.rs b/src/test/run-pass/expr-block-generic.rs index 71e6f962e35..adb49f3142d 100644 --- a/src/test/run-pass/expr-block-generic.rs +++ b/src/test/run-pass/expr-block-generic.rs @@ -6,7 +6,7 @@ // Tests for standalone blocks as expressions with dynamic type sizes type compare = fn@(T, T) -> bool; -fn test_generic(expected: T, eq: compare) { +fn test_generic(expected: T, eq: compare) { let actual: T = { expected }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-fn.rs b/src/test/run-pass/expr-fn.rs index f181b3f3261..c2d27cf696c 100644 --- a/src/test/run-pass/expr-fn.rs +++ b/src/test/run-pass/expr-fn.rs @@ -9,7 +9,7 @@ fn test_vec() { } fn test_generic() { - fn f(t: T) -> T { t } + fn f(t: T) -> T { t } assert (f(10) == 10); } diff --git a/src/test/run-pass/expr-if-generic-box2.rs b/src/test/run-pass/expr-if-generic-box2.rs index ef56bcd41dc..e5370db83d1 100644 --- a/src/test/run-pass/expr-if-generic-box2.rs +++ b/src/test/run-pass/expr-if-generic-box2.rs @@ -4,7 +4,7 @@ // -*- rust -*- type compare = fn@(T, T) -> bool; -fn test_generic(expected: T, not_expected: T, eq: compare) { +fn test_generic(expected: T, not_expected: T, eq: compare) { let actual: T = if true { expected } else { not_expected }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-if-generic.rs b/src/test/run-pass/expr-if-generic.rs index 1ad0b006592..5d7730809d5 100644 --- a/src/test/run-pass/expr-if-generic.rs +++ b/src/test/run-pass/expr-if-generic.rs @@ -6,7 +6,7 @@ // Tests for if as expressions with dynamic type sizes type compare = fn@(T, T) -> bool; -fn test_generic(expected: T, not_expected: T, eq: compare) { +fn test_generic(expected: T, not_expected: T, eq: compare) { let actual: T = if true { expected } else { not_expected }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/fixed-point-bind-unique.rs b/src/test/run-pass/fixed-point-bind-unique.rs index 95ebd437b88..2c7ef7fb125 100644 --- a/src/test/run-pass/fixed-point-bind-unique.rs +++ b/src/test/run-pass/fixed-point-bind-unique.rs @@ -1,8 +1,8 @@ -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 4ad9b5090cc..cc57ba6a9af 100644 --- a/src/test/run-pass/fn-bare-spawn.rs +++ b/src/test/run-pass/fn-bare-spawn.rs @@ -1,6 +1,6 @@ // This is what the signature to spawn should look like with bare functions -fn spawn(val: T, f: extern fn(T)) { +fn spawn(val: T, f: extern fn(T)) { f(val); } diff --git a/src/test/run-pass/generic-alias-box.rs b/src/test/run-pass/generic-alias-box.rs index c273672f781..f140ad1b994 100644 --- a/src/test/run-pass/generic-alias-box.rs +++ b/src/test/run-pass/generic-alias-box.rs @@ -1,6 +1,6 @@ -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/generic-alias-unique.rs b/src/test/run-pass/generic-alias-unique.rs index 79285589766..9d3ac09de7c 100644 --- a/src/test/run-pass/generic-alias-unique.rs +++ b/src/test/run-pass/generic-alias-unique.rs @@ -1,6 +1,6 @@ -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/generic-box.rs b/src/test/run-pass/generic-box.rs index 3d871c896a8..fed97b99f8e 100644 --- a/src/test/run-pass/generic-box.rs +++ b/src/test/run-pass/generic-box.rs @@ -1,6 +1,6 @@ -fn box(x: {x: T, y: T, z: T}) -> @{x: T, y: T, z: T} { return @x; } +fn box(x: {x: T, y: T, z: T}) -> @{x: T, y: T, z: T} { return @x; } fn main() { let x: @{x: int, y: int, z: int} = box::({x: 1, y: 2, z: 3}); diff --git a/src/test/run-pass/generic-derived-type.rs b/src/test/run-pass/generic-derived-type.rs index cb406e85980..f190e72b648 100644 --- a/src/test/run-pass/generic-derived-type.rs +++ b/src/test/run-pass/generic-derived-type.rs @@ -1,8 +1,8 @@ -fn g(x: X) -> X { return x; } +fn g(x: X) -> X { return x; } -fn f(t: T) -> {a: T, b: T} { +fn f(t: T) -> {a: T, b: T} { type pair = {a: T, b: T}; let x: pair = {a: t, b: t}; diff --git a/src/test/run-pass/generic-drop-glue.rs b/src/test/run-pass/generic-drop-glue.rs index 15583f9904b..c6d16a4127c 100644 --- a/src/test/run-pass/generic-drop-glue.rs +++ b/src/test/run-pass/generic-drop-glue.rs @@ -1,5 +1,5 @@ -fn f(t: T) { let t1: T = t; } +fn f(t: T) { let t1: T = t; } fn main() { let x = {x: @10, y: @12}; f(x); } diff --git a/src/test/run-pass/generic-exterior-box.rs b/src/test/run-pass/generic-exterior-box.rs index c683da09bdf..ff2221aeefb 100644 --- a/src/test/run-pass/generic-exterior-box.rs +++ b/src/test/run-pass/generic-exterior-box.rs @@ -1,8 +1,8 @@ -type recbox = {x: @T}; +type recbox = {x: @T}; -fn reclift(t: T) -> recbox { return {x: @t}; } +fn reclift(t: T) -> recbox { return {x: @t}; } fn main() { let foo: int = 17; diff --git a/src/test/run-pass/generic-exterior-unique.rs b/src/test/run-pass/generic-exterior-unique.rs index 227bb7066c4..61860d36b5e 100644 --- a/src/test/run-pass/generic-exterior-unique.rs +++ b/src/test/run-pass/generic-exterior-unique.rs @@ -1,6 +1,6 @@ -type recbox = {x: ~T}; +type recbox = {x: ~T}; -fn reclift(t: T) -> recbox { return {x: ~t}; } +fn reclift(t: T) -> recbox { return {x: ~t}; } fn main() { let foo: int = 17; diff --git a/src/test/run-pass/generic-fn-infer.rs b/src/test/run-pass/generic-fn-infer.rs index b375752d1a1..c7696259ec2 100644 --- a/src/test/run-pass/generic-fn-infer.rs +++ b/src/test/run-pass/generic-fn-infer.rs @@ -4,6 +4,6 @@ // -*- rust -*- // Issue #45: infer type parameters in function applications -fn id(x: T) -> T { return x; } +fn id(x: T) -> T { return x; } fn main() { let x: int = 42; let y: int = id(x); assert (x == y); } diff --git a/src/test/run-pass/generic-fn-unique.rs b/src/test/run-pass/generic-fn-unique.rs index 7d54afd59eb..81fbd307d2a 100644 --- a/src/test/run-pass/generic-fn-unique.rs +++ b/src/test/run-pass/generic-fn-unique.rs @@ -1,4 +1,4 @@ -fn f(x: ~T) -> ~T { return x; } +fn f(x: ~T) -> ~T { return x; } fn main() { let x = f(~3); log(debug, *x); } diff --git a/src/test/run-pass/generic-fn.rs b/src/test/run-pass/generic-fn.rs index fae711ae3ad..c7a38940caf 100644 --- a/src/test/run-pass/generic-fn.rs +++ b/src/test/run-pass/generic-fn.rs @@ -2,7 +2,7 @@ // -*- rust -*- -fn id(x: T) -> T { return x; } +fn id(x: T) -> T { return x; } type triple = {x: int, y: int, z: int}; diff --git a/src/test/run-pass/generic-tup.rs b/src/test/run-pass/generic-tup.rs index b660592720c..1d37565be31 100644 --- a/src/test/run-pass/generic-tup.rs +++ b/src/test/run-pass/generic-tup.rs @@ -1,4 +1,4 @@ -fn get_third(t: (T, T, T)) -> T { let (_, _, x) = t; return x; } +fn get_third(t: (T, T, T)) -> T { let (_, _, x) = t; return x; } fn main() { log(debug, get_third((1, 2, 3))); diff --git a/src/test/run-pass/generic-unique.rs b/src/test/run-pass/generic-unique.rs index 0572257a877..21daeac2ef7 100644 --- a/src/test/run-pass/generic-unique.rs +++ b/src/test/run-pass/generic-unique.rs @@ -1,5 +1,5 @@ -fn box(x: {x: T, y: T, z: T}) -> ~{x: T, y: T, z: T} { return ~x; } +fn box(x: {x: T, y: T, z: T}) -> ~{x: T, y: T, z: T} { return ~x; } fn main() { let x: ~{x: int, y: int, z: int} = box::({x: 1, y: 2, z: 3}); diff --git a/src/test/run-pass/issue-2288.rs b/src/test/run-pass/issue-2288.rs index a01b55f50c6..f4d045bb444 100644 --- a/src/test/run-pass/issue-2288.rs +++ b/src/test/run-pass/issue-2288.rs @@ -1,19 +1,19 @@ -trait clam { +trait clam { fn chowder(y: A); } -struct foo : clam { +struct foo : clam { x: A, fn chowder(y: A) { } } -fn foo(b: A) -> foo { +fn foo(b: A) -> foo { foo { x: b } } -fn f(x: clam, a: A) { +fn f(x: clam, a: A) { x.chowder(a); } diff --git a/src/test/run-pass/issue-2311-2.rs b/src/test/run-pass/issue-2311-2.rs index 20c9b9ad947..ef3752d5fa7 100644 --- a/src/test/run-pass/issue-2311-2.rs +++ b/src/test/run-pass/issue-2311-2.rs @@ -1,12 +1,12 @@ -trait clam { } -struct foo { +trait clam { } +struct foo { x: A, fn bar>(c: C) -> B { fail; } } -fn foo(b: A) -> foo { +fn foo(b: A) -> foo { foo { x: b } diff --git a/src/test/run-pass/issue-2445-b.rs b/src/test/run-pass/issue-2445-b.rs index 2318691aebe..0b650286020 100644 --- a/src/test/run-pass/issue-2445-b.rs +++ b/src/test/run-pass/issue-2445-b.rs @@ -1,16 +1,16 @@ -struct c1 { +struct c1 { x: T, fn f1(x: int) { } } -fn c1(x: T) -> c1 { +fn c1(x: T) -> c1 { c1 { x: x } } -impl c1 { +impl c1 { fn f2(x: int) { } } diff --git a/src/test/run-pass/issue-2445.rs b/src/test/run-pass/issue-2445.rs index edb0fdf16ae..ae6cdf34e4d 100644 --- a/src/test/run-pass/issue-2445.rs +++ b/src/test/run-pass/issue-2445.rs @@ -1,17 +1,17 @@ use dvec::DVec; -struct c1 { +struct c1 { x: T, fn f1(x: T) {} } -fn c1(x: T) -> c1 { +fn c1(x: T) -> c1 { c1 { x: x } } -impl c1 { +impl c1 { fn f2(x: T) {} } diff --git a/src/test/run-pass/issue-2550.rs b/src/test/run-pass/issue-2550.rs index 989818ef594..496fe3a4798 100644 --- a/src/test/run-pass/issue-2550.rs +++ b/src/test/run-pass/issue-2550.rs @@ -8,7 +8,7 @@ fn C(x: uint) -> C { } } -fn f(_x: T) { +fn f(_x: T) { } #[deny(non_implicitly_copyable_typarams)] diff --git a/src/test/run-pass/issue-2611.rs b/src/test/run-pass/issue-2611.rs index 94456ecb25b..0d5c244abcb 100644 --- a/src/test/run-pass/issue-2611.rs +++ b/src/test/run-pass/issue-2611.rs @@ -1,11 +1,11 @@ use iter::BaseIter; trait FlatMapToVec { - fn flat_map_to_vec>(op: fn(A) -> IB) -> ~[B]; + fn flat_map_to_vec>(op: fn(A) -> IB) -> ~[B]; } -impl BaseIter: FlatMapToVec { - fn flat_map_to_vec>(op: fn(A) -> IB) -> ~[B] { +impl BaseIter: FlatMapToVec { + fn flat_map_to_vec>(op: fn(A) -> IB) -> ~[B] { iter::flat_map_to_vec(self, op) } } diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index 856e8c2c174..d878d3fcf4b 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -15,13 +15,13 @@ mod pipes { pure fn ne(&&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 = unsafe::transmute(~{ mut state: empty, mut blocked_task: None::, @@ -55,7 +55,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(); @@ -81,7 +81,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 { @@ -102,7 +102,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 => { @@ -119,7 +119,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 => { @@ -136,7 +136,7 @@ mod pipes { } } - struct send_packet { + struct send_packet { mut p: Option<*packet>, drop { if self.p != None { @@ -152,13 +152,13 @@ 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>, drop { if self.p != None { @@ -174,13 +174,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 a440d4f05d4..30a806d165d 100644 --- a/src/test/run-pass/issue-2734.rs +++ b/src/test/run-pass/issue-2734.rs @@ -1,7 +1,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 81fbae57105..0c9795cc5c3 100644 --- a/src/test/run-pass/issue-2735.rs +++ b/src/test/run-pass/issue-2735.rs @@ -1,7 +1,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-2904.rs b/src/test/run-pass/issue-2904.rs index b4ae83bb702..741235554ac 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -45,7 +45,7 @@ fn square_from_char(c: char) -> square { } } -fn read_board_grid(+in: rdr) -> ~[~[square]] { +fn read_board_grid(+in: rdr) -> ~[~[square]] { let in = 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 0d24f72cb23..98cfaded04a 100644 --- a/src/test/run-pass/issue-2930.rs +++ b/src/test/run-pass/issue-2930.rs @@ -1,5 +1,5 @@ proto! stream ( - stream:send { + stream:send { send(T) -> stream } ) diff --git a/src/test/run-pass/issue-3149.rs b/src/test/run-pass/issue-3149.rs index fe0f646e07d..47d72c53e3b 100644 --- a/src/test/run-pass/issue-3149.rs +++ b/src/test/run-pass/issue-3149.rs @@ -1,4 +1,4 @@ -pure fn Matrix4(m11: T, m12: T, m13: T, m14: T, +pure fn 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, m41: T, m42: T, m43: T, m44: T) @@ -12,7 +12,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/issue-333.rs b/src/test/run-pass/issue-333.rs index 3452beaf7f4..94829fdb7a8 100644 --- a/src/test/run-pass/issue-333.rs +++ b/src/test/run-pass/issue-333.rs @@ -1,5 +1,5 @@ -fn quux(x: T) -> T { let f = id::; return f(x); } +fn quux(x: T) -> T { let f = id::; return f(x); } -fn id(x: T) -> T { return x; } +fn id(x: T) -> T { return x; } fn main() { assert (quux(10) == 10); } diff --git a/src/test/run-pass/ivec-add.rs b/src/test/run-pass/ivec-add.rs index 652336145f6..9464b6923a9 100644 --- a/src/test/run-pass/ivec-add.rs +++ b/src/test/run-pass/ivec-add.rs @@ -1,4 +1,4 @@ -fn double(a: T) -> ~[T] { return ~[a] + ~[a]; } +fn double(a: T) -> ~[T] { return ~[a] + ~[a]; } fn double_int(a: int) -> ~[int] { return ~[a] + ~[a]; } diff --git a/src/test/run-pass/kindck-owned-trait-contains-1.rs b/src/test/run-pass/kindck-owned-trait-contains-1.rs index 7de63c20e0c..afbc2561d15 100644 --- a/src/test/run-pass/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/kindck-owned-trait-contains-1.rs @@ -1,10 +1,10 @@ trait repeat { fn get() -> A; } -impl @A: repeat { +impl @A: repeat { fn get() -> A { *self } } -fn repeater(v: @A) -> repeat { +fn repeater(v: @A) -> repeat { // Note: owned kind is not necessary as A appears in the trait type v as repeat:: // No } diff --git a/src/test/run-pass/monad.rs b/src/test/run-pass/monad.rs index d3f8c668edb..36eea6e89d5 100644 --- a/src/test/run-pass/monad.rs +++ b/src/test/run-pass/monad.rs @@ -1,9 +1,9 @@ trait vec_monad { - fn bind(f: fn(A) -> ~[B]) -> ~[B]; + fn bind(f: fn(A) -> ~[B]) -> ~[B]; } impl ~[A]: vec_monad { - fn bind(f: fn(A) -> ~[B]) -> ~[B] { + fn bind(f: fn(A) -> ~[B]) -> ~[B] { let mut r = ~[]; for self.each |elt| { r += f(elt); } r diff --git a/src/test/run-pass/newtype-polymorphic.rs b/src/test/run-pass/newtype-polymorphic.rs index fa6b0b86012..18f6557fdac 100644 --- a/src/test/run-pass/newtype-polymorphic.rs +++ b/src/test/run-pass/newtype-polymorphic.rs @@ -1,8 +1,8 @@ enum myvec = ~[X]; -fn myvec_deref(mv: myvec) -> ~[X] { return *mv; } +fn myvec_deref(mv: myvec) -> ~[X] { return *mv; } -fn myvec_elt(mv: myvec) -> X { return mv[0]; } +fn myvec_elt(mv: myvec) -> X { return mv[0]; } fn main() { let mv = myvec(~[1, 2, 3]); diff --git a/src/test/run-pass/non-boolean-pure-fns.rs b/src/test/run-pass/non-boolean-pure-fns.rs index 600afd97a69..9b8bbfd9438 100644 --- a/src/test/run-pass/non-boolean-pure-fns.rs +++ b/src/test/run-pass/non-boolean-pure-fns.rs @@ -2,15 +2,15 @@ use std; use std::list::*; -pure fn pure_length_go(ls: @List, acc: uint) -> uint { +pure fn pure_length_go(ls: @List, acc: uint) -> uint { match *ls { Nil => { acc } Cons(_, tl) => { pure_length_go(tl, acc + 1u) } } } -pure fn pure_length(ls: @List) -> uint { pure_length_go(ls, 0u) } +pure fn pure_length(ls: @List) -> uint { pure_length_go(ls, 0u) } -pure fn nonempty_list(ls: @List) -> bool { pure_length(ls) > 0u } +pure fn nonempty_list(ls: @List) -> bool { pure_length(ls) > 0u } -fn safe_head(ls: @List) -> T { +fn safe_head(ls: @List) -> T { assert is_not_empty(ls); return head(ls); } diff --git a/src/test/run-pass/pipe-bank-proto.rs b/src/test/run-pass/pipe-bank-proto.rs index fc76487b436..f484e635e49 100644 --- a/src/test/run-pass/pipe-bank-proto.rs +++ b/src/test/run-pass/pipe-bank-proto.rs @@ -36,7 +36,7 @@ macro_rules! move_it ( { $x:expr } => { unsafe { let y <- *ptr::addr_of($x); y } } ) -fn switch(+endp: pipes::RecvPacket, +fn switch(+endp: pipes::RecvPacket, f: fn(+Option) -> U) -> U { f(pipes::try_recv(endp)) } diff --git a/src/test/run-pass/pipe-select.rs b/src/test/run-pass/pipe-select.rs index 7f36dbe546c..783febf942c 100644 --- a/src/test/run-pass/pipe-select.rs +++ b/src/test/run-pass/pipe-select.rs @@ -14,7 +14,7 @@ proto! oneshot ( ) proto! stream ( - stream:send { + stream:send { send(T) -> stream } ) diff --git a/src/test/run-pass/resource-generic.rs b/src/test/run-pass/resource-generic.rs index 1d01de738b5..392d68d8763 100644 --- a/src/test/run-pass/resource-generic.rs +++ b/src/test/run-pass/resource-generic.rs @@ -1,9 +1,9 @@ -struct finish { +struct finish { arg: {val: T, fin: extern fn(T)}, drop { self.arg.fin(self.arg.val); } } -fn finish(arg: {val: T, fin: extern fn(T)}) -> finish { +fn finish(arg: {val: T, fin: extern fn(T)}) -> finish { finish { arg: arg } diff --git a/src/test/run-pass/ret-none.rs b/src/test/run-pass/ret-none.rs index 1533bb9ef09..069618aaa05 100644 --- a/src/test/run-pass/ret-none.rs +++ b/src/test/run-pass/ret-none.rs @@ -2,6 +2,6 @@ enum option { none, some(T), } -fn f() -> option { return none; } +fn f() -> option { return none; } fn main() { f::(); } diff --git a/src/test/run-pass/send-type-inference.rs b/src/test/run-pass/send-type-inference.rs index 67a1b618413..c642670afbc 100644 --- a/src/test/run-pass/send-type-inference.rs +++ b/src/test/run-pass/send-type-inference.rs @@ -4,9 +4,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/sendfn-deep-copy.rs b/src/test/run-pass/sendfn-deep-copy.rs index d5ee2f1aaec..d089eb873bd 100644 --- a/src/test/run-pass/sendfn-deep-copy.rs +++ b/src/test/run-pass/sendfn-deep-copy.rs @@ -5,7 +5,7 @@ use comm::send; fn main() { test05(); } -fn mk_counter() -> fn~(A) -> (A,uint) { +fn mk_counter() -> fn~(A) -> (A,uint) { // The only reason that the counter is generic is so that it closes // over both a type descriptor and some data. let v = ~[mut 0u]; diff --git a/src/test/run-pass/sendfn-generic-fn.rs b/src/test/run-pass/sendfn-generic-fn.rs index eece50e7570..2fcc6adfce3 100644 --- a/src/test/run-pass/sendfn-generic-fn.rs +++ b/src/test/run-pass/sendfn-generic-fn.rs @@ -7,7 +7,7 @@ fn main() { test05(); } type pair = { a: A, b: B }; -fn make_generic_record(a: A, b: B) -> pair { +fn make_generic_record(a: A, b: B) -> pair { return {a: a, b: b}; } @@ -23,7 +23,7 @@ fn test05_start(&&f: fn~(&&float, &&~str) -> pair) { assert q.b == ~"Ho"; } -fn spawn(f: extern fn(fn~(A,B)->pair)) { +fn spawn(f: extern fn(fn~(A,B)->pair)) { let arg = fn~(a: A, b: B) -> pair { return make_generic_record(a, b); }; diff --git a/src/test/run-pass/static-impl.rs b/src/test/run-pass/static-impl.rs index f338dcef577..e29f3fdd5e4 100644 --- a/src/test/run-pass/static-impl.rs +++ b/src/test/run-pass/static-impl.rs @@ -28,13 +28,13 @@ impl uint: uint_utils { trait vec_utils { fn length_() -> uint; fn iter_(f: fn(T)); - fn map_(f: fn(T) -> U) -> ~[U]; + fn map_(f: fn(T) -> U) -> ~[U]; } impl ~[T]: vec_utils { fn length_() -> uint { vec::len(self) } fn iter_(f: fn(T)) { for self.each |x| { f(x); } } - fn map_(f: fn(T) -> U) -> ~[U] { + fn map_(f: fn(T) -> U) -> ~[U] { let mut r = ~[]; for self.each |elt| { r += ~[f(elt)]; } r diff --git a/src/test/run-pass/static-method-test.rs b/src/test/run-pass/static-method-test.rs index b8832edbad9..1fc930a688e 100644 --- a/src/test/run-pass/static-method-test.rs +++ b/src/test/run-pass/static-method-test.rs @@ -5,7 +5,7 @@ trait bool_like { static fn select(b: self, +x1: A, +x2: A) -> A; } -fn andand(x1: T, x2: T) -> T { +fn andand(x1: T, x2: T) -> T { select(x1, x2, x1) } diff --git a/src/test/run-pass/trait-generic.rs b/src/test/run-pass/trait-generic.rs index 95709971e03..4c7d0415d85 100644 --- a/src/test/run-pass/trait-generic.rs +++ b/src/test/run-pass/trait-generic.rs @@ -12,10 +12,10 @@ impl (): to_str { } trait map { - fn map(f: fn(T) -> U) -> ~[U]; + fn map(f: fn(T) -> U) -> ~[U]; } impl ~[T]: map { - fn map(f: fn(T) -> U) -> ~[U] { + fn map(f: fn(T) -> U) -> ~[U] { let mut r = ~[]; for self.each |x| { r += ~[f(x)]; } r diff --git a/src/test/run-pass/type-param-constraints.rs b/src/test/run-pass/type-param-constraints.rs index f9174598cce..f96c2bede61 100644 --- a/src/test/run-pass/type-param-constraints.rs +++ b/src/test/run-pass/type-param-constraints.rs @@ -1,6 +1,6 @@ fn p_foo(pinned: T) { } -fn s_foo(shared: T) { } -fn u_foo(unique: T) { } +fn s_foo(shared: 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 5c7e2228ab4..18c3db591f6 100644 --- a/src/test/run-pass/uniq-cc-generic.rs +++ b/src/test/run-pass/uniq-cc-generic.rs @@ -8,7 +8,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-assign-generic.rs b/src/test/run-pass/unique-assign-generic.rs index 8addb1acaf2..8a36cbd7c7d 100644 --- a/src/test/run-pass/unique-assign-generic.rs +++ b/src/test/run-pass/unique-assign-generic.rs @@ -1,4 +1,4 @@ -fn f(t: T) -> T { +fn f(t: T) -> T { let t1 = t; t1 } diff --git a/src/test/run-pass/unique-generic-assign.rs b/src/test/run-pass/unique-generic-assign.rs index f8fd6f62c26..a299e88c344 100644 --- a/src/test/run-pass/unique-generic-assign.rs +++ b/src/test/run-pass/unique-generic-assign.rs @@ -1,6 +1,6 @@ // Issue #976 -fn f(x: ~T) { +fn f(x: ~T) { let _x2 = x; } fn main() { } diff --git a/src/test/run-pass/unique-kinds.rs b/src/test/run-pass/unique-kinds.rs index c22b529910a..2f6c94f3f34 100644 --- a/src/test/run-pass/unique-kinds.rs +++ b/src/test/run-pass/unique-kinds.rs @@ -2,11 +2,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; } @@ -20,11 +20,11 @@ fn sendable() { fn copyable() { - 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; }