diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-03-25 13:21:04 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-03-26 21:30:17 -0700 |
| commit | 8b56a8380b6cca384f4ade7aa1a07b0c5eb77d60 (patch) | |
| tree | 506d6be2fd2d0699da58cfdf89553310731e0c30 /src/libstd | |
| parent | 15688eaf284b54d29e42b4ec415c23c94e567b23 (diff) | |
| download | rust-8b56a8380b6cca384f4ade7aa1a07b0c5eb77d60.tar.gz rust-8b56a8380b6cca384f4ade7aa1a07b0c5eb77d60.zip | |
librustc: Modify all code to use new lifetime binder syntax
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/arc.rs | 20 | ||||
| -rw-r--r-- | src/libstd/base64.rs | 4 | ||||
| -rw-r--r-- | src/libstd/deque.rs | 2 | ||||
| -rw-r--r-- | src/libstd/flatpipes.rs | 2 | ||||
| -rw-r--r-- | src/libstd/json.rs | 6 | ||||
| -rw-r--r-- | src/libstd/serialize.rs | 6 | ||||
| -rw-r--r-- | src/libstd/smallintmap.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sort.rs | 14 | ||||
| -rw-r--r-- | src/libstd/stats.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sync.rs | 28 | ||||
| -rw-r--r-- | src/libstd/treemap.rs | 19 |
11 files changed, 57 insertions, 50 deletions
diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index d037acff0ed..02c50cc7c98 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -95,7 +95,7 @@ pub fn ARC<T:Const + Owned>(data: T) -> ARC<T> { * Access the underlying data in an atomically reference counted * wrapper. */ -pub fn get<T:Const + Owned>(rc: &'a ARC<T>) -> &'a T { +pub fn get<'a, T:Const + Owned>(rc: &'a ARC<T>) -> &'a T { unsafe { get_shared_immutable_state(&rc.x) } } @@ -191,7 +191,7 @@ pub impl<T:Owned> MutexARC<T> { /// As access(), but with a condvar, as sync::mutex.lock_cond(). #[inline(always)] - unsafe fn access_cond<U>( + unsafe fn access_cond<'x, 'c, U>( &self, blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) -> U { @@ -239,7 +239,7 @@ impl Drop for PoisonOnFail { } } -fn PoisonOnFail(failed: &'r mut bool) -> PoisonOnFail { +fn PoisonOnFail<'r>(failed: &'r mut bool) -> PoisonOnFail { PoisonOnFail { failed: ptr::to_mut_unsafe_ptr(failed) } @@ -313,7 +313,9 @@ pub impl<T:Const + Owned> RWARC<T> { } /// As write(), but with a condvar, as sync::rwlock.write_cond(). #[inline(always)] - fn write_cond<U>(&self, blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) -> U { + fn write_cond<'x, 'c, U>(&self, + blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) + -> U { unsafe { let state = get_shared_mutable_state(&self.x); do (*borrow_rwlock(state)).write_cond |cond| { @@ -375,7 +377,7 @@ pub impl<T:Const + Owned> RWARC<T> { } /// To be called inside of the write_downgrade block. - fn downgrade(&self, token: RWWriteMode<'a, T>) -> RWReadMode<'a, T> { + fn downgrade<'a>(&self, token: RWWriteMode<'a, T>) -> RWReadMode<'a, T> { // The rwlock should assert that the token belongs to us for us. let state = unsafe { get_shared_immutable_state(&self.x) }; let RWWriteMode { @@ -420,7 +422,7 @@ pub struct RWReadMode<'self, T> { token: sync::RWlockReadMode<'self>, } -pub impl<T:Const + Owned> RWWriteMode<'self, T> { +pub impl<'self, T:Const + Owned> RWWriteMode<'self, T> { /// Access the pre-downgrade RWARC in write mode. fn write<U>(&self, blk: &fn(x: &mut T) -> U) -> U { match *self { @@ -436,7 +438,9 @@ pub impl<T:Const + Owned> RWWriteMode<'self, T> { } } /// Access the pre-downgrade RWARC in write mode with a condvar. - fn write_cond<U>(&self, blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) -> U { + fn write_cond<'x, 'c, U>(&self, + blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) + -> U { match *self { RWWriteMode { data: ref data, @@ -458,7 +462,7 @@ pub impl<T:Const + Owned> RWWriteMode<'self, T> { } } -pub impl<T:Const + Owned> RWReadMode<'self, T> { +pub impl<'self, T:Const + Owned> RWReadMode<'self, T> { /// Access the post-downgrade rwlock in read mode. fn read<U>(&self, blk: &fn(x: &T) -> U) -> U { match *self { diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index 02858de9b34..2267d19292c 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -24,7 +24,7 @@ static CHARS: [char * 64] = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' ]; -impl ToBase64 for &'self [u8] { +impl<'self> ToBase64 for &'self [u8] { fn to_base64(&self) -> ~str { let mut s = ~""; unsafe { @@ -73,7 +73,7 @@ impl ToBase64 for &'self [u8] { } } -impl ToBase64 for &'self str { +impl<'self> ToBase64 for &'self str { fn to_base64(&self) -> ~str { str::to_bytes(*self).to_base64() } diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index e6fcbdc84c8..72b68f8fe3a 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -132,7 +132,7 @@ fn grow<T>(nelts: uint, lo: uint, elts: &mut [Option<T>]) -> ~[Option<T>] { rv } -fn get<T>(elts: &'r [Option<T>], i: uint) -> &'r T { +fn get<'r, T>(elts: &'r [Option<T>], i: uint) -> &'r T { match elts[i] { Some(ref t) => t, _ => fail!() } } diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index 01a7cbfe604..1a3a28f7492 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -466,7 +466,7 @@ pub mod flatteners { fn from_writer(w: @Writer) -> Self; } - impl FromReader for json::Decoder<'self> { + impl<'self> FromReader for json::Decoder<'self> { fn from_reader(r: @Reader) -> json::Decoder<'self> { match json::from_reader(r) { Ok(json) => { diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 8b8771e989a..7c9b15bfded 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -741,7 +741,7 @@ pub fn from_str(s: &str) -> Result<Json, Error> { } } -pub struct Decoder { +pub struct Decoder<'self> { priv json: Json, priv mut stack: ~[&'self Json], } @@ -750,7 +750,7 @@ pub fn Decoder(json: Json) -> Decoder { Decoder { json: json, stack: ~[] } } -priv impl Decoder<'self> { +priv impl<'self> Decoder<'self> { fn peek(&self) -> &'self Json { if vec::uniq_len(&const self.stack) == 0 { self.stack.push(&self.json); @@ -766,7 +766,7 @@ priv impl Decoder<'self> { } } -impl serialize::Decoder for Decoder<'self> { +impl<'self> serialize::Decoder for Decoder<'self> { fn read_nil(&self) -> () { debug!("read_nil"); match *self.pop() { diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index d288c06d293..326b9e4dc07 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -213,7 +213,7 @@ impl<D:Decoder> Decodable<D> for i64 { } } -impl<S:Encoder> Encodable<S> for &'self str { +impl<'self, S:Encoder> Encodable<S> for &'self str { fn encode(&self, s: &S) { s.emit_borrowed_str(*self) } } @@ -286,7 +286,7 @@ impl<D:Decoder> Decodable<D> for () { } } -impl<S:Encoder,T:Encodable<S>> Encodable<S> for &'self T { +impl<'self, S:Encoder,T:Encodable<S>> Encodable<S> for &'self T { fn encode(&self, s: &S) { s.emit_borrowed(|| (**self).encode(s)) } @@ -316,7 +316,7 @@ impl<D:Decoder,T:Decodable<D>> Decodable<D> for @T { } } -impl<S:Encoder,T:Encodable<S>> Encodable<S> for &'self [T] { +impl<'self, S:Encoder,T:Encodable<S>> Encodable<S> for &'self [T] { fn encode(&self, s: &S) { do s.emit_borrowed_vec(self.len()) { for self.eachi |i, e| { diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 4ad8d38b072..16f7c0ba860 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -22,7 +22,7 @@ pub struct SmallIntMap<T> { priv v: ~[Option<T>], } -impl<V> BaseIter<(uint, &'self V)> for SmallIntMap<V> { +impl<'self, V> BaseIter<(uint, &'self V)> for SmallIntMap<V> { /// Visit all key-value pairs in order fn each(&self, it: &fn(&(uint, &'self V)) -> bool) { for uint::range(0, self.v.len()) |i| { @@ -36,7 +36,7 @@ impl<V> BaseIter<(uint, &'self V)> for SmallIntMap<V> { fn size_hint(&self) -> Option<uint> { Some(self.len()) } } -impl<V> ReverseIter<(uint, &'self V)> for SmallIntMap<V> { +impl<'self, V> ReverseIter<(uint, &'self V)> for SmallIntMap<V> { /// Visit all key-value pairs in reverse order fn each_reverse(&self, it: &fn(&(uint, &'self V)) -> bool) { for uint::range_rev(self.v.len(), 0) |i| { diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 2d83c4bd9d0..1588d688148 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -16,7 +16,7 @@ use core::util; use core::vec::{len, push}; use core::vec; -type Le<T> = &'self fn(v1: &T, v2: &T) -> bool; +type Le<'self, T> = &'self fn(v1: &T, v2: &T) -> bool; /** * Merge sort. Returns a new vector containing the sorted list. @@ -173,7 +173,7 @@ pub trait Sort { fn qsort(self); } -impl<T:Copy + Ord + Eq> Sort for &'self mut [T] { +impl<'self, T:Copy + Ord + Eq> Sort for &'self mut [T] { fn qsort(self) { quick_sort3(self); } } @@ -1188,7 +1188,7 @@ mod big_tests { } } - struct LVal { + struct LVal<'self> { val: uint, key: &'self fn(@uint), } @@ -1209,16 +1209,16 @@ mod big_tests { } impl<'self> Ord for LVal<'self> { - fn lt(&self, other: &'a LVal<'self>) -> bool { + fn lt<'a>(&self, other: &'a LVal<'self>) -> bool { (*self).val < other.val } - fn le(&self, other: &'a LVal<'self>) -> bool { + fn le<'a>(&self, other: &'a LVal<'self>) -> bool { (*self).val <= other.val } - fn gt(&self, other: &'a LVal<'self>) -> bool { + fn gt<'a>(&self, other: &'a LVal<'self>) -> bool { (*self).val > other.val } - fn ge(&self, other: &'a LVal<'self>) -> bool { + fn ge<'a>(&self, other: &'a LVal<'self>) -> bool { (*self).val >= other.val } } diff --git a/src/libstd/stats.rs b/src/libstd/stats.rs index cecf9686327..04059a49511 100644 --- a/src/libstd/stats.rs +++ b/src/libstd/stats.rs @@ -30,7 +30,7 @@ pub trait Stats { fn median_abs_dev_pct(self) -> f64; } -impl Stats for &'self [f64] { +impl<'self> Stats for &'self [f64] { fn sum(self) -> f64 { vec::foldl(0.0, self, |p,q| p + *q) } diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 22ba33ba04e..ea9455b1e98 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -162,12 +162,12 @@ pub impl Sem<~[Waitqueue]> { // FIXME(#3588) should go inside of access() #[doc(hidden)] -type SemRelease = SemReleaseGeneric<'self, ()>; -type SemAndSignalRelease = SemReleaseGeneric<'self, ~[Waitqueue]>; -struct SemReleaseGeneric<Q> { sem: &'self Sem<Q> } +type SemRelease<'self> = SemReleaseGeneric<'self, ()>; +type SemAndSignalRelease<'self> = SemReleaseGeneric<'self, ~[Waitqueue]>; +struct SemReleaseGeneric<'self, Q> { sem: &'self Sem<Q> } #[unsafe_destructor] -impl<Q:Owned> Drop for SemReleaseGeneric<'self, Q> { +impl<'self, Q:Owned> Drop for SemReleaseGeneric<'self, Q> { fn finalize(&self) { unsafe { self.sem.release(); @@ -175,14 +175,14 @@ impl<Q:Owned> Drop for SemReleaseGeneric<'self, Q> { } } -fn SemRelease(sem: &'r Sem<()>) -> SemRelease<'r> { +fn SemRelease<'r>(sem: &'r Sem<()>) -> SemRelease<'r> { SemReleaseGeneric { sem: sem } } -fn SemAndSignalRelease(sem: &'r Sem<~[Waitqueue]>) - -> SemAndSignalRelease<'r> { +fn SemAndSignalRelease<'r>(sem: &'r Sem<~[Waitqueue]>) + -> SemAndSignalRelease<'r> { SemReleaseGeneric { sem: sem } @@ -194,7 +194,7 @@ pub struct Condvar<'self> { priv sem: &'self Sem<~[Waitqueue]> } #[unsafe_destructor] impl<'self> Drop for Condvar<'self> { fn finalize(&self) {} } -pub impl Condvar<'self> { +pub impl<'self> Condvar<'self> { /** * Atomically drop the associated lock, and block until a signal is sent. * @@ -260,7 +260,7 @@ pub impl Condvar<'self> { // This is needed for a failing condition variable to reacquire the // mutex during unwinding. As long as the wrapper (mutex, etc) is // bounded in when it gets released, this shouldn't hang forever. - struct SemAndSignalReacquire { + struct SemAndSignalReacquire<'self> { sem: &'self Sem<~[Waitqueue]>, } @@ -276,8 +276,8 @@ pub impl Condvar<'self> { } } - fn SemAndSignalReacquire(sem: &'r Sem<~[Waitqueue]>) - -> SemAndSignalReacquire<'r> { + fn SemAndSignalReacquire<'r>(sem: &'r Sem<~[Waitqueue]>) + -> SemAndSignalReacquire<'r> { SemAndSignalReacquire { sem: sem } @@ -615,7 +615,7 @@ pub impl RWlock { // FIXME(#3588) should go inside of read() #[doc(hidden)] -struct RWlockReleaseRead { +struct RWlockReleaseRead<'self> { lock: &'self RWlock, } @@ -651,7 +651,7 @@ fn RWlockReleaseRead<'r>(lock: &'r RWlock) -> RWlockReleaseRead<'r> { // FIXME(#3588) should go inside of downgrade() #[doc(hidden)] #[unsafe_destructor] -struct RWlockReleaseDowngrade { +struct RWlockReleaseDowngrade<'self> { lock: &'self RWlock, } @@ -699,7 +699,7 @@ pub struct RWlockWriteMode<'self> { priv lock: &'self RWlock } impl<'self> Drop for RWlockWriteMode<'self> { fn finalize(&self) {} } /// The "read permission" token used for rwlock.write_downgrade(). -pub struct RWlockReadMode { priv lock: &'self RWlock } +pub struct RWlockReadMode<'self> { priv lock: &'self RWlock } #[unsafe_destructor] impl<'self> Drop for RWlockReadMode<'self> { fn finalize(&self) {} } diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index fccf58ddb6f..9a184ca8682 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -198,7 +198,7 @@ pub impl<K: TotalOrd, V> TreeMap<K, V> { } /// Lazy forward iterator over a map -pub struct TreeMapIterator<K, V> { +pub struct TreeMapIterator<'self, K, V> { priv stack: ~[&'self ~TreeNode<K, V>], priv node: &'self Option<~TreeNode<K, V>> } @@ -537,24 +537,25 @@ pub impl<K: TotalOrd, V> TreeNode<K, V> { } } -fn each<K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>, - f: &fn(&(&'r K, &'r V)) -> bool) { +fn each<'r, K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>, + f: &fn(&(&'r K, &'r V)) -> bool) { for node.each |x| { each(&x.left, f); if f(&(&x.key, &x.value)) { each(&x.right, f) } } } -fn each_reverse<K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>, - f: &fn(&(&'r K, &'r V)) -> bool) { +fn each_reverse<'r, K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>, + f: &fn(&(&'r K, &'r V)) -> bool) { for node.each |x| { each_reverse(&x.right, f); if f(&(&x.key, &x.value)) { each_reverse(&x.left, f) } } } -fn mutate_values<K: TotalOrd, V>(node: &'r mut Option<~TreeNode<K, V>>, - f: &fn(&'r K, &'r mut V) -> bool) -> bool { +fn mutate_values<'r, K: TotalOrd, V>(node: &'r mut Option<~TreeNode<K, V>>, + f: &fn(&'r K, &'r mut V) -> bool) + -> bool { match *node { Some(~TreeNode{key: ref key, value: ref mut value, left: ref mut left, right: ref mut right, _}) => { @@ -590,7 +591,9 @@ fn split<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>) { } } -fn find_mut<K: TotalOrd, V>(node: &'r mut Option<~TreeNode<K, V>>, key: &K) -> Option<&'r mut V> { +fn find_mut<'r, K: TotalOrd, V>(node: &'r mut Option<~TreeNode<K, V>>, + key: &K) + -> Option<&'r mut V> { match *node { Some(ref mut x) => { match key.cmp(&x.key) { |
