diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-10-02 11:37:37 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-10-02 14:31:39 -0700 |
| commit | f78cdcb6364cf938bfeb71da0c7eca62e257d537 (patch) | |
| tree | cb3f93224e4757b5f77709e576ca6f24ce0981ec /src | |
| parent | a5042d58ee86af13b6910fa1884b7c1fe9423ae7 (diff) | |
| download | rust-f78cdcb6364cf938bfeb71da0c7eca62e257d537.tar.gz rust-f78cdcb6364cf938bfeb71da0c7eca62e257d537.zip | |
Removing explicit uses of + mode
This removes most explicit uses of the + argument mode. Pending a snapshot, I had to remove the forbid(deprecated_modes) pragma from a bunch of files. I'll put it back! + mode still has to be used in a few places for functions that get moved (see task.rs) The changes outside core and std are due to the to_bytes trait and making the compiler (with legacy modes on) agree with the libraries (with legacy modes off) about modes.
Diffstat (limited to 'src')
38 files changed, 282 insertions, 276 deletions
diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 6936de2bccb..7d410c0337a 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -1,7 +1,7 @@ //! Managed vectors // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; use cast::transmute; @@ -48,7 +48,7 @@ pub pure fn capacity<T>(v: @[const T]) -> uint { */ #[inline(always)] pub pure fn build_sized<A>(size: uint, - builder: &fn(push: pure fn(+v: A))) -> @[A] { + builder: &fn(push: pure fn(v: A))) -> @[A] { let mut vec: @[const A] = @[]; unsafe { raw::reserve(&mut vec, size); } builder(|+x| unsafe { raw::push(&mut vec, move x) }); @@ -66,7 +66,7 @@ pub pure fn build_sized<A>(size: uint, * onto the vector being constructed. */ #[inline(always)] -pub pure fn build<A>(builder: &fn(push: pure fn(+v: A))) -> @[A] { +pub pure fn build<A>(builder: &fn(push: pure fn(v: A))) -> @[A] { build_sized(4, builder) } @@ -83,8 +83,8 @@ pub pure fn build<A>(builder: &fn(push: pure fn(+v: A))) -> @[A] { * onto the vector being constructed. */ #[inline(always)] -pub pure fn build_sized_opt<A>(+size: Option<uint>, - builder: &fn(push: pure fn(+v: A))) -> @[A] { +pub pure fn build_sized_opt<A>(size: Option<uint>, + builder: &fn(push: pure fn(v: A))) -> @[A] { build_sized(size.get_default(4), builder) } @@ -126,7 +126,7 @@ pub pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value `t`. */ -pub pure fn from_elem<T: Copy>(n_elts: uint, +t: T) -> @[T] { +pub pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] { do build_sized(n_elts) |push| { let mut i: uint = 0u; while i < n_elts { push(copy t); i += 1u; } @@ -166,7 +166,7 @@ pub mod raw { } #[inline(always)] - pub unsafe fn push<T>(v: &mut @[const T], +initval: T) { + pub unsafe fn push<T>(v: &mut @[const T], initval: T) { let repr: **VecRepr = ::cast::reinterpret_cast(&v); let fill = (**repr).unboxed.fill; if (**repr).unboxed.alloc > fill { @@ -178,7 +178,7 @@ pub mod raw { } // This doesn't bother to make sure we have space. #[inline(always)] // really pretty please - pub unsafe fn push_fast<T>(v: &mut @[const T], +initval: T) { + pub unsafe fn push_fast<T>(v: &mut @[const T], initval: T) { let repr: **VecRepr = ::cast::reinterpret_cast(&v); let fill = (**repr).unboxed.fill; (**repr).unboxed.fill += sys::size_of::<T>(); @@ -187,7 +187,7 @@ pub mod raw { rusti::move_val_init(*p, move initval); } - pub unsafe fn push_slow<T>(v: &mut @[const T], +initval: T) { + pub unsafe fn push_slow<T>(v: &mut @[const T], initval: T) { reserve_at_least(v, v.len() + 1u); push_fast(v, move initval); } diff --git a/src/libcore/cast.rs b/src/libcore/cast.rs index 21f5861b89e..f4f0d7b6104 100644 --- a/src/libcore/cast.rs +++ b/src/libcore/cast.rs @@ -21,7 +21,7 @@ pub unsafe fn reinterpret_cast<T, U>(src: &T) -> U { * reinterpret_cast on managed pointer types. */ #[inline(always)] -pub unsafe fn forget<T>(+thing: T) { rusti::forget(move thing); } +pub unsafe fn forget<T>(thing: T) { rusti::forget(move thing); } /** * Force-increment the reference count on a shared box. If used @@ -29,7 +29,7 @@ pub unsafe fn forget<T>(+thing: T) { rusti::forget(move thing); } * and/or reinterpret_cast when such calls would otherwise scramble a box's * reference count */ -pub unsafe fn bump_box_refcount<T>(+t: @T) { forget(move t); } +pub unsafe fn bump_box_refcount<T>(t: @T) { forget(move t); } /** * Transform a value of one type into a value of another type. @@ -40,7 +40,7 @@ pub unsafe fn bump_box_refcount<T>(+t: @T) { forget(move t); } * assert transmute("L") == ~[76u8, 0u8]; */ #[inline(always)] -pub unsafe fn transmute<L, G>(+thing: L) -> G { +pub unsafe fn transmute<L, G>(thing: L) -> G { let newthing: G = reinterpret_cast(&thing); forget(move thing); move newthing @@ -48,33 +48,33 @@ pub unsafe fn transmute<L, G>(+thing: L) -> G { /// Coerce an immutable reference to be mutable. #[inline(always)] -pub unsafe fn transmute_mut<T>(+ptr: &a/T) -> &a/mut T { transmute(move ptr) } +pub unsafe fn transmute_mut<T>(ptr: &a/T) -> &a/mut T { transmute(move ptr) } /// Coerce a mutable reference to be immutable. #[inline(always)] -pub unsafe fn transmute_immut<T>(+ptr: &a/mut T) -> &a/T { +pub unsafe fn transmute_immut<T>(ptr: &a/mut T) -> &a/T { transmute(move ptr) } /// Coerce a borrowed pointer to have an arbitrary associated region. #[inline(always)] -pub unsafe fn transmute_region<T>(+ptr: &a/T) -> &b/T { transmute(move ptr) } +pub unsafe fn transmute_region<T>(ptr: &a/T) -> &b/T { transmute(move ptr) } /// Coerce an immutable reference to be mutable. #[inline(always)] -pub unsafe fn transmute_mut_unsafe<T>(+ptr: *const T) -> *mut T { +pub unsafe fn transmute_mut_unsafe<T>(ptr: *const T) -> *mut T { transmute(ptr) } /// Coerce an immutable reference to be mutable. #[inline(always)] -pub unsafe fn transmute_immut_unsafe<T>(+ptr: *const T) -> *T { +pub unsafe fn transmute_immut_unsafe<T>(ptr: *const T) -> *T { transmute(ptr) } /// Coerce a borrowed mutable pointer to have an arbitrary associated region. #[inline(always)] -pub unsafe fn transmute_mut_region<T>(+ptr: &a/mut T) -> &b/mut T { +pub unsafe fn transmute_mut_region<T>(ptr: &a/mut T) -> &b/mut T { transmute(move ptr) } diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index ff9f9498a98..64c38d13e49 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -32,8 +32,8 @@ will once again be the preferred module for intertask communication. */ -// NB: transitionary, de-mode-ing. -#[warn(deprecated_mode)]; +// NB: transitionary, de-mode-ing +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; use either::Either; @@ -75,7 +75,7 @@ pub fn Port<T: Send>() -> Port<T> { impl<T: Send> Port<T> { fn chan() -> Chan<T> { Chan(self) } - fn send(+v: T) { self.chan().send(move v) } + fn send(v: T) { self.chan().send(move v) } fn recv() -> T { recv(self) } fn peek() -> bool { peek(self) } @@ -84,7 +84,7 @@ impl<T: Send> Port<T> { impl<T: Send> Chan<T> { fn chan() -> Chan<T> { self } - fn send(+v: T) { send(self, move v) } + fn send(v: T) { send(self, move v) } fn recv() -> T { recv_chan(self) } fn peek() -> bool { peek_chan(self) } @@ -174,7 +174,7 @@ pub fn Chan<T: Send>(&&p: Port<T>) -> Chan<T> { * Sends data over a channel. The sent data is moved into the channel, * whereupon the caller loses access to it. */ -pub fn send<T: Send>(ch: Chan<T>, +data: T) { +pub fn send<T: Send>(ch: Chan<T>, data: T) { let Chan_(p) = ch; let data_ptr = ptr::addr_of(&data) as *(); let res = rustrt::rust_port_id_send(p, data_ptr); diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 4e08dd4c2f3..17ddd6ea73b 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -9,7 +9,7 @@ Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate. */ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; type DListLink<T> = Option<DListNode<T>>; @@ -80,7 +80,7 @@ impl<T> DListNode<T> { } /// Creates a new dlist node with the given data. -pure fn new_dlist_node<T>(+data: T) -> DListNode<T> { +pure fn new_dlist_node<T>(data: T) -> DListNode<T> { DListNode(@{data: move data, mut linked: false, mut prev: None, mut next: None}) } @@ -91,13 +91,13 @@ pure fn DList<T>() -> DList<T> { } /// Creates a new dlist with a single element -pub pure fn from_elem<T>(+data: T) -> DList<T> { +pub pure fn from_elem<T>(data: T) -> DList<T> { let list = DList(); unsafe { list.push(move data); } list } -pub fn from_vec<T: Copy>(+vec: &[T]) -> DList<T> { +pub fn from_vec<T: Copy>(vec: &[T]) -> DList<T> { do vec::foldl(DList(), vec) |list,data| { list.push(*data); // Iterating left-to-right -- add newly to the tail. list @@ -115,7 +115,7 @@ fn concat<T>(lists: DList<DList<T>>) -> DList<T> { } priv impl<T> DList<T> { - pure fn new_link(+data: T) -> DListLink<T> { + pure fn new_link(data: T) -> DListLink<T> { Some(DListNode(@{data: move data, mut linked: true, mut prev: None, mut next: None})) } @@ -142,7 +142,7 @@ priv impl<T> DList<T> { // Link two nodes together. If either of them are 'none', also sets // the head and/or tail pointers appropriately. #[inline(always)] - fn link(+before: DListLink<T>, +after: DListLink<T>) { + fn link(before: DListLink<T>, after: DListLink<T>) { match before { Some(neighbour) => neighbour.next = after, None => self.hd = after @@ -163,12 +163,12 @@ priv impl<T> DList<T> { self.size -= 1; } - fn add_head(+nobe: DListLink<T>) { + fn add_head(nobe: DListLink<T>) { self.link(nobe, self.hd); // Might set tail too. self.hd = nobe; self.size += 1; } - fn add_tail(+nobe: DListLink<T>) { + fn add_tail(nobe: DListLink<T>) { self.link(self.tl, nobe); // Might set head too. self.tl = nobe; self.size += 1; @@ -198,27 +198,27 @@ impl<T> DList<T> { pure fn is_not_empty() -> bool { self.len() != 0 } /// Add data to the head of the list. O(1). - fn push_head(+data: T) { + fn push_head(data: T) { self.add_head(self.new_link(move data)); } /** * Add data to the head of the list, and get the new containing * node. O(1). */ - fn push_head_n(+data: T) -> DListNode<T> { + fn push_head_n(data: T) -> DListNode<T> { let mut nobe = self.new_link(move data); self.add_head(nobe); option::get(&nobe) } /// Add data to the tail of the list. O(1). - fn push(+data: T) { + fn push(data: T) { self.add_tail(self.new_link(move data)); } /** * Add data to the tail of the list, and get the new containing * node. O(1). */ - fn push_n(+data: T) -> DListNode<T> { + fn push_n(data: T) -> DListNode<T> { let mut nobe = self.new_link(move data); self.add_tail(nobe); option::get(&nobe) @@ -227,7 +227,7 @@ impl<T> DList<T> { * Insert data into the middle of the list, left of the given node. * O(1). */ - fn insert_before(+data: T, neighbour: DListNode<T>) { + fn insert_before(data: T, neighbour: DListNode<T>) { self.insert_left(self.new_link(move data), neighbour); } /** @@ -242,7 +242,7 @@ impl<T> DList<T> { * Insert data in the middle of the list, left of the given node, * and get its containing node. O(1). */ - fn insert_before_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> { + fn insert_before_n(data: T, neighbour: DListNode<T>) -> DListNode<T> { let mut nobe = self.new_link(move data); self.insert_left(nobe, neighbour); option::get(&nobe) @@ -251,7 +251,7 @@ impl<T> DList<T> { * Insert data into the middle of the list, right of the given node. * O(1). */ - fn insert_after(+data: T, neighbour: DListNode<T>) { + fn insert_after(data: T, neighbour: DListNode<T>) { self.insert_right(neighbour, self.new_link(move data)); } /** @@ -266,7 +266,7 @@ impl<T> DList<T> { * Insert data in the middle of the list, right of the given node, * and get its containing node. O(1). */ - fn insert_after_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> { + fn insert_after_n(data: T, neighbour: DListNode<T>) -> DListNode<T> { let mut nobe = self.new_link(move data); self.insert_right(neighbour, nobe); option::get(&nobe) diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index 3ce5a7153fd..a2a70908797 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -10,7 +10,7 @@ Note that recursive use is not permitted. */ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; use cast::reinterpret_cast; @@ -61,17 +61,17 @@ pub fn DVec<A>() -> DVec<A> { } /// Creates a new dvec with a single element -pub fn from_elem<A>(+e: A) -> DVec<A> { +pub fn from_elem<A>(e: A) -> DVec<A> { DVec_({mut data: ~[move e]}) } /// Creates a new dvec with the contents of a vector -pub fn from_vec<A>(+v: ~[A]) -> DVec<A> { +pub fn from_vec<A>(v: ~[A]) -> DVec<A> { DVec_({mut data: move v}) } /// Consumes the vector and returns its contents -pub fn unwrap<A>(+d: DVec<A>) -> ~[A] { +pub fn unwrap<A>(d: DVec<A>) -> ~[A] { let DVec_({data: v}) <- d; move v } @@ -87,7 +87,7 @@ priv impl<A> DVec<A> { } #[inline(always)] - fn check_out<B>(f: &fn(+v: ~[A]) -> B) -> B { + fn check_out<B>(f: &fn(v: ~[A]) -> B) -> B { unsafe { let mut data = cast::reinterpret_cast(&null::<()>()); data <-> self.data; @@ -98,7 +98,7 @@ priv impl<A> DVec<A> { } #[inline(always)] - fn give_back(+data: ~[A]) { + fn give_back(data: ~[A]) { unsafe { self.data = move data; } @@ -120,7 +120,7 @@ impl<A> DVec<A> { * and return a new vector to replace it with. */ #[inline(always)] - fn swap(f: &fn(+v: ~[A]) -> ~[A]) { + fn swap(f: &fn(v: ~[A]) -> ~[A]) { self.check_out(|v| self.give_back(f(move v))) } @@ -130,7 +130,7 @@ impl<A> DVec<A> { * and return a new vector to replace it with. */ #[inline(always)] - fn swap_mut(f: &fn(+v: ~[mut A]) -> ~[mut A]) { + fn swap_mut(f: &fn(v: ~[mut A]) -> ~[mut A]) { do self.swap |v| { vec::from_mut(f(vec::to_mut(move v))) } @@ -148,7 +148,7 @@ impl<A> DVec<A> { } /// Overwrite the current contents - fn set(+w: ~[A]) { + fn set(w: ~[A]) { self.check_not_borrowed(); self.data <- w; } @@ -164,7 +164,7 @@ impl<A> DVec<A> { } /// Insert a single item at the front of the list - fn unshift(+t: A) { + fn unshift(t: A) { unsafe { let mut data = cast::reinterpret_cast(&null::<()>()); data <-> self.data; @@ -178,7 +178,7 @@ impl<A> DVec<A> { } /// Append a single item to the end of the list - fn push(+t: A) { + fn push(t: A) { self.check_not_borrowed(); self.data.push(move t); } @@ -295,7 +295,7 @@ impl<A: Copy> DVec<A> { } /// Overwrites the contents of the element at `idx` with `a` - fn set_elt(idx: uint, +a: A) { + fn set_elt(idx: uint, a: A) { self.check_not_borrowed(); self.data[idx] = a; } @@ -305,7 +305,7 @@ impl<A: Copy> DVec<A> { * growing the vector if necessary. New elements will be initialized * with `initval` */ - fn grow_set_elt(idx: uint, initval: &A, +val: A) { + fn grow_set_elt(idx: uint, initval: &A, val: A) { do self.swap |v| { let mut v = move v; v.grow_set(idx, initval, val); @@ -354,7 +354,7 @@ impl<A: Copy> DVec<A> { } impl<A:Copy> DVec<A>: Index<uint,A> { - pure fn index(+idx: uint) -> A { + pure fn index(idx: uint) -> A { self.get_elt(idx) } } diff --git a/src/libcore/either.rs b/src/libcore/either.rs index dd3bcdfdf88..c64cd25e481 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; //! A type that represents one of two alternatives @@ -114,7 +114,8 @@ pub pure fn is_right<T, U>(eith: &Either<T, U>) -> bool { match *eith { Right(_) => true, _ => false } } -pub pure fn unwrap_left<T,U>(+eith: Either<T,U>) -> T { +// tjc: fix the next two after a snapshot +pub pure fn unwrap_left<T,U>(eith: Either<T,U>) -> T { //! Retrieves the value in the left branch. Fails if the either is Right. match move eith { @@ -122,7 +123,7 @@ pub pure fn unwrap_left<T,U>(+eith: Either<T,U>) -> T { } } -pub pure fn unwrap_right<T,U>(+eith: Either<T,U>) -> U { +pub pure fn unwrap_right<T,U>(eith: Either<T,U>) -> U { //! Retrieves the value in the right branch. Fails if the either is Left. match move eith { diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs index 25f92e61726..e10ff4bac71 100644 --- a/src/libcore/extfmt.rs +++ b/src/libcore/extfmt.rs @@ -87,7 +87,7 @@ mod ct { let mut pieces: ~[Piece] = ~[]; let lim = str::len(s); let mut buf = ~""; - fn flush_buf(+buf: ~str, pieces: &mut ~[Piece]) -> ~str { + fn flush_buf(buf: ~str, pieces: &mut ~[Piece]) -> ~str { if buf.len() > 0 { let piece = PieceString(move buf); pieces.push(move piece); @@ -323,7 +323,7 @@ mod rt { let mut s = str::from_char(c); return unsafe { pad(cv, s, PadNozero) }; } - pure fn conv_str(cv: Conv, +s: &str) -> ~str { + pure fn conv_str(cv: Conv, s: &str) -> ~str { // For strings, precision is the maximum characters // displayed let mut unpadded = match cv.precision { @@ -405,7 +405,7 @@ mod rt { pure fn ne(other: &PadMode) -> bool { !self.eq(other) } } - fn pad(cv: Conv, +s: ~str, mode: PadMode) -> ~str { + fn pad(cv: Conv, s: ~str, mode: PadMode) -> ~str { let mut s = move s; // sadtimes let uwidth : uint = match cv.width { CountImplied => return s, @@ -518,7 +518,7 @@ mod rt2 { let mut s = str::from_char(c); return unsafe { pad(cv, s, PadNozero) }; } - pure fn conv_str(cv: Conv, +s: &str) -> ~str { + pure fn conv_str(cv: Conv, s: &str) -> ~str { // For strings, precision is the maximum characters // displayed let mut unpadded = match cv.precision { @@ -600,7 +600,7 @@ mod rt2 { pure fn ne(other: &PadMode) -> bool { !self.eq(other) } } - fn pad(cv: Conv, +s: ~str, mode: PadMode) -> ~str { + fn pad(cv: Conv, s: ~str, mode: PadMode) -> ~str { let mut s = move s; // sadtimes let uwidth : uint = match cv.width { CountImplied => return s, diff --git a/src/libcore/future.rs b/src/libcore/future.rs index db311ea3e82..11b6a2c0135 100644 --- a/src/libcore/future.rs +++ b/src/libcore/future.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; /*! @@ -55,7 +55,7 @@ impl<A> Future<A> { } } -pub fn from_value<A>(+val: A) -> Future<A> { +pub fn from_value<A>(val: A) -> Future<A> { /*! * Create a future from a value * @@ -66,7 +66,7 @@ pub fn from_value<A>(+val: A) -> Future<A> { Future {state: Forced(~(move val))} } -pub fn from_port<A:Send>(+port: future_pipe::client::waiting<A>) -> +pub fn from_port<A:Send>(port: future_pipe::client::waiting<A>) -> Future<A> { /*! * Create a future from a port diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index ddd26205000..6942d38d5d3 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; use T = inst::T; @@ -231,7 +231,7 @@ fn test_to_str() { #[test] fn test_interfaces() { - fn test<U:num::Num cmp::Eq>(+ten: U) { + fn test<U:num::Num cmp::Eq>(ten: U) { assert (ten.to_int() == 10); let two: U = from_int(2); diff --git a/src/libcore/io.rs b/src/libcore/io.rs index f8f644a17ab..2efc96933da 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -813,7 +813,7 @@ pub mod fsync { } } - pub fn Res<t: Copy>(+arg: Arg<t>) -> Res<t>{ + pub fn Res<t: Copy>(arg: Arg<t>) -> Res<t>{ Res { arg: move arg } @@ -822,17 +822,17 @@ pub mod fsync { pub type Arg<t> = { val: t, opt_level: Option<Level>, - fsync_fn: fn@(+f: t, Level) -> int + fsync_fn: fn@(f: t, Level) -> int }; // fsync file after executing blk // FIXME (#2004) find better way to create resources within lifetime of // outer res pub fn FILE_res_sync(file: &FILERes, opt_level: Option<Level>, - blk: fn(+v: Res<*libc::FILE>)) { + blk: fn(v: Res<*libc::FILE>)) { blk(move Res({ val: file.f, opt_level: opt_level, - fsync_fn: fn@(+file: *libc::FILE, l: Level) -> int { + fsync_fn: fn@(file: *libc::FILE, l: Level) -> int { return os::fsync_fd(libc::fileno(file), l) as int; } })); @@ -840,10 +840,10 @@ pub mod fsync { // fsync fd after executing blk pub fn fd_res_sync(fd: &FdRes, opt_level: Option<Level>, - blk: fn(+v: Res<fd_t>)) { + blk: fn(v: Res<fd_t>)) { blk(move Res({ val: fd.fd, opt_level: opt_level, - fsync_fn: fn@(+fd: fd_t, l: Level) -> int { + fsync_fn: fn@(fd: fd_t, l: Level) -> int { return os::fsync_fd(fd, l) as int; } })); @@ -853,11 +853,11 @@ pub mod fsync { pub trait FSyncable { fn fsync(l: Level) -> int; } // Call o.fsync after executing blk - pub fn obj_sync(+o: FSyncable, opt_level: Option<Level>, - blk: fn(+v: Res<FSyncable>)) { + pub fn obj_sync(o: FSyncable, opt_level: Option<Level>, + blk: fn(v: Res<FSyncable>)) { blk(Res({ val: o, opt_level: opt_level, - fsync_fn: fn@(+o: FSyncable, l: Level) -> int { + fsync_fn: fn@(o: FSyncable, l: Level) -> int { return o.fsync(l); } })); diff --git a/src/libcore/iter-trait.rs b/src/libcore/iter-trait.rs index a2fb4698d7c..09bfe2eff36 100644 --- a/src/libcore/iter-trait.rs +++ b/src/libcore/iter-trait.rs @@ -16,7 +16,7 @@ impl<A> IMPL_T<A>: iter::ExtendedIter<A> { pure fn eachi(blk: fn(uint, v: &A) -> bool) { iter::eachi(&self, blk) } pure fn all(blk: fn(&A) -> bool) -> bool { iter::all(&self, blk) } pure fn any(blk: fn(&A) -> bool) -> bool { iter::any(&self, blk) } - pure fn foldl<B>(+b0: B, blk: fn(&B, &A) -> B) -> B { + pure fn foldl<B>(b0: B, blk: fn(&B, &A) -> B) -> B { iter::foldl(&self, move b0, blk) } pure fn position(f: fn(&A) -> bool) -> Option<uint> { @@ -30,20 +30,20 @@ impl<A: Eq> IMPL_T<A>: iter::EqIter<A> { } impl<A: Copy> IMPL_T<A>: iter::CopyableIter<A> { - pure fn filter_to_vec(pred: fn(+a: A) -> bool) -> ~[A] { + pure fn filter_to_vec(pred: fn(a: A) -> bool) -> ~[A] { iter::filter_to_vec(&self, pred) } - pure fn map_to_vec<B>(op: fn(+v: A) -> B) -> ~[B] { + pure fn map_to_vec<B>(op: fn(v: A) -> B) -> ~[B] { iter::map_to_vec(&self, op) } pure fn to_vec() -> ~[A] { iter::to_vec(&self) } - pure fn flat_map_to_vec<B:Copy,IB:BaseIter<B>>(op: fn(+a: A) -> IB) + pure fn flat_map_to_vec<B:Copy,IB:BaseIter<B>>(op: fn(a: A) -> IB) -> ~[B] { iter::flat_map_to_vec(&self, op) } - pure fn find(p: fn(+a: A) -> bool) -> Option<A> { iter::find(&self, p) } + pure fn find(p: fn(a: A) -> bool) -> Option<A> { iter::find(&self, p) } } impl<A: Copy Ord> IMPL_T<A>: iter::CopyableOrderedIter<A> { diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 5271555d299..bf3e91f7071 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -18,7 +18,7 @@ pub trait ExtendedIter<A> { pure fn eachi(blk: fn(uint, v: &A) -> bool); pure fn all(blk: fn(&A) -> bool) -> bool; pure fn any(blk: fn(&A) -> bool) -> bool; - pure fn foldl<B>(+b0: B, blk: fn(&B, &A) -> B) -> B; + pure fn foldl<B>(b0: B, blk: fn(&B, &A) -> B) -> B; pure fn position(f: fn(&A) -> bool) -> Option<uint>; } @@ -36,10 +36,10 @@ pub trait TimesIx{ } pub trait CopyableIter<A:Copy> { - pure fn filter_to_vec(pred: fn(+a: A) -> bool) -> ~[A]; - pure fn map_to_vec<B>(op: fn(+v: A) -> B) -> ~[B]; + pure fn filter_to_vec(pred: fn(a: A) -> bool) -> ~[A]; + pure fn map_to_vec<B>(op: fn(v: A) -> B) -> ~[B]; pure fn to_vec() -> ~[A]; - pure fn find(p: fn(+a: A) -> bool) -> Option<A>; + pure fn find(p: fn(a: A) -> bool) -> Option<A>; } pub trait CopyableOrderedIter<A:Copy Ord> { @@ -64,7 +64,7 @@ pub trait Buildable<A> { * onto the sequence being constructed. */ static pure fn build_sized(size: uint, - builder: fn(push: pure fn(+v: A))) -> self; + builder: fn(push: pure fn(v: A))) -> self; } pub pure fn eachi<A,IA:BaseIter<A>>(self: &IA, @@ -93,7 +93,7 @@ pub pure fn any<A,IA:BaseIter<A>>(self: &IA, } pub pure fn filter_to_vec<A:Copy,IA:BaseIter<A>>( - self: &IA, prd: fn(+a: A) -> bool) -> ~[A] { + self: &IA, prd: fn(a: A) -> bool) -> ~[A] { do vec::build_sized_opt(self.size_hint()) |push| { for self.each |a| { if prd(*a) { push(*a); } @@ -102,7 +102,7 @@ pub pure fn filter_to_vec<A:Copy,IA:BaseIter<A>>( } pub pure fn map_to_vec<A:Copy,B,IA:BaseIter<A>>(self: &IA, - op: fn(+v: A) -> B) + op: fn(v: A) -> B) -> ~[B] { do vec::build_sized_opt(self.size_hint()) |push| { for self.each |a| { @@ -112,8 +112,7 @@ pub pure fn map_to_vec<A:Copy,B,IA:BaseIter<A>>(self: &IA, } pub pure fn flat_map_to_vec<A:Copy,B:Copy,IA:BaseIter<A>,IB:BaseIter<B>>( - self: &IA, op: fn(+a: A) -> IB) -> ~[B] { - + self: &IA, op: fn(a: A) -> IB) -> ~[B] { do vec::build |push| { for self.each |a| { for op(*a).each |b| { @@ -123,7 +122,7 @@ pub pure fn flat_map_to_vec<A:Copy,B:Copy,IA:BaseIter<A>,IB:BaseIter<B>>( } } -pub pure fn foldl<A,B,IA:BaseIter<A>>(self: &IA, +b0: B, +pub pure fn foldl<A,B,IA:BaseIter<A>>(self: &IA, b0: B, blk: fn(&B, &A) -> B) -> B { let mut b <- b0; @@ -206,7 +205,7 @@ pub pure fn max<A:Copy Ord,IA:BaseIter<A>>(self: &IA) -> A { } pub pure fn find<A: Copy,IA:BaseIter<A>>(self: &IA, - p: fn(+a: A) -> bool) -> Option<A> { + p: fn(a: A) -> bool) -> Option<A> { for self.each |i| { if p(*i) { return Some(*i) } } @@ -226,7 +225,7 @@ pub pure fn find<A: Copy,IA:BaseIter<A>>(self: &IA, * onto the sequence being constructed. */ #[inline(always)] -pub pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(+v: A))) +pub pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(v: A))) -> B { build_sized(4, builder) } @@ -247,7 +246,7 @@ pub pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(+v: A))) #[inline(always)] pub pure fn build_sized_opt<A,B: Buildable<A>>( size: Option<uint>, - builder: fn(push: pure fn(+v: A))) -> B { + builder: fn(push: pure fn(v: A))) -> B { build_sized(size.get_default(4), builder) } @@ -285,7 +284,7 @@ pub pure fn from_fn<T,BT: Buildable<T>>(n_elts: uint, * to the value `t`. */ pub pure fn from_elem<T: Copy,BT: Buildable<T>>(n_elts: uint, - +t: T) -> BT { + t: T) -> BT { do build_sized(n_elts) |push| { let mut i: uint = 0; while i < n_elts { push(t); i += 1; } diff --git a/src/libcore/mutable.rs b/src/libcore/mutable.rs index a1f65117ecf..5948c630cd8 100644 --- a/src/libcore/mutable.rs +++ b/src/libcore/mutable.rs @@ -8,8 +8,7 @@ dynamic checks: your program will fail if you attempt to perform mutation when the data structure should be immutable. */ - -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; use util::with; @@ -24,11 +23,11 @@ struct Data<T> { pub type Mut<T> = Data<T>; -pub fn Mut<T>(+t: T) -> Mut<T> { +pub fn Mut<T>(t: T) -> Mut<T> { Data {value: t, mode: ReadOnly} } -pub fn unwrap<T>(+m: Mut<T>) -> T { +pub fn unwrap<T>(m: Mut<T>) -> T { // Borrowck should prevent us from calling unwrap while the value // is in use, as that would be a move from a borrowed value. assert (m.mode as uint) == (ReadOnly as uint); diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 994e010e452..038c117b8be 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -77,6 +77,6 @@ pub trait Shr<RHS,Result> { #[lang="index"] pub trait Index<Index,Result> { - pure fn index(+index: Index) -> Result; + pure fn index(index: Index) -> Result; } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 87d6aeefbc3..6bd326186cb 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -49,7 +49,7 @@ pub pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T { } } -pub pure fn expect<T: Copy>(opt: &Option<T>, +reason: ~str) -> T { +pub pure fn expect<T: Copy>(opt: &Option<T>, reason: ~str) -> T { /*! * Gets the value out of an option, printing a specified message on * failure @@ -67,8 +67,8 @@ pub pure fn map<T, U>(opt: &Option<T>, f: fn(x: &T) -> U) -> Option<U> { match *opt { Some(ref x) => Some(f(x)), None => None } } -pub pure fn map_consume<T, U>(+opt: Option<T>, - f: fn(+v: T) -> U) -> Option<U> { +pub pure fn map_consume<T, U>(opt: Option<T>, + f: fn(v: T) -> U) -> Option<U> { /*! * As `map`, but consumes the option and gives `f` ownership to avoid * copying. @@ -76,8 +76,8 @@ pub pure fn map_consume<T, U>(+opt: Option<T>, if opt.is_some() { Some(f(option::unwrap(move opt))) } else { None } } -pub pure fn chain<T, U>(+opt: Option<T>, - f: fn(+t: T) -> Option<U>) -> Option<U> { +pub pure fn chain<T, U>(opt: Option<T>, + f: fn(t: T) -> Option<U>) -> Option<U> { /*! * Update an optional value by optionally running its content through a * function that returns an option. @@ -101,7 +101,7 @@ pub pure fn chain_ref<T, U>(opt: &Option<T>, match *opt { Some(ref x) => f(x), None => None } } -pub pure fn or<T>(+opta: Option<T>, +optb: Option<T>) -> Option<T> { +pub pure fn or<T>(opta: Option<T>, optb: Option<T>) -> Option<T> { /*! * Returns the leftmost some() value, or none if both are none. */ @@ -112,7 +112,7 @@ pub pure fn or<T>(+opta: Option<T>, +optb: Option<T>) -> Option<T> { } #[inline(always)] -pub pure fn while_some<T>(+x: Option<T>, blk: fn(+v: T) -> Option<T>) { +pub pure fn while_some<T>(x: Option<T>, blk: fn(v: T) -> Option<T>) { //! Applies a function zero or more times until the result is none. let mut opt <- x; @@ -133,13 +133,13 @@ pub pure fn is_some<T>(opt: &Option<T>) -> bool { !is_none(opt) } -pub pure fn get_default<T: Copy>(opt: &Option<T>, +def: T) -> T { +pub pure fn get_default<T: Copy>(opt: &Option<T>, def: T) -> T { //! Returns the contained value or a default match *opt { Some(copy x) => x, None => def } } -pub pure fn map_default<T, U>(opt: &Option<T>, +def: U, +pub pure fn map_default<T, U>(opt: &Option<T>, def: U, f: fn(x: &T) -> U) -> U { //! Applies a function to the contained value or returns a default @@ -151,10 +151,8 @@ pub pure fn iter<T>(opt: &Option<T>, f: fn(x: &T)) { match *opt { None => (), Some(ref t) => f(t) } } -// tjc: shouldn't this be - instead of +? -// then could get rid of some superfluous moves #[inline(always)] -pub pure fn unwrap<T>(+opt: Option<T>) -> T { +pub pure fn unwrap<T>(opt: Option<T>) -> T { /*! * Moves a value out of an option type and returns it. * @@ -174,7 +172,7 @@ pub fn swap_unwrap<T>(opt: &mut Option<T>) -> T { unwrap(util::replace(opt, None)) } -pub pure fn unwrap_expect<T>(+opt: Option<T>, reason: &str) -> T { +pub pure fn unwrap_expect<T>(opt: Option<T>, reason: &str) -> T { //! As unwrap, but with a specified failure message. if opt.is_none() { fail reason.to_unique(); } unwrap(move opt) @@ -197,7 +195,7 @@ impl<T> &Option<T> { chain_ref(self, f) } /// Applies a function to the contained value or returns a default - pure fn map_default<U>(+def: U, f: fn(x: &T) -> U) -> U + pure fn map_default<U>(def: U, f: fn(x: &T) -> U) -> U { map_default(self, move def, f) } /// Performs an operation on the contained value by reference pure fn iter(f: fn(x: &T)) { iter(self, f) } @@ -216,7 +214,7 @@ impl<T: Copy> Option<T> { * Fails if the value equals `none` */ pure fn get() -> T { get(&self) } - pure fn get_default(+def: T) -> T { get_default(&self, def) } + pure fn get_default(def: T) -> T { get_default(&self, def) } /** * Gets the value out of an option, printing a specified message on * failure @@ -225,9 +223,9 @@ impl<T: Copy> Option<T> { * * Fails if the value equals `none` */ - pure fn expect(+reason: ~str) -> T { expect(&self, reason) } + pure fn expect(reason: ~str) -> T { expect(&self, reason) } /// Applies a function zero or more times until the result is none. - pure fn while_some(blk: fn(+v: T) -> Option<T>) { while_some(self, blk) } + pure fn while_some(blk: fn(v: T) -> Option<T>) { while_some(self, blk) } } impl<T: Eq> Option<T> : Eq { diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 1cf4fbab6c9..f178502f6a0 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid #[forbid(deprecated_pattern)]; /*! @@ -768,7 +768,7 @@ struct OverriddenArgs { val: ~[~str] } -fn overridden_arg_key(+_v: @OverriddenArgs) {} +fn overridden_arg_key(_v: @OverriddenArgs) {} pub fn args() -> ~[~str] { unsafe { @@ -779,7 +779,7 @@ pub fn args() -> ~[~str] { } } -pub fn set_args(+new_args: ~[~str]) { +pub fn set_args(new_args: ~[~str]) { unsafe { let overridden_args = @OverriddenArgs { val: copy new_args }; task::local_data::local_data_set(overridden_arg_key, overridden_args); diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 4d446df9cd5..e34c0db35e9 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -73,7 +73,7 @@ bounded and unbounded protocols allows for less code duplication. */ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; use cmp::Eq; @@ -169,7 +169,7 @@ impl PacketHeader { reinterpret_cast(&self.buffer) } - fn set_buffer<T: Send>(+b: ~Buffer<T>) unsafe { + fn set_buffer<T: Send>(b: ~Buffer<T>) unsafe { self.buffer = reinterpret_cast(&b); } } @@ -227,7 +227,7 @@ pub fn packet<T: Send>() -> *Packet<T> { #[doc(hidden)] pub fn entangle_buffer<T: Send, Tstart: Send>( - +buffer: ~Buffer<T>, + buffer: ~Buffer<T>, init: fn(*libc::c_void, x: &T) -> *Packet<Tstart>) -> (SendPacketBuffered<Tstart, T>, RecvPacketBuffered<Tstart, T>) { @@ -239,12 +239,12 @@ pub fn entangle_buffer<T: Send, Tstart: Send>( #[abi = "rust-intrinsic"] #[doc(hidden)] extern mod rusti { - fn atomic_xchg(dst: &mut int, +src: int) -> int; - fn atomic_xchg_acq(dst: &mut int, +src: int) -> int; - fn atomic_xchg_rel(dst: &mut int, +src: int) -> int; + fn atomic_xchg(dst: &mut int, src: int) -> int; + fn atomic_xchg_acq(dst: &mut int, src: int) -> int; + fn atomic_xchg_rel(dst: &mut int, src: int) -> int; - fn atomic_xadd_acq(dst: &mut int, +src: int) -> int; - fn atomic_xsub_rel(dst: &mut int, +src: int) -> int; + fn atomic_xadd_acq(dst: &mut int, src: int) -> int; + fn atomic_xsub_rel(dst: &mut int, src: int) -> int; } // If I call the rusti versions directly from a polymorphic function, @@ -265,7 +265,7 @@ pub fn atomic_sub_rel(dst: &mut int, src: int) -> int { } #[doc(hidden)] -pub fn swap_task(+dst: &mut *rust_task, src: *rust_task) -> *rust_task { +pub fn swap_task(dst: &mut *rust_task, src: *rust_task) -> *rust_task { // It might be worth making both acquire and release versions of // this. unsafe { @@ -304,14 +304,14 @@ fn wait_event(this: *rust_task) -> *libc::c_void { } #[doc(hidden)] -fn swap_state_acq(+dst: &mut State, src: State) -> State { +fn swap_state_acq(dst: &mut State, src: State) -> State { unsafe { transmute(rusti::atomic_xchg_acq(transmute(move dst), src as int)) } } #[doc(hidden)] -fn swap_state_rel(+dst: &mut State, src: State) -> State { +fn swap_state_rel(dst: &mut State, src: State) -> State { unsafe { transmute(rusti::atomic_xchg_rel(transmute(move dst), src as int)) } @@ -343,7 +343,7 @@ struct BufferResource<T: Send> { } } -fn BufferResource<T: Send>(+b: ~Buffer<T>) -> BufferResource<T> { +fn BufferResource<T: Send>(b: ~Buffer<T>) -> BufferResource<T> { //let p = ptr::addr_of(*b); //error!("take %?", p); atomic_add_acq(&mut b.header.ref_count, 1); @@ -354,8 +354,8 @@ fn BufferResource<T: Send>(+b: ~Buffer<T>) -> BufferResource<T> { } #[doc(hidden)] -pub fn send<T: Send, Tbuffer: Send>(+p: SendPacketBuffered<T, Tbuffer>, - +payload: T) -> bool { +pub fn send<T: Send, Tbuffer: Send>(p: SendPacketBuffered<T, Tbuffer>, + payload: T) -> bool { let header = p.header(); let p_ = p.unwrap(); let p = unsafe { &*p_ }; @@ -398,7 +398,7 @@ pub fn send<T: Send, Tbuffer: Send>(+p: SendPacketBuffered<T, Tbuffer>, Fails if the sender closes the connection. */ -pub fn recv<T: Send, Tbuffer: Send>(+p: RecvPacketBuffered<T, Tbuffer>) -> T { +pub fn recv<T: Send, Tbuffer: Send>(p: RecvPacketBuffered<T, Tbuffer>) -> T { option::unwrap_expect(try_recv(move p), "connection closed") } @@ -408,7 +408,7 @@ Returns `none` if the sender has closed the connection without sending a message, or `Some(T)` if a message was received. */ -pub fn try_recv<T: Send, Tbuffer: Send>(+p: RecvPacketBuffered<T, Tbuffer>) +pub fn try_recv<T: Send, Tbuffer: Send>(p: RecvPacketBuffered<T, Tbuffer>) -> Option<T> { let p_ = p.unwrap(); @@ -655,8 +655,8 @@ this case, `select2` may return either `left` or `right`. */ pub fn select2<A: Send, Ab: Send, B: Send, Bb: Send>( - +a: RecvPacketBuffered<A, Ab>, - +b: RecvPacketBuffered<B, Bb>) + a: RecvPacketBuffered<A, Ab>, + b: RecvPacketBuffered<B, Bb>) -> Either<(Option<A>, RecvPacketBuffered<B, Bb>), (RecvPacketBuffered<A, Ab>, Option<B>)> { @@ -697,7 +697,7 @@ pub fn select2i<A: Selectable, B: Selectable>(a: &A, b: &B) -> list of the remaining endpoints. */ -pub fn select<T: Send, Tb: Send>(+endpoints: ~[RecvPacketBuffered<T, Tb>]) +pub fn select<T: Send, Tb: Send>(endpoints: ~[RecvPacketBuffered<T, Tb>]) -> (uint, Option<T>, ~[RecvPacketBuffered<T, Tb>]) { let ready = wait_many(endpoints.map(|p| p.header())); @@ -859,7 +859,7 @@ endpoint is passed to the new task. pub fn spawn_service<T: Send, Tb: Send>( init: extern fn() -> (SendPacketBuffered<T, Tb>, RecvPacketBuffered<T, Tb>), - +service: fn~(+v: RecvPacketBuffered<T, Tb>)) + +service: fn~(v: RecvPacketBuffered<T, Tb>)) -> SendPacketBuffered<T, Tb> { let (client, server) = init(); @@ -883,7 +883,7 @@ receive state. pub fn spawn_service_recv<T: Send, Tb: Send>( init: extern fn() -> (RecvPacketBuffered<T, Tb>, SendPacketBuffered<T, Tb>), - +service: fn~(+v: SendPacketBuffered<T, Tb>)) + +service: fn~(v: SendPacketBuffered<T, Tb>)) -> RecvPacketBuffered<T, Tb> { let (client, server) = init(); @@ -914,10 +914,10 @@ pub trait Channel<T: Send> { // built in send kind. /// Sends a message. - fn send(+x: T); + fn send(x: T); /// Sends a message, or report if the receiver has closed the connection. - fn try_send(+x: T) -> bool; + fn try_send(x: T) -> bool; } /// A trait for things that can receive multiple messages. @@ -966,14 +966,14 @@ pub fn stream<T:Send>() -> (Chan<T>, Port<T>) { } impl<T: Send> Chan<T>: Channel<T> { - fn send(+x: T) { + fn send(x: T) { let mut endp = None; endp <-> self.endp; self.endp = Some( streamp::client::data(unwrap(move endp), move x)) } - fn try_send(+x: T) -> bool { + fn try_send(x: T) -> bool { let mut endp = None; endp <-> self.endp; match move streamp::client::try_data(unwrap(move endp), move x) { @@ -1041,7 +1041,7 @@ pub fn PortSet<T: Send>() -> PortSet<T>{ impl<T: Send> PortSet<T> : Recv<T> { - fn add(+port: pipes::Port<T>) { + fn add(port: pipes::Port<T>) { self.ports.push(move port) } @@ -1091,7 +1091,7 @@ impl<T: Send> PortSet<T> : Recv<T> { pub type SharedChan<T: Send> = private::Exclusive<Chan<T>>; impl<T: Send> SharedChan<T>: Channel<T> { - fn send(+x: T) { + fn send(x: T) { let mut xx = Some(move x); do self.with_imm |chan| { let mut x = None; @@ -1100,7 +1100,7 @@ impl<T: Send> SharedChan<T>: Channel<T> { } } - fn try_send(+x: T) -> bool { + fn try_send(x: T) -> bool { let mut xx = Some(move x); do self.with_imm |chan| { let mut x = None; @@ -1111,7 +1111,7 @@ impl<T: Send> SharedChan<T>: Channel<T> { } /// Converts a `chan` into a `shared_chan`. -pub fn SharedChan<T:Send>(+c: Chan<T>) -> SharedChan<T> { +pub fn SharedChan<T:Send>(c: Chan<T>) -> SharedChan<T> { private::exclusive(move c) } @@ -1165,13 +1165,13 @@ pub fn oneshot<T: Send>() -> (ChanOne<T>, PortOne<T>) { * Receive a message from a oneshot pipe, failing if the connection was * closed. */ -pub fn recv_one<T: Send>(+port: PortOne<T>) -> T { +pub fn recv_one<T: Send>(port: PortOne<T>) -> T { let oneshot::send(message) = recv(move port); move message } /// Receive a message from a oneshot pipe unless the connection was closed. -pub fn try_recv_one<T: Send> (+port: PortOne<T>) -> Option<T> { +pub fn try_recv_one<T: Send> (port: PortOne<T>) -> Option<T> { let message = try_recv(move port); if message.is_none() { None } @@ -1182,7 +1182,7 @@ pub fn try_recv_one<T: Send> (+port: PortOne<T>) -> Option<T> { } /// Send a message on a oneshot pipe, failing if the connection was closed. -pub fn send_one<T: Send>(+chan: ChanOne<T>, +data: T) { +pub fn send_one<T: Send>(chan: ChanOne<T>, data: T) { oneshot::client::send(move chan, move data); } @@ -1190,7 +1190,7 @@ pub fn send_one<T: Send>(+chan: ChanOne<T>, +data: T) { * Send a message on a oneshot pipe, or return false if the connection was * closed. */ -pub fn try_send_one<T: Send>(+chan: ChanOne<T>, +data: T) +pub fn try_send_one<T: Send>(chan: ChanOne<T>, data: T) -> bool { oneshot::client::try_send(move chan, move data).is_some() } @@ -1198,7 +1198,7 @@ pub fn try_send_one<T: Send>(+chan: ChanOne<T>, +data: T) pub mod rt { // These are used to hide the option constructors from the // compiler because their names are changing - pub fn make_some<T>(+val: T) -> Option<T> { Some(move val) } + pub fn make_some<T>(val: T) -> Option<T> { Some(move val) } pub fn make_none<T>() -> Option<T> { None } } diff --git a/src/libcore/private.rs b/src/libcore/private.rs index 025a6f28976..c1b2b32edaf 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; #[doc(hidden)]; @@ -340,7 +340,7 @@ fn ArcDestruct<T>(data: *libc::c_void) -> ArcDestruct<T> { } } -pub unsafe fn unwrap_shared_mutable_state<T: Send>(+rc: SharedMutableState<T>) +pub unsafe fn unwrap_shared_mutable_state<T: Send>(rc: SharedMutableState<T>) -> T { struct DeathThroes<T> { mut ptr: Option<~ArcData<T>>, @@ -413,7 +413,7 @@ pub unsafe fn unwrap_shared_mutable_state<T: Send>(+rc: SharedMutableState<T>) */ pub type SharedMutableState<T: Send> = ArcDestruct<T>; -pub unsafe fn shared_mutable_state<T: Send>(+data: T) -> +pub unsafe fn shared_mutable_state<T: Send>(data: T) -> SharedMutableState<T> { let data = ~ArcData { count: 1, unwrapper: 0, data: Some(move data) }; unsafe { @@ -502,7 +502,7 @@ struct ExData<T: Send> { lock: LittleLock, mut failed: bool, mut data: T, } */ pub struct Exclusive<T: Send> { x: SharedMutableState<ExData<T>> } -pub fn exclusive<T:Send >(+user_data: T) -> Exclusive<T> { +pub fn exclusive<T:Send >(user_data: T) -> Exclusive<T> { let data = ExData { lock: LittleLock(), mut failed: false, mut data: user_data }; @@ -544,7 +544,7 @@ impl<T: Send> Exclusive<T> { } // FIXME(#2585) make this a by-move method on the exclusive -pub fn unwrap_exclusive<T: Send>(+arc: Exclusive<T>) -> T { +pub fn unwrap_exclusive<T: Send>(arc: Exclusive<T>) -> T { let Exclusive { x: x } <- arc; let inner = unsafe { unwrap_shared_mutable_state(move x) }; let ExData { data: data, _ } <- inner; diff --git a/src/libcore/reflect.rs b/src/libcore/reflect.rs index af6a3f9b478..41006e1dfb5 100644 --- a/src/libcore/reflect.rs +++ b/src/libcore/reflect.rs @@ -27,7 +27,7 @@ fn align(size: uint, align: uint) -> uint { struct MovePtrAdaptor<V: TyVisitor MovePtr> { inner: V } -pub fn MovePtrAdaptor<V: TyVisitor MovePtr>(+v: V) -> MovePtrAdaptor<V> { +pub fn MovePtrAdaptor<V: TyVisitor MovePtr>(v: V) -> MovePtrAdaptor<V> { MovePtrAdaptor { inner: move v } } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index e454c068d47..e61690d5b2c 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -1,7 +1,7 @@ //! A type representing either success or failure // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; use cmp::Eq; @@ -102,7 +102,7 @@ pub pure fn to_either<T: Copy, U: Copy>(res: &Result<U, T>) * ok(parse_bytes(buf)) * } */ -pub fn chain<T, U: Copy, V: Copy>(+res: Result<T, V>, op: fn(+t: T) +pub fn chain<T, U: Copy, V: Copy>(res: Result<T, V>, op: fn(t: T) -> Result<U, V>) -> Result<U, V> { // XXX: Should be writable with move + match if res.is_ok() { @@ -121,8 +121,8 @@ pub fn chain<T, U: Copy, V: Copy>(+res: Result<T, V>, op: fn(+t: T) * successful result while handling an error. */ pub fn chain_err<T: Copy, U: Copy, V: Copy>( - +res: Result<T, V>, - op: fn(+t: V) -> Result<T, U>) + res: Result<T, V>, + op: fn(t: V) -> Result<T, U>) -> Result<T, U> { match move res { Ok(move t) => Ok(t), @@ -247,12 +247,12 @@ impl<T, E: Copy> Result<T, E> { } impl<T: Copy, E: Copy> Result<T, E> { - fn chain<U:Copy>(op: fn(+t: T) -> Result<U,E>) -> Result<U,E> { + fn chain<U:Copy>(op: fn(t: T) -> Result<U,E>) -> Result<U,E> { // XXX: Bad copy chain(copy self, op) } - fn chain_err<F:Copy>(op: fn(+t: E) -> Result<T,F>) -> Result<T,F> { + fn chain_err<F:Copy>(op: fn(t: E) -> Result<T,F>) -> Result<T,F> { // XXX: Bad copy chain_err(copy self, op) } @@ -348,7 +348,7 @@ pub fn iter_vec2<S,T,U:Copy>(ss: &[S], ts: &[T], } /// Unwraps a result, assuming it is an `ok(T)` -pub fn unwrap<T, U>(+res: Result<T, U>) -> T { +pub fn unwrap<T, U>(res: Result<T, U>) -> T { match move res { Ok(move t) => move t, Err(_) => fail ~"unwrap called on an err result" @@ -356,7 +356,7 @@ pub fn unwrap<T, U>(+res: Result<T, U>) -> T { } /// Unwraps a result, assuming it is an `err(U)` -pub fn unwrap_err<T, U>(+res: Result<T, U>) -> U { +pub fn unwrap_err<T, U>(res: Result<T, U>) -> U { match move res { Err(move u) => move u, Ok(_) => fail ~"unwrap called on an ok result" @@ -389,7 +389,7 @@ mod tests { #[legacy_exports]; fn op1() -> result::Result<int, ~str> { result::Ok(666) } - fn op2(+i: int) -> result::Result<uint, ~str> { + fn op2(i: int) -> result::Result<uint, ~str> { result::Ok(i as uint + 1u) } diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 40c2bc83351..f3e98f6ba82 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; //! Process spawning @@ -224,7 +224,7 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program { drop { destroy_repr(&self.r); } } - fn ProgRes(+r: ProgRepr) -> ProgRes { + fn ProgRes(r: ProgRepr) -> ProgRes { ProgRes { r: r } @@ -328,7 +328,7 @@ pub fn program_output(prog: &str, args: &[~str]) -> return {status: status, out: move outs, err: move errs}; } -fn writeclose(fd: c_int, +s: ~str) { +fn writeclose(fd: c_int, s: ~str) { use io::WriterUtil; error!("writeclose %d, %s", fd as int, s); diff --git a/src/libcore/send_map.rs b/src/libcore/send_map.rs index 1b219e16e09..4a56ee5b896 100644 --- a/src/libcore/send_map.rs +++ b/src/libcore/send_map.rs @@ -15,7 +15,7 @@ use to_bytes::IterBytes; pub trait SendMap<K:Eq Hash, V: Copy> { // FIXME(#3148) ^^^^ once find_ref() works, we can drop V:copy - fn insert(&mut self, +k: K, +v: V) -> bool; + fn insert(&mut self, k: K, +v: V) -> bool; fn remove(&mut self, k: &K) -> bool; fn clear(&mut self); pure fn len(&const self) -> uint; @@ -161,7 +161,7 @@ pub mod linear { } } - fn insert_opt_bucket(&mut self, +bucket: Option<Bucket<K,V>>) { + fn insert_opt_bucket(&mut self, bucket: Option<Bucket<K,V>>) { match move bucket { Some(Bucket {hash: move hash, key: move key, @@ -175,7 +175,7 @@ pub mod linear { /// Inserts the key value pair into the buckets. /// Assumes that there will be a bucket. /// True if there was no previous entry with that key - fn insert_internal(&mut self, hash: uint, +k: K, +v: V) -> bool { + fn insert_internal(&mut self, hash: uint, k: K, v: V) -> bool { match self.bucket_for_key_with_hash(self.buckets, hash, &k) { TableFull => { fail ~"Internal logic error"; } FoundHole(idx) => { @@ -206,7 +206,7 @@ pub mod linear { } impl<K:Hash IterBytes Eq,V> LinearMap<K,V> { - fn insert(&mut self, +k: K, +v: V) -> bool { + fn insert(&mut self, k: K, v: V) -> bool { if self.size >= self.resize_at { // n.b.: We could also do this after searching, so // that we do not resize if this call to insert is diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs index d0f8de136e2..09973148c8c 100644 --- a/src/libcore/stackwalk.rs +++ b/src/libcore/stackwalk.rs @@ -1,5 +1,7 @@ #[doc(hidden)]; // FIXME #3538 +#[legacy_modes]; // tjc: remove after snapshot + // NB: transitionary, de-mode-ing. // XXX: Can't do this because frame_address needs a deprecated mode. //#[forbid(deprecated_mode)]; diff --git a/src/libcore/str.rs b/src/libcore/str.rs index e8a88f3bc1b..cf996a8b254 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -175,7 +175,7 @@ pub fn push_str(lhs: &const ~str, rhs: &str) { /// Concatenate two strings together #[inline(always)] -pub pure fn append(+lhs: ~str, rhs: &str) -> ~str { +pub pure fn append(lhs: ~str, rhs: &str) -> ~str { let mut v <- lhs; unsafe { push_str_no_overallocate(&mut v, rhs); diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 9f13a6c2207..12329616fbf 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -83,7 +83,7 @@ pub pure fn pref_align_of<T>() -> uint { /// Returns the refcount of a shared box (as just before calling this) #[inline(always)] -pub pure fn refcount<T>(+t: @T) -> uint { +pub pure fn refcount<T>(t: @T) -> uint { unsafe { let ref_ptr: *uint = cast::reinterpret_cast(&t); *ref_ptr - 1 diff --git a/src/libcore/task.rs b/src/libcore/task.rs index 912b7f712aa..5ca35a7f562 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; /*! @@ -232,7 +232,7 @@ pub enum TaskBuilder = { pub fn task() -> TaskBuilder { TaskBuilder({ opts: default_task_opts(), - gen_body: |body| move body, // Identity function + gen_body: |+body| move body, // Identity function can_not_copy: None, mut consumed: false, }) @@ -347,7 +347,7 @@ impl TaskBuilder { * # Failure * Fails if a future_result was already set for this task. */ - fn future_result(blk: fn(+v: future::Future<TaskResult>)) -> TaskBuilder { + fn future_result(blk: fn(v: future::Future<TaskResult>)) -> TaskBuilder { // FIXME (#1087, #1857): Once linked failure and notification are // handled in the library, I can imagine implementing this by just // registering an arbitrary number of task::on_exit handlers and @@ -459,9 +459,9 @@ impl TaskBuilder { spawn::spawn_raw(move opts, x.gen_body(move f)); } /// Runs a task, while transfering ownership of one argument to the child. - fn spawn_with<A: Send>(+arg: A, +f: fn~(+v: A)) { + fn spawn_with<A: Send>(arg: A, +f: fn~(+v: A)) { let arg = ~mut Some(move arg); - do self.spawn |move arg, move f|{ + do self.spawn |move arg, move f| { f(option::swap_unwrap(arg)) } } @@ -473,7 +473,7 @@ impl TaskBuilder { * child task, passes the port to child's body, and returns a channel * linked to the port to the parent. * - * This encapsulates Some boilerplate handshaking logic that would + * This encapsulates some boilerplate handshaking logic that would * otherwise be required to establish communication from the parent * to the child. */ @@ -1149,7 +1149,7 @@ fn test_avoid_copying_the_body_spawn() { #[test] fn test_avoid_copying_the_body_spawn_listener() { - do avoid_copying_the_body |f| { + do avoid_copying_the_body |+f| { spawn_listener(fn~(move f, _po: comm::Port<int>) { f(); }); @@ -1167,7 +1167,7 @@ fn test_avoid_copying_the_body_task_spawn() { #[test] fn test_avoid_copying_the_body_spawn_listener_1() { - do avoid_copying_the_body |f| { + do avoid_copying_the_body |+f| { task().spawn_listener(fn~(move f, _po: comm::Port<int>) { f(); }); diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs index eda76518001..2130354229a 100644 --- a/src/libcore/task/local_data.rs +++ b/src/libcore/task/local_data.rs @@ -37,7 +37,7 @@ use local_data_priv::{ * * These two cases aside, the interface is safe. */ -pub type LocalDataKey<T: Owned> = &fn(+v: @T); +pub type LocalDataKey<T: Owned> = &fn(v: @T); /** * Remove a task-local data value from the table, returning the @@ -62,7 +62,7 @@ pub unsafe fn local_data_get<T: Owned>( * that value is overwritten (and its destructor is run). */ pub unsafe fn local_data_set<T: Owned>( - key: LocalDataKey<T>, +data: @T) { + key: LocalDataKey<T>, data: @T) { local_set(rt::rust_get_task(), key, data) } @@ -79,7 +79,7 @@ pub unsafe fn local_data_modify<T: Owned>( #[test] pub fn test_tls_multitask() unsafe { - fn my_key(+_x: @~str) { } + fn my_key(_x: @~str) { } local_data_set(my_key, @~"parent data"); do task::spawn unsafe { assert local_data_get(my_key).is_none(); // TLS shouldn't carry over. @@ -95,7 +95,7 @@ pub fn test_tls_multitask() unsafe { #[test] pub fn test_tls_overwrite() unsafe { - fn my_key(+_x: @~str) { } + fn my_key(_x: @~str) { } local_data_set(my_key, @~"first data"); local_data_set(my_key, @~"next data"); // Shouldn't leak. assert *(local_data_get(my_key).get()) == ~"next data"; @@ -103,7 +103,7 @@ pub fn test_tls_overwrite() unsafe { #[test] pub fn test_tls_pop() unsafe { - fn my_key(+_x: @~str) { } + fn my_key(_x: @~str) { } local_data_set(my_key, @~"weasel"); assert *(local_data_pop(my_key).get()) == ~"weasel"; // Pop must remove the data from the map. @@ -112,7 +112,7 @@ pub fn test_tls_pop() unsafe { #[test] pub fn test_tls_modify() unsafe { - fn my_key(+_x: @~str) { } + fn my_key(_x: @~str) { } local_data_modify(my_key, |data| { match data { Some(@ref val) => fail ~"unwelcome value: " + *val, @@ -136,7 +136,7 @@ pub fn test_tls_crust_automorestack_memorial_bug() unsafe { // jump over to the rust stack, which causes next_c_sp to get recorded as // Something within a rust stack segment. Then a subsequent upcall (esp. // for logging, think vsnprintf) would run on a stack smaller than 1 MB. - fn my_key(+_x: @~str) { } + fn my_key(_x: @~str) { } do task::spawn { unsafe { local_data_set(my_key, @~"hax"); } } @@ -144,9 +144,9 @@ pub fn test_tls_crust_automorestack_memorial_bug() unsafe { #[test] pub fn test_tls_multiple_types() unsafe { - fn str_key(+_x: @~str) { } - fn box_key(+_x: @@()) { } - fn int_key(+_x: @int) { } + fn str_key(_x: @~str) { } + fn box_key(_x: @@()) { } + fn int_key(_x: @int) { } do task::spawn unsafe { local_data_set(str_key, @~"string data"); local_data_set(box_key, @@()); @@ -156,9 +156,9 @@ pub fn test_tls_multiple_types() unsafe { #[test] pub fn test_tls_overwrite_multiple_types() { - fn str_key(+_x: @~str) { } - fn box_key(+_x: @@()) { } - fn int_key(+_x: @int) { } + fn str_key(_x: @~str) { } + fn box_key(_x: @@()) { } + fn int_key(_x: @int) { } do task::spawn unsafe { local_data_set(str_key, @~"string data"); local_data_set(int_key, @42); @@ -172,9 +172,9 @@ pub fn test_tls_overwrite_multiple_types() { #[should_fail] #[ignore(cfg(windows))] pub fn test_tls_cleanup_on_failure() unsafe { - fn str_key(+_x: @~str) { } - fn box_key(+_x: @@()) { } - fn int_key(+_x: @int) { } + fn str_key(_x: @~str) { } + fn box_key(_x: @@()) { } + fn int_key(_x: @int) { } local_data_set(str_key, @~"parent data"); local_data_set(box_key, @@()); do task::spawn unsafe { // spawn_linked diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index 0d3007286c5..499dd073060 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -117,7 +117,7 @@ unsafe fn local_get<T: Owned>( } unsafe fn local_set<T: Owned>( - task: *rust_task, key: LocalDataKey<T>, +data: @T) { + task: *rust_task, key: LocalDataKey<T>, data: @T) { let map = get_task_local_map(task); // Store key+data as *voids. Data is invisibly referenced once; key isn't. diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 982679f9398..786255fe7fa 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -82,7 +82,7 @@ fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) { let was_present = tasks.remove(&task); assert was_present; } -fn taskset_each(tasks: &TaskSet, blk: fn(+v: *rust_task) -> bool) { +fn taskset_each(tasks: &TaskSet, blk: fn(v: *rust_task) -> bool) { tasks.each_key(|k| blk(*k)) } @@ -303,8 +303,8 @@ struct TCB { } } -fn TCB(me: *rust_task, +tasks: TaskGroupArc, +ancestors: AncestorList, - is_main: bool, +notifier: Option<AutoNotify>) -> TCB { +fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList, + is_main: bool, notifier: Option<AutoNotify>) -> TCB { let notifier = move notifier; notifier.iter(|x| { x.failed = false; }); @@ -327,7 +327,7 @@ struct AutoNotify { } } -fn AutoNotify(+chan: Chan<Notification>) -> AutoNotify { +fn AutoNotify(chan: Chan<Notification>) -> AutoNotify { AutoNotify { notify_chan: chan, failed: true // Un-set above when taskgroup successfully made. @@ -377,13 +377,13 @@ fn kill_taskgroup(state: TaskGroupInner, me: *rust_task, is_main: bool) { // see 'None' if Somebody already failed and we got a kill signal.) if newstate.is_some() { let group = option::unwrap(move newstate); - for taskset_each(&group.members) |+sibling| { + for taskset_each(&group.members) |sibling| { // Skip self - killing ourself won't do much good. if sibling != me { rt::rust_task_kill_other(sibling); } } - for taskset_each(&group.descendants) |+child| { + for taskset_each(&group.descendants) |child| { assert child != me; rt::rust_task_kill_other(child); } @@ -486,7 +486,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool) } } -fn spawn_raw(+opts: TaskOpts, +f: fn~()) { +fn spawn_raw(opts: TaskOpts, +f: fn~()) { let (child_tg, ancestors, is_main) = gen_child_taskgroup(opts.linked, opts.supervised); @@ -528,9 +528,9 @@ fn spawn_raw(+opts: TaskOpts, +f: fn~()) { // (3a) If any of those fails, it leaves all groups, and does nothing. // (3b) Otherwise it builds a task control structure and puts it in TLS, // (4) ...and runs the provided body function. - fn make_child_wrapper(child: *rust_task, +child_arc: TaskGroupArc, - +ancestors: AncestorList, is_main: bool, - +notify_chan: Option<Chan<Notification>>, + fn make_child_wrapper(child: *rust_task, child_arc: TaskGroupArc, + ancestors: AncestorList, is_main: bool, + notify_chan: Option<Chan<Notification>>, +f: fn~()) -> fn~() { let child_data = ~mut Some((move child_arc, move ancestors)); return fn~(move notify_chan, move child_data, move f) { diff --git a/src/libcore/util.rs b/src/libcore/util.rs index 9ba8b52f5da..aa1fe14ba88 100644 --- a/src/libcore/util.rs +++ b/src/libcore/util.rs @@ -5,25 +5,25 @@ Miscellaneous helpers for common patterns. */ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; use cmp::Eq; /// The identity function. #[inline(always)] -pub pure fn id<T>(+x: T) -> T { move x } +pub pure fn id<T>(x: T) -> T { move x } /// Ignores a value. #[inline(always)] -pub pure fn ignore<T>(+_x: T) { } +pub pure fn ignore<T>(_x: T) { } /// Sets `*ptr` to `new_value`, invokes `op()`, and then restores the /// original value of `*ptr`. #[inline(always)] pub fn with<T: Copy, R>( ptr: &mut T, - +new_value: T, + new_value: T, op: &fn() -> R) -> R { // NDM: if swap operator were defined somewhat differently, @@ -50,7 +50,7 @@ pub fn swap<T>(x: &mut T, y: &mut T) { * value, without deinitialising or copying either one. */ #[inline(always)] -pub fn replace<T>(dest: &mut T, +src: T) -> T { +pub fn replace<T>(dest: &mut T, src: T) -> T { let mut tmp <- src; swap(dest, &mut tmp); move tmp diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index ce82215a87c..0c822bd0a03 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -47,7 +47,7 @@ pub pure fn same_length<T, U>(xs: &[const T], ys: &[const U]) -> bool { * * v - A vector * * n - The number of elements to reserve space for */ -pub fn reserve<T>(+v: &mut ~[T], +n: uint) { +pub fn reserve<T>(v: &mut ~[T], n: uint) { // Only make the (slow) call into the runtime if we have to if capacity(v) < n { unsafe { @@ -119,7 +119,7 @@ pub pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> ~[T] { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value `t`. */ -pub pure fn from_elem<T: Copy>(n_elts: uint, +t: T) -> ~[T] { +pub pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> ~[T] { from_fn(n_elts, |_i| copy t) } @@ -148,9 +148,9 @@ pub pure fn with_capacity<T>(capacity: uint) -> ~[T] { */ #[inline(always)] pub pure fn build_sized<A>(size: uint, - builder: fn(push: pure fn(+v: A))) -> ~[A] { + builder: fn(push: pure fn(v: A))) -> ~[A] { let mut vec = with_capacity(size); - builder(|+x| unsafe { vec.push(move x) }); + builder(|x| unsafe { vec.push(move x) }); move vec } @@ -165,7 +165,7 @@ pub pure fn build_sized<A>(size: uint, * onto the vector being constructed. */ #[inline(always)] -pub pure fn build<A>(builder: fn(push: pure fn(+v: A))) -> ~[A] { +pub pure fn build<A>(builder: fn(push: pure fn(v: A))) -> ~[A] { build_sized(4, builder) } @@ -183,17 +183,17 @@ pub pure fn build<A>(builder: fn(push: pure fn(+v: A))) -> ~[A] { */ #[inline(always)] pub pure fn build_sized_opt<A>(size: Option<uint>, - builder: fn(push: pure fn(+v: A))) -> ~[A] { + builder: fn(push: pure fn(v: A))) -> ~[A] { build_sized(size.get_default(4), builder) } /// Produces a mut vector from an immutable vector. -pub pure fn to_mut<T>(+v: ~[T]) -> ~[mut T] { +pub pure fn to_mut<T>(v: ~[T]) -> ~[mut T] { unsafe { ::cast::transmute(move v) } } /// Produces an immutable vector from a mut vector. -pub pure fn from_mut<T>(+v: ~[mut T]) -> ~[T] { +pub pure fn from_mut<T>(v: ~[mut T]) -> ~[T] { unsafe { ::cast::transmute(move v) } } @@ -412,13 +412,13 @@ pub fn shift<T>(v: &mut ~[T]) -> T { } /// Prepend an element to the vector -pub fn unshift<T>(v: &mut ~[T], +x: T) { +pub fn unshift<T>(v: &mut ~[T], x: T) { let mut vv = ~[move x]; *v <-> vv; v.push_all_move(vv); } -pub fn consume<T>(+v: ~[T], f: fn(uint, +v: T)) unsafe { +pub fn consume<T>(v: ~[T], f: fn(uint, v: T)) unsafe { let mut v = move v; // FIXME(#3488) do as_imm_buf(v) |p, ln| { @@ -431,7 +431,7 @@ pub fn consume<T>(+v: ~[T], f: fn(uint, +v: T)) unsafe { raw::set_len(&mut v, 0); } -pub fn consume_mut<T>(+v: ~[mut T], f: fn(uint, +v: T)) { +pub fn consume_mut<T>(v: ~[mut T], f: fn(uint, v: T)) { consume(vec::from_mut(v), f) } @@ -468,7 +468,7 @@ pub fn swap_remove<T>(v: &mut ~[T], index: uint) -> T { /// Append an element to a vector #[inline(always)] -pub fn push<T>(v: &mut ~[T], +initval: T) { +pub fn push<T>(v: &mut ~[T], initval: T) { unsafe { let repr: **raw::VecRepr = ::cast::transmute(copy v); let fill = (**repr).unboxed.fill; @@ -483,7 +483,7 @@ pub fn push<T>(v: &mut ~[T], +initval: T) { // This doesn't bother to make sure we have space. #[inline(always)] // really pretty please -unsafe fn push_fast<T>(+v: &mut ~[T], +initval: T) { +unsafe fn push_fast<T>(v: &mut ~[T], initval: T) { let repr: **raw::VecRepr = ::cast::transmute(v); let fill = (**repr).unboxed.fill; (**repr).unboxed.fill += sys::size_of::<T>(); @@ -493,13 +493,13 @@ unsafe fn push_fast<T>(+v: &mut ~[T], +initval: T) { } #[inline(never)] -fn push_slow<T>(+v: &mut ~[T], +initval: T) { +fn push_slow<T>(v: &mut ~[T], initval: T) { reserve_at_least(v, v.len() + 1u); unsafe { push_fast(v, move initval) } } #[inline(always)] -pub fn push_all<T: Copy>(+v: &mut ~[T], rhs: &[const T]) { +pub fn push_all<T: Copy>(v: &mut ~[T], rhs: &[const T]) { reserve(v, v.len() + rhs.len()); for uint::range(0u, rhs.len()) |i| { @@ -508,7 +508,7 @@ pub fn push_all<T: Copy>(+v: &mut ~[T], rhs: &[const T]) { } #[inline(always)] -pub fn push_all_move<T>(v: &mut ~[T], +rhs: ~[T]) { +pub fn push_all_move<T>(v: &mut ~[T], rhs: ~[T]) { let mut rhs = move rhs; // FIXME(#3488) reserve(v, v.len() + rhs.len()); unsafe { @@ -573,7 +573,7 @@ pub fn dedup<T: Eq>(v: &mut ~[T]) unsafe { // Appending #[inline(always)] -pub pure fn append<T: Copy>(+lhs: ~[T], rhs: &[const T]) -> ~[T] { +pub pure fn append<T: Copy>(lhs: ~[T], rhs: &[const T]) -> ~[T] { let mut v <- lhs; unsafe { v.push_all(rhs); @@ -582,14 +582,14 @@ pub pure fn append<T: Copy>(+lhs: ~[T], rhs: &[const T]) -> ~[T] { } #[inline(always)] -pub pure fn append_one<T>(+lhs: ~[T], +x: T) -> ~[T] { +pub pure fn append_one<T>(lhs: ~[T], x: T) -> ~[T] { let mut v <- lhs; unsafe { v.push(move x); } move v } #[inline(always)] -pure fn append_mut<T: Copy>(+lhs: ~[mut T], rhs: &[const T]) -> ~[mut T] { +pure fn append_mut<T: Copy>(lhs: ~[mut T], rhs: &[const T]) -> ~[mut T] { to_mut(append(from_mut(lhs), rhs)) } @@ -642,7 +642,7 @@ pub fn grow_fn<T>(v: &mut ~[T], n: uint, op: iter::InitOp<T>) { * of the vector, expands the vector by replicating `initval` to fill the * intervening space. */ -pub fn grow_set<T: Copy>(v: &mut ~[T], index: uint, initval: &T, +val: T) { +pub fn grow_set<T: Copy>(v: &mut ~[T], index: uint, initval: &T, val: T) { let l = v.len(); if index >= l { grow(v, index - l + 1u, initval); } v[index] = move val; @@ -661,7 +661,7 @@ pub pure fn map<T, U>(v: &[T], f: fn(t: &T) -> U) -> ~[U] { move result } -pub fn map_consume<T, U>(+v: ~[T], f: fn(+v: T) -> U) -> ~[U] { +pub fn map_consume<T, U>(v: ~[T], f: fn(v: T) -> U) -> ~[U] { let mut result = ~[]; do consume(move v) |_i, x| { result.push(f(move x)); @@ -758,7 +758,7 @@ pub pure fn connect<T: Copy>(v: &[~[T]], sep: &T) -> ~[T] { } /// Reduce a vector from left to right -pub pure fn foldl<T: Copy, U>(+z: T, v: &[U], p: fn(+t: T, u: &U) -> T) -> T { +pub pure fn foldl<T: Copy, U>(z: T, v: &[U], p: fn(t: T, u: &U) -> T) -> T { let mut accum = z; for each(v) |elt| { // it should be possible to move accum in, but the liveness analysis @@ -769,7 +769,7 @@ pub pure fn foldl<T: Copy, U>(+z: T, v: &[U], p: fn(+t: T, u: &U) -> T) -> T { } /// Reduce a vector from right to left -pub pure fn foldr<T, U: Copy>(v: &[T], +z: U, p: fn(t: &T, +u: U) -> U) -> U { +pub pure fn foldr<T, U: Copy>(v: &[T], z: U, p: fn(t: &T, u: U) -> U) -> U { let mut accum = z; for rev_each(v) |elt| { accum = p(elt, accum); @@ -992,7 +992,7 @@ pure fn unzip_slice<T: Copy, U: Copy>(v: &[(T, U)]) -> (~[T], ~[U]) { * and the i-th element of the second vector contains the second element * of the i-th tuple of the input vector. */ -pub pure fn unzip<T,U>(+v: ~[(T, U)]) -> (~[T], ~[U]) { +pub pure fn unzip<T,U>(v: ~[(T, U)]) -> (~[T], ~[U]) { let mut ts = ~[], us = ~[]; unsafe { do consume(move v) |_i, p| { @@ -1023,7 +1023,7 @@ pub pure fn zip_slice<T: Copy, U: Copy>(v: &[const T], u: &[const U]) * Returns a vector of tuples, where the i-th tuple contains contains the * i-th elements from each of the input vectors. */ -pub pure fn zip<T, U>(+v: ~[T], +u: ~[U]) -> ~[(T, U)] { +pub pure fn zip<T, U>(v: ~[T], u: ~[U]) -> ~[(T, U)] { let mut v = move v, u = move u; // FIXME(#3488) let mut i = len(v); assert i == len(u); @@ -1190,7 +1190,7 @@ pub fn each2<U, T>(v1: &[U], v2: &[T], f: fn(u: &U, t: &T) -> bool) { * The total number of permutations produced is `len(v)!`. If `v` contains * repeated elements, then some permutations are repeated. */ -pure fn each_permutation<T: Copy>(+v: &[T], put: fn(ts: &[T]) -> bool) { +pure fn each_permutation<T: Copy>(v: &[T], put: fn(ts: &[T]) -> bool) { let ln = len(v); if ln <= 1 { put(v); @@ -1435,7 +1435,7 @@ impl<T: Copy> &[const T]: CopyableVector<T> { pub trait ImmutableVector<T> { pure fn view(start: uint, end: uint) -> &self/[T]; - pure fn foldr<U: Copy>(+z: U, p: fn(t: &T, +u: U) -> U) -> U; + pure fn foldr<U: Copy>(z: U, p: fn(t: &T, u: U) -> U) -> U; pure fn map<U>(f: fn(t: &T) -> U) -> ~[U]; pure fn mapi<U>(f: fn(uint, t: &T) -> U) -> ~[U]; fn map_r<U>(f: fn(x: &T) -> U) -> ~[U]; @@ -1459,7 +1459,7 @@ impl<T> &[T]: ImmutableVector<T> { } /// Reduce a vector from right to left #[inline] - pure fn foldr<U: Copy>(+z: U, p: fn(t: &T, +u: U) -> U) -> U { + pure fn foldr<U: Copy>(z: U, p: fn(t: &T, u: U) -> U) -> U { foldr(self, z, p) } /// Apply a function to each element of a vector and return the results @@ -1582,11 +1582,11 @@ impl<T: Copy> &[T]: ImmutableCopyableVector<T> { } pub trait MutableVector<T> { - fn push(&mut self, +t: T); - fn push_all_move(&mut self, +rhs: ~[T]); + fn push(&mut self, t: T); + fn push_all_move(&mut self, rhs: ~[T]); fn pop(&mut self) -> T; fn shift(&mut self) -> T; - fn unshift(&mut self, +x: T); + fn unshift(&mut self, x: T); fn swap_remove(&mut self, index: uint) -> T; fn truncate(&mut self, newlen: uint); } @@ -1595,7 +1595,7 @@ pub trait MutableCopyableVector<T: Copy> { fn push_all(&mut self, rhs: &[const T]); fn grow(&mut self, n: uint, initval: &T); fn grow_fn(&mut self, n: uint, op: iter::InitOp<T>); - fn grow_set(&mut self, index: uint, initval: &T, +val: T); + fn grow_set(&mut self, index: uint, initval: &T, val: T); } trait MutableEqVector<T: Eq> { @@ -1603,11 +1603,11 @@ trait MutableEqVector<T: Eq> { } impl<T> ~[T]: MutableVector<T> { - fn push(&mut self, +t: T) { + fn push(&mut self, t: T) { push(self, move t); } - fn push_all_move(&mut self, +rhs: ~[T]) { + fn push_all_move(&mut self, rhs: ~[T]) { push_all_move(self, move rhs); } @@ -1619,7 +1619,7 @@ impl<T> ~[T]: MutableVector<T> { shift(self) } - fn unshift(&mut self, +x: T) { + fn unshift(&mut self, x: T) { unshift(self, x) } @@ -1645,7 +1645,7 @@ impl<T: Copy> ~[T]: MutableCopyableVector<T> { grow_fn(self, n, op); } - fn grow_set(&mut self, index: uint, initval: &T, +val: T) { + fn grow_set(&mut self, index: uint, initval: &T, val: T) { grow_set(self, index, initval, val); } } @@ -1717,21 +1717,21 @@ pub mod raw { * would also make any pointers to it invalid. */ #[inline(always)] - pub unsafe fn to_ptr<T>(+v: &[T]) -> *T { + pub unsafe fn to_ptr<T>(v: &[T]) -> *T { let repr: **SliceRepr = ::cast::transmute(&v); return ::cast::reinterpret_cast(&addr_of(&((**repr).data))); } /** see `to_ptr()` */ #[inline(always)] - pub unsafe fn to_const_ptr<T>(+v: &[const T]) -> *const T { + pub unsafe fn to_const_ptr<T>(v: &[const T]) -> *const T { let repr: **SliceRepr = ::cast::transmute(&v); return ::cast::reinterpret_cast(&addr_of(&((**repr).data))); } /** see `to_ptr()` */ #[inline(always)] - pub unsafe fn to_mut_ptr<T>(+v: &[mut T]) -> *mut T { + pub unsafe fn to_mut_ptr<T>(v: &[mut T]) -> *mut T { let repr: **SliceRepr = ::cast::transmute(&v); return ::cast::reinterpret_cast(&addr_of(&((**repr).data))); } @@ -1764,7 +1764,7 @@ pub mod raw { * is newly allocated. */ #[inline(always)] - pub unsafe fn init_elem<T>(v: &[mut T], i: uint, +val: T) { + pub unsafe fn init_elem<T>(v: &[mut T], i: uint, val: T) { let mut box = Some(move val); do as_mut_buf(v) |p, _len| { let mut box2 = None; @@ -1896,7 +1896,7 @@ impl<A> &[A]: iter::ExtendedIter<A> { } pub pure fn all(blk: fn(&A) -> bool) -> bool { iter::all(&self, blk) } pub pure fn any(blk: fn(&A) -> bool) -> bool { iter::any(&self, blk) } - pub pure fn foldl<B>(+b0: B, blk: fn(&B, &A) -> B) -> B { + pub pure fn foldl<B>(b0: B, blk: fn(&B, &A) -> B) -> B { iter::foldl(&self, move b0, blk) } pub pure fn position(f: fn(&A) -> bool) -> Option<uint> { @@ -1910,10 +1910,10 @@ impl<A: Eq> &[A]: iter::EqIter<A> { } impl<A: Copy> &[A]: iter::CopyableIter<A> { - pure fn filter_to_vec(pred: fn(+a: A) -> bool) -> ~[A] { + pure fn filter_to_vec(pred: fn(a: A) -> bool) -> ~[A] { iter::filter_to_vec(&self, pred) } - pure fn map_to_vec<B>(op: fn(+v: A) -> B) -> ~[B] { + pure fn map_to_vec<B>(op: fn(v: A) -> B) -> ~[B] { iter::map_to_vec(&self, op) } pure fn to_vec() -> ~[A] { iter::to_vec(&self) } @@ -1923,7 +1923,7 @@ impl<A: Copy> &[A]: iter::CopyableIter<A> { // iter::flat_map_to_vec(self, op) // } - pub pure fn find(p: fn(+a: A) -> bool) -> Option<A> { + pub pure fn find(p: fn(a: A) -> bool) -> Option<A> { iter::find(&self, p) } } @@ -1951,7 +1951,7 @@ mod tests { return if *n % 2u == 1u { Some(*n * *n) } else { None }; } - fn add(+x: uint, y: &uint) -> uint { return x + *y; } + fn add(x: uint, y: &uint) -> uint { return x + *y; } #[test] fn test_unsafe_ptrs() { @@ -2193,7 +2193,7 @@ mod tests { #[test] fn test_dedup() { - fn case(+a: ~[uint], +b: ~[uint]) { + fn case(a: ~[uint], b: ~[uint]) { let mut v = a; v.dedup(); assert(v == b); @@ -2323,7 +2323,7 @@ mod tests { #[test] fn test_foldl2() { - fn sub(+a: int, b: &int) -> int { + fn sub(a: int, b: &int) -> int { a - *b } let mut v = ~[1, 2, 3, 4]; @@ -2333,7 +2333,7 @@ mod tests { #[test] fn test_foldr() { - fn sub(a: &int, +b: int) -> int { + fn sub(a: &int, b: int) -> int { *a - b } let mut v = ~[1, 2, 3, 4]; diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index a04eadb7732..67bbff7fb6a 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -232,7 +232,7 @@ type Result = result::Result<Matches, Fail_>; */ fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe { let n_opts = vec::len::<Opt>(opts); - fn f(_x: uint) -> ~[Optval] { return ~[]; } + fn f(+_x: uint) -> ~[Optval] { return ~[]; } let vals = vec::to_mut(vec::from_fn(n_opts, f)); let mut free: ~[~str] = ~[]; let l = vec::len(args); diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index aedd53d41cc..59cb0d36f77 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -763,7 +763,7 @@ impl TcpSocket { /// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket` impl TcpSocketBuf: io::Reader { - fn read(buf: &[mut u8], len: uint) -> uint { + fn read(buf: &[mut u8], +len: uint) -> uint { // Loop until our buffer has enough data in it for us to read from. while self.data.buf.len() < len { let read_result = read(&self.data.sock, 0u); @@ -799,13 +799,13 @@ impl TcpSocketBuf: io::Reader { let mut bytes = ~[0]; if self.read(bytes, 1u) == 0 { fail } else { bytes[0] as int } } - fn unread_byte(amt: int) { + fn unread_byte(+amt: int) { self.data.buf.unshift(amt as u8); } fn eof() -> bool { false // noop } - fn seek(dist: int, seek: io::SeekStyle) { + fn seek(+dist: int, +seek: io::SeekStyle) { log(debug, fmt!("tcp_socket_buf seek stub %? %?", dist, seek)); // noop } @@ -827,7 +827,7 @@ impl TcpSocketBuf: io::Writer { err_data.err_name, err_data.err_msg)); } } - fn seek(dist: int, seek: io::SeekStyle) { + fn seek(+dist: int, +seek: io::SeekStyle) { log(debug, fmt!("tcp_socket_buf seek stub %? %?", dist, seek)); // noop } diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 00226c4e81e..920751d690f 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -735,7 +735,7 @@ impl Url : Eq { } impl Url: IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { unsafe { self.to_str() }.iter_bytes(lsb0, f) } } diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 647560099e9..d14a4854555 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -379,7 +379,7 @@ Section: Iterating * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ -pub fn loop_chars(rope: Rope, it: fn(char) -> bool) -> bool { +pub fn loop_chars(rope: Rope, it: fn(+c: char) -> bool) -> bool { match (rope) { node::Empty => return true, node::Content(x) => return node::loop_chars(x, it) @@ -1037,7 +1037,7 @@ mod node { return result; } - pub fn loop_chars(node: @Node, it: fn(char) -> bool) -> bool { + pub fn loop_chars(node: @Node, it: fn(+c: char) -> bool) -> bool { return loop_leaves(node,|leaf| { str::all_between(*leaf.content, leaf.byte_offset, diff --git a/src/libstd/std.rc b/src/libstd/std.rc index aa26c4af29c..95af018e35a 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -18,6 +18,9 @@ not required in or otherwise suitable for the core library. #[no_core]; +// tjc: Added legacy_modes back in because it still uses + mode. +// Remove once + mode gets expunged from std. +#[legacy_modes]; #[legacy_exports]; #[allow(vecs_implicitly_copyable)]; diff --git a/src/rustc/middle/lint.rs b/src/rustc/middle/lint.rs index ebdc66156e3..0f31f2056a1 100644 --- a/src/rustc/middle/lint.rs +++ b/src/rustc/middle/lint.rs @@ -683,8 +683,12 @@ fn check_fn_deprecated_modes(tcx: ty::ctxt, fn_ty: ty::t, decl: ast::fn_decl, mode_to_str(arg_ast.mode)); match arg_ast.mode { ast::expl(ast::by_copy) => { - // This should warn, but we can't yet - // since it's still used. -- tjc + if !tcx.legacy_modes { + tcx.sess.span_lint( + deprecated_mode, id, id, span, + fmt!("argument %d uses by-copy mode", + counter)); + } } ast::expl(_) => { diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index a34fcc89c04..f35a3ce735f 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -251,7 +251,7 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result { colors = do par::mapi_factory(*color_vec) { let colors = arc::clone(&color); let graph = arc::clone(&graph); - fn~(+i: uint, +c: color) -> color { + fn~(i: uint, c: color) -> color { let c : color = c; let colors = arc::get(&colors); let graph = arc::get(&graph); |
