diff options
| author | bors <bors@rust-lang.org> | 2013-03-11 10:15:58 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-03-11 10:15:58 -0700 |
| commit | 2ebb67487c1530822d83d6da6f71fa62cb68f2cd (patch) | |
| tree | 7c5b611ac00f1054d51fd657d7fb7d143291fce2 /src/libstd | |
| parent | 51cdca0bf0d3efc554c1815df9306ea10e881a14 (diff) | |
| parent | 08c840205ea477d4f76216abac45be6a4ce9fa4b (diff) | |
| download | rust-2ebb67487c1530822d83d6da6f71fa62cb68f2cd.tar.gz rust-2ebb67487c1530822d83d6da6f71fa62cb68f2cd.zip | |
auto merge of #5291 : pcwalton/rust/drop-lint, r=pcwalton
r? @nikomatsakis
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/arc.rs | 67 | ||||
| -rw-r--r-- | src/libstd/arena.rs | 6 | ||||
| -rw-r--r-- | src/libstd/bitv.rs | 30 | ||||
| -rw-r--r-- | src/libstd/ebml.rs | 70 | ||||
| -rw-r--r-- | src/libstd/fun_treemap.rs | 2 | ||||
| -rw-r--r-- | src/libstd/json.rs | 86 | ||||
| -rw-r--r-- | src/libstd/list.rs | 8 | ||||
| -rw-r--r-- | src/libstd/md4.rs | 2 | ||||
| -rw-r--r-- | src/libstd/oldmap.rs | 14 | ||||
| -rw-r--r-- | src/libstd/prettyprint.rs | 30 | ||||
| -rw-r--r-- | src/libstd/priority_queue.rs | 2 | ||||
| -rw-r--r-- | src/libstd/rl.rs | 2 | ||||
| -rw-r--r-- | src/libstd/rope.rs | 10 | ||||
| -rw-r--r-- | src/libstd/semver.rs | 2 | ||||
| -rw-r--r-- | src/libstd/serialize.rs | 64 | ||||
| -rw-r--r-- | src/libstd/smallintmap.rs | 12 | ||||
| -rw-r--r-- | src/libstd/sync.rs | 35 | ||||
| -rw-r--r-- | src/libstd/treemap.rs | 34 | ||||
| -rw-r--r-- | src/libstd/workcache.rs | 2 |
19 files changed, 253 insertions, 225 deletions
diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index e7503f0082c..d7d878fa192 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -176,7 +176,7 @@ pub impl<T:Owned> MutexARC<T> { * blocked on the mutex) will also fail immediately. */ #[inline(always)] - unsafe fn access<U>(&self, blk: fn(x: &mut T) -> U) -> U { + unsafe fn access<U>(&self, blk: &fn(x: &mut T) -> U) -> U { unsafe { let state = get_shared_mutable_state(&self.x); // Borrowck would complain about this if the function were @@ -301,7 +301,7 @@ pub impl<T:Const + Owned> RWARC<T> { * poison the ARC, so subsequent readers and writers will both also fail. */ #[inline(always)] - fn write<U>(&self, blk: fn(x: &mut T) -> U) -> U { + fn write<U>(&self, blk: &fn(x: &mut T) -> U) -> U { unsafe { let state = get_shared_mutable_state(&self.x); do (*borrow_rwlock(state)).write { @@ -313,7 +313,7 @@ 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<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| { @@ -335,7 +335,7 @@ pub impl<T:Const + Owned> RWARC<T> { * Failing will unlock the ARC while unwinding. However, unlike all other * access modes, this will not poison the ARC. */ - fn read<U>(&self, blk: fn(x: &T) -> U) -> U { + fn read<U>(&self, blk: &fn(x: &T) -> U) -> U { let state = unsafe { get_shared_immutable_state(&self.x) }; do (&state.lock).read { check_poison(false, state.failed); @@ -360,14 +360,16 @@ pub impl<T:Const + Owned> RWARC<T> { * } * ~~~ */ - fn write_downgrade<U>(&self, blk: fn(v: RWWriteMode<T>) -> U) -> U { + fn write_downgrade<U>(&self, blk: &fn(v: RWWriteMode<T>) -> U) -> U { unsafe { let state = get_shared_mutable_state(&self.x); do (*borrow_rwlock(state)).write_downgrade |write_mode| { check_poison(false, (*state).failed); - blk(RWWriteMode((&mut (*state).data, - write_mode, - PoisonOnFail(&mut (*state).failed)))) + blk(RWWriteMode { + data: &mut (*state).data, + token: write_mode, + poison: PoisonOnFail(&mut (*state).failed) + }) } } } @@ -376,7 +378,11 @@ pub impl<T:Const + Owned> RWARC<T> { fn downgrade(&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((data, t, _poison)) = token; + let RWWriteMode { + data: data, + token: t, + poison: _poison + } = token; // Let readers in let new_token = (&state.lock).downgrade(t); // Whatever region the input reference had, it will be safe to use @@ -386,7 +392,10 @@ pub impl<T:Const + Owned> RWARC<T> { // Downgrade ensured the token belonged to us. Just a sanity check. fail_unless!(ptr::ref_eq(&state.data, new_data)); // Produce new token - RWReadMode((new_data, new_token)) + RWReadMode { + data: new_data, + token: new_token, + } } } @@ -398,19 +407,28 @@ fn borrow_rwlock<T:Const + Owned>(state: *const RWARCInner<T>) -> *RWlock { unsafe { cast::transmute(&const (*state).lock) } } -// FIXME (#3154) ice with struct/&<T> prevents these from being structs. - /// The "write permission" token used for RWARC.write_downgrade(). -pub enum RWWriteMode<T> = - (&self/mut T, sync::RWlockWriteMode/&self, PoisonOnFail); +pub struct RWWriteMode<'self, T> { + data: &'self mut T, + token: sync::RWlockWriteMode<'self>, + poison: PoisonOnFail, +} + /// The "read permission" token used for RWARC.write_downgrade(). -pub enum RWReadMode<T> = (&self/T, sync::RWlockReadMode/&self); +pub struct RWReadMode<'self, T> { + data: &'self T, + token: sync::RWlockReadMode<'self>, +} pub impl<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 { + fn write<U>(&self, blk: &fn(x: &mut T) -> U) -> U { match *self { - RWWriteMode((ref data, ref token, _)) => { + RWWriteMode { + data: ref data, + token: ref token, + poison: _ + } => { do token.write { blk(&mut **data) } @@ -418,9 +436,13 @@ 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<U>(&self, blk: &fn(x: &x/mut T, c: &c/Condvar) -> U) -> U { match *self { - RWWriteMode((ref data, ref token, ref poison)) => { + RWWriteMode { + data: ref data, + token: ref token, + poison: ref poison + } => { do token.write_cond |cond| { unsafe { let cvar = Condvar { @@ -438,9 +460,12 @@ pub impl<T:Const + Owned> RWWriteMode/&self<T> { pub impl<T:Const + Owned> RWReadMode/&self<T> { /// Access the post-downgrade rwlock in read mode. - fn read<U>(&self, blk: fn(x: &T) -> U) -> U { + fn read<U>(&self, blk: &fn(x: &T) -> U) -> U { match *self { - RWReadMode((data, ref token)) => { + RWReadMode { + data: data, + token: ref token + } => { do token.read { blk(data) } } } diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index 9ed6d285ce6..695b3d01376 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -201,7 +201,7 @@ pub impl Arena { } #[inline(always)] - fn alloc_pod<T>(&self, op: fn() -> T) -> &self/T { + fn alloc_pod<T>(&self, op: &fn() -> T) -> &self/T { unsafe { let tydesc = sys::get_type_desc::<T>(); let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align); @@ -246,7 +246,7 @@ pub impl Arena { } #[inline(always)] - fn alloc_nonpod<T>(&self, op: fn() -> T) -> &self/T { + fn alloc_nonpod<T>(&self, op: &fn() -> T) -> &self/T { unsafe { let tydesc = sys::get_type_desc::<T>(); let (ty_ptr, ptr) = @@ -268,7 +268,7 @@ pub impl Arena { // The external interface #[inline(always)] - fn alloc<T>(&self, op: fn() -> T) -> &self/T { + fn alloc<T>(&self, op: &fn() -> T) -> &self/T { unsafe { if !rusti::needs_drop::<T>() { self.alloc_pod(op) diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 55ec29d2337..8dbdb83698c 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -33,7 +33,7 @@ pub impl SmallBitv { #[inline(always)] fn bits_op(&mut self, right_bits: uint, nbits: uint, - f: fn(uint, uint) -> uint) -> bool { + f: &fn(uint, uint) -> uint) -> bool { let mask = small_mask(nbits); let old_b: uint = self.bits; let new_b = f(old_b, right_bits); @@ -130,7 +130,7 @@ pub impl BigBitv { #[inline(always)] fn process(&mut self, b: &BigBitv, nbits: uint, - op: fn(uint, uint) -> uint) -> bool { + op: &fn(uint, uint) -> uint) -> bool { let len = b.storage.len(); fail_unless!((self.storage.len() == len)); let mut changed = false; @@ -148,7 +148,7 @@ pub impl BigBitv { } #[inline(always)] - fn each_storage(&mut self, op: fn(v: &mut uint) -> bool) { + fn each_storage(&mut self, op: &fn(v: &mut uint) -> bool) { for uint::range(0, self.storage.len()) |i| { let mut w = self.storage[i]; let b = op(&mut w); @@ -392,7 +392,7 @@ pub impl Bitv { } #[inline(always)] - fn each(&self, f: fn(bool) -> bool) { + fn each(&self, f: &fn(bool) -> bool) { let mut i = 0; while i < self.nbits { if !f(self.get(i)) { break; } @@ -493,7 +493,7 @@ pub impl Bitv { true } - fn ones(&self, f: fn(uint) -> bool) { + fn ones(&self, f: &fn(uint) -> bool) { for uint::range(0, self.nbits) |i| { if self.get(i) { if !f(i) { break } @@ -546,7 +546,7 @@ pub fn from_bools(bools: &[bool]) -> Bitv { * Create a bitv of the specified length where the value at each * index is f(index). */ -pub fn from_fn(len: uint, f: fn(index: uint) -> bool) -> Bitv { +pub fn from_fn(len: uint, f: &fn(index: uint) -> bool) -> Bitv { let mut bitv = Bitv::new(len, false); for uint::range(0, len) |i| { bitv.set(i, f(i)); @@ -561,7 +561,7 @@ impl ops::Index<uint,bool> for Bitv { } #[inline(always)] -pure fn iterate_bits(base: uint, bits: uint, f: fn(uint) -> bool) -> bool { +pure fn iterate_bits(base: uint, bits: uint, f: &fn(uint) -> bool) -> bool { if bits == 0 { return true; } @@ -622,7 +622,7 @@ pub impl BitvSet { } #[inline(always)] - priv fn other_op(&mut self, other: &BitvSet, f: fn(uint, uint) -> uint) { + priv fn other_op(&mut self, other: &BitvSet, f: &fn(uint, uint) -> uint) { fn nbits(mut w: uint) -> uint { let mut bits = 0; for uint::bits.times { @@ -669,7 +669,7 @@ pub impl BitvSet { impl BaseIter<uint> for BitvSet { pure fn size_hint(&self) -> Option<uint> { Some(self.len()) } - pure fn each(&self, blk: fn(v: &uint) -> bool) { + pure fn each(&self, blk: &fn(v: &uint) -> bool) { for self.bitv.storage.eachi |i, &w| { if !iterate_bits(i * uint::bits, w, |b| blk(&b)) { return; @@ -778,7 +778,7 @@ impl Set<uint> for BitvSet { other.is_subset(self) } - pure fn difference(&self, other: &BitvSet, f: fn(&uint) -> bool) { + pure fn difference(&self, other: &BitvSet, f: &fn(&uint) -> bool) { for self.each_common(other) |i, w1, w2| { if !iterate_bits(i, w1 & !w2, |b| f(&b)) { return; @@ -791,7 +791,7 @@ impl Set<uint> for BitvSet { } pure fn symmetric_difference(&self, other: &BitvSet, - f: fn(&uint) -> bool) { + f: &fn(&uint) -> bool) { for self.each_common(other) |i, w1, w2| { if !iterate_bits(i, w1 ^ w2, |b| f(&b)) { return; @@ -802,7 +802,7 @@ impl Set<uint> for BitvSet { ); } - pure fn intersection(&self, other: &BitvSet, f: fn(&uint) -> bool) { + pure fn intersection(&self, other: &BitvSet, f: &fn(&uint) -> bool) { for self.each_common(other) |i, w1, w2| { if !iterate_bits(i, w1 & w2, |b| f(&b)) { return; @@ -810,7 +810,7 @@ impl Set<uint> for BitvSet { } } - pure fn union(&self, other: &BitvSet, f: fn(&uint) -> bool) { + pure fn union(&self, other: &BitvSet, f: &fn(&uint) -> bool) { for self.each_common(other) |i, w1, w2| { if !iterate_bits(i, w1 | w2, |b| f(&b)) { return; @@ -828,7 +828,7 @@ priv impl BitvSet { /// w1, w2) where the bit location is the number of bits offset so far, /// and w1/w2 are the words coming from the two vectors self, other. pure fn each_common(&self, other: &BitvSet, - f: fn(uint, uint, uint) -> bool) { + f: &fn(uint, uint, uint) -> bool) { let min = uint::min(self.bitv.storage.len(), other.bitv.storage.len()); for self.bitv.storage.view(0, min).eachi |i, &w| { @@ -846,7 +846,7 @@ priv impl BitvSet { /// is true if the word comes from 'self', and false if it comes from /// 'other'. pure fn each_outlier(&self, other: &BitvSet, - f: fn(bool, uint, uint) -> bool) { + f: &fn(bool, uint, uint) -> bool) { let len1 = self.bitv.storage.len(); let len2 = other.bitv.storage.len(); let min = uint::min(len1, len2); diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 44461ae06ff..a55d4bc97ec 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -142,7 +142,7 @@ pub mod reader { } } - pub fn docs(d: Doc, it: fn(uint, Doc) -> bool) { + pub fn docs(d: Doc, it: &fn(uint, Doc) -> bool) { let mut pos = d.start; while pos < d.end { let elt_tag = vuint_at(*d.data, pos); @@ -155,7 +155,7 @@ pub mod reader { } } - pub fn tagged_docs(d: Doc, tg: uint, it: fn(Doc) -> bool) { + pub fn tagged_docs(d: Doc, tg: uint, it: &fn(Doc) -> bool) { let mut pos = d.start; while pos < d.end { let elt_tag = vuint_at(*d.data, pos); @@ -175,7 +175,7 @@ pub mod reader { vec::slice::<u8>(*d.data, d.start, d.end).to_vec() } - pub fn with_doc_data<T>(d: Doc, f: fn(x: &[u8]) -> T) -> T { + pub fn with_doc_data<T>(d: Doc, f: &fn(x: &[u8]) -> T) -> T { f(vec::slice(*d.data, d.start, d.end)) } @@ -255,7 +255,7 @@ pub mod reader { r_doc } - fn push_doc<T>(&self, d: Doc, f: fn() -> T) -> T { + fn push_doc<T>(&self, d: Doc, f: &fn() -> T) -> T { let old_parent = self.parent; let old_pos = self.pos; self.parent = d; @@ -274,7 +274,7 @@ pub mod reader { } pub impl Decoder { - fn read_opaque<R>(&self, op: fn(Doc) -> R) -> R { + fn read_opaque<R>(&self, op: &fn(Doc) -> R) -> R { do self.push_doc(self.next_doc(EsOpaque)) { op(copy self.parent) } @@ -321,23 +321,23 @@ pub mod reader { fn read_managed_str(&self) -> @str { fail!(~"read_managed_str()"); } // Compound types: - fn read_owned<T>(&self, f: fn() -> T) -> T { + fn read_owned<T>(&self, f: &fn() -> T) -> T { debug!("read_owned()"); f() } - fn read_managed<T>(&self, f: fn() -> T) -> T { + fn read_managed<T>(&self, f: &fn() -> T) -> T { debug!("read_managed()"); f() } - fn read_enum<T>(&self, name: &str, f: fn() -> T) -> T { + fn read_enum<T>(&self, name: &str, f: &fn() -> T) -> T { debug!("read_enum(%s)", name); self._check_label(name); self.push_doc(self.next_doc(EsEnum), f) } - fn read_enum_variant<T>(&self, f: fn(uint) -> T) -> T { + fn read_enum_variant<T>(&self, f: &fn(uint) -> T) -> T { debug!("read_enum_variant()"); let idx = self._next_uint(EsEnumVid); debug!(" idx=%u", idx); @@ -346,12 +346,12 @@ pub mod reader { } } - fn read_enum_variant_arg<T>(&self, idx: uint, f: fn() -> T) -> T { + fn read_enum_variant_arg<T>(&self, idx: uint, f: &fn() -> T) -> T { debug!("read_enum_variant_arg(idx=%u)", idx); f() } - fn read_owned_vec<T>(&self, f: fn(uint) -> T) -> T { + fn read_owned_vec<T>(&self, f: &fn(uint) -> T) -> T { debug!("read_owned_vec()"); do self.push_doc(self.next_doc(EsVec)) { let len = self._next_uint(EsVecLen); @@ -360,7 +360,7 @@ pub mod reader { } } - fn read_managed_vec<T>(&self, f: fn(uint) -> T) -> T { + fn read_managed_vec<T>(&self, f: &fn(uint) -> T) -> T { debug!("read_managed_vec()"); do self.push_doc(self.next_doc(EsVec)) { let len = self._next_uint(EsVecLen); @@ -369,33 +369,33 @@ pub mod reader { } } - fn read_vec_elt<T>(&self, idx: uint, f: fn() -> T) -> T { + fn read_vec_elt<T>(&self, idx: uint, f: &fn() -> T) -> T { debug!("read_vec_elt(idx=%u)", idx); self.push_doc(self.next_doc(EsVecElt), f) } - fn read_rec<T>(&self, f: fn() -> T) -> T { + fn read_rec<T>(&self, f: &fn() -> T) -> T { debug!("read_rec()"); f() } - fn read_struct<T>(&self, name: &str, _len: uint, f: fn() -> T) -> T { + fn read_struct<T>(&self, name: &str, _len: uint, f: &fn() -> T) -> T { debug!("read_struct(name=%s)", name); f() } - fn read_field<T>(&self, name: &str, idx: uint, f: fn() -> T) -> T { + fn read_field<T>(&self, name: &str, idx: uint, f: &fn() -> T) -> T { debug!("read_field(name=%s, idx=%u)", name, idx); self._check_label(name); f() } - fn read_tup<T>(&self, len: uint, f: fn() -> T) -> T { + fn read_tup<T>(&self, len: uint, f: &fn() -> T) -> T { debug!("read_tup(len=%u)", len); f() } - fn read_tup_elt<T>(&self, idx: uint, f: fn() -> T) -> T { + fn read_tup_elt<T>(&self, idx: uint, f: &fn() -> T) -> T { debug!("read_tup_elt(idx=%u)", idx); f() } @@ -469,7 +469,7 @@ pub mod writer { debug!("End tag (size = %u)", size); } - fn wr_tag(&self, tag_id: uint, blk: fn()) { + fn wr_tag(&self, tag_id: uint, blk: &fn()) { self.start_tag(tag_id); blk(); self.end_tag(); @@ -566,7 +566,7 @@ pub mod writer { } pub impl Encoder { - fn emit_opaque(&self, f: fn()) { + fn emit_opaque(&self, f: &fn()) { do self.wr_tag(EsOpaque as uint) { f() } @@ -623,49 +623,49 @@ pub mod writer { self.emit_borrowed_str(v) } - fn emit_borrowed(&self, f: fn()) { f() } - fn emit_owned(&self, f: fn()) { f() } - fn emit_managed(&self, f: fn()) { f() } + fn emit_borrowed(&self, f: &fn()) { f() } + fn emit_owned(&self, f: &fn()) { f() } + fn emit_managed(&self, f: &fn()) { f() } - fn emit_enum(&self, name: &str, f: fn()) { + fn emit_enum(&self, name: &str, f: &fn()) { self._emit_label(name); self.wr_tag(EsEnum as uint, f) } fn emit_enum_variant(&self, _v_name: &str, v_id: uint, _cnt: uint, - f: fn()) { + f: &fn()) { self._emit_tagged_uint(EsEnumVid, v_id); self.wr_tag(EsEnumBody as uint, f) } - fn emit_enum_variant_arg(&self, _idx: uint, f: fn()) { f() } + fn emit_enum_variant_arg(&self, _idx: uint, f: &fn()) { f() } - fn emit_borrowed_vec(&self, len: uint, f: fn()) { + fn emit_borrowed_vec(&self, len: uint, f: &fn()) { do self.wr_tag(EsVec as uint) { self._emit_tagged_uint(EsVecLen, len); f() } } - fn emit_owned_vec(&self, len: uint, f: fn()) { + fn emit_owned_vec(&self, len: uint, f: &fn()) { self.emit_borrowed_vec(len, f) } - fn emit_managed_vec(&self, len: uint, f: fn()) { + fn emit_managed_vec(&self, len: uint, f: &fn()) { self.emit_borrowed_vec(len, f) } - fn emit_vec_elt(&self, _idx: uint, f: fn()) { + fn emit_vec_elt(&self, _idx: uint, f: &fn()) { self.wr_tag(EsVecElt as uint, f) } - fn emit_rec(&self, f: fn()) { f() } - fn emit_struct(&self, _name: &str, _len: uint, f: fn()) { f() } - fn emit_field(&self, name: &str, _idx: uint, f: fn()) { + fn emit_rec(&self, f: &fn()) { f() } + fn emit_struct(&self, _name: &str, _len: uint, f: &fn()) { f() } + fn emit_field(&self, name: &str, _idx: uint, f: &fn()) { self._emit_label(name); f() } - fn emit_tup(&self, _len: uint, f: fn()) { f() } - fn emit_tup_elt(&self, _idx: uint, f: fn()) { f() } + fn emit_tup(&self, _len: uint, f: &fn()) { f() } + fn emit_tup_elt(&self, _idx: uint, f: &fn()) { f() } } } diff --git a/src/libstd/fun_treemap.rs b/src/libstd/fun_treemap.rs index 0729987958a..735f86b34ec 100644 --- a/src/libstd/fun_treemap.rs +++ b/src/libstd/fun_treemap.rs @@ -61,7 +61,7 @@ pub fn find<K:Eq + Ord,V:Copy>(m: Treemap<K, V>, k: K) -> Option<V> { } /// Visit all pairs in the map in order. -pub fn traverse<K, V: Copy>(m: Treemap<K, V>, f: fn(&K, &V)) { +pub fn traverse<K, V: Copy>(m: Treemap<K, V>, f: &fn(&K, &V)) { match *m { Empty => (), /* diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 9208d415971..8c6a870b98c 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -116,15 +116,15 @@ impl serialize::Encoder for Encoder { fn emit_owned_str(&self, v: &str) { self.emit_borrowed_str(v) } fn emit_managed_str(&self, v: &str) { self.emit_borrowed_str(v) } - fn emit_borrowed(&self, f: fn()) { f() } - fn emit_owned(&self, f: fn()) { f() } - fn emit_managed(&self, f: fn()) { f() } + fn emit_borrowed(&self, f: &fn()) { f() } + fn emit_owned(&self, f: &fn()) { f() } + fn emit_managed(&self, f: &fn()) { f() } - fn emit_enum(&self, _name: &str, f: fn()) { + fn emit_enum(&self, _name: &str, f: &fn()) { f() } - fn emit_enum_variant(&self, name: &str, _id: uint, _cnt: uint, f: fn()) { + fn emit_enum_variant(&self, name: &str, _id: uint, _cnt: uint, f: &fn()) { // encoding of enums is special-cased for Option. Specifically: // Some(34) => 34 // None => null @@ -160,49 +160,49 @@ impl serialize::Encoder for Encoder { } } - fn emit_enum_variant_arg(&self, idx: uint, f: fn()) { + fn emit_enum_variant_arg(&self, idx: uint, f: &fn()) { if (idx != 0) {self.wr.write_char(',');} f(); } - fn emit_borrowed_vec(&self, _len: uint, f: fn()) { + fn emit_borrowed_vec(&self, _len: uint, f: &fn()) { self.wr.write_char('['); f(); self.wr.write_char(']'); } - fn emit_owned_vec(&self, len: uint, f: fn()) { + fn emit_owned_vec(&self, len: uint, f: &fn()) { self.emit_borrowed_vec(len, f) } - fn emit_managed_vec(&self, len: uint, f: fn()) { + fn emit_managed_vec(&self, len: uint, f: &fn()) { self.emit_borrowed_vec(len, f) } - fn emit_vec_elt(&self, idx: uint, f: fn()) { + fn emit_vec_elt(&self, idx: uint, f: &fn()) { if idx != 0 { self.wr.write_char(','); } f() } - fn emit_rec(&self, f: fn()) { + fn emit_rec(&self, f: &fn()) { self.wr.write_char('{'); f(); self.wr.write_char('}'); } - fn emit_struct(&self, _name: &str, _len: uint, f: fn()) { + fn emit_struct(&self, _name: &str, _len: uint, f: &fn()) { self.wr.write_char('{'); f(); self.wr.write_char('}'); } - fn emit_field(&self, name: &str, idx: uint, f: fn()) { + fn emit_field(&self, name: &str, idx: uint, f: &fn()) { if idx != 0 { self.wr.write_char(','); } self.wr.write_str(escape_str(name)); self.wr.write_char(':'); f(); } - fn emit_tup(&self, len: uint, f: fn()) { + fn emit_tup(&self, len: uint, f: &fn()) { self.emit_borrowed_vec(len, f); } - fn emit_tup_elt(&self, idx: uint, f: fn()) { + fn emit_tup_elt(&self, idx: uint, f: &fn()) { self.emit_vec_elt(idx, f) } } @@ -251,39 +251,39 @@ impl serialize::Encoder for PrettyEncoder { fn emit_owned_str(&self, v: &str) { self.emit_borrowed_str(v) } fn emit_managed_str(&self, v: &str) { self.emit_borrowed_str(v) } - fn emit_borrowed(&self, f: fn()) { f() } - fn emit_owned(&self, f: fn()) { f() } - fn emit_managed(&self, f: fn()) { f() } + fn emit_borrowed(&self, f: &fn()) { f() } + fn emit_owned(&self, f: &fn()) { f() } + fn emit_managed(&self, f: &fn()) { f() } - fn emit_enum(&self, name: &str, f: fn()) { + fn emit_enum(&self, name: &str, f: &fn()) { if name != "option" { fail!(~"only supports option enum") } f() } - fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: fn()) { + fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: &fn()) { if id == 0 { self.emit_nil(); } else { f() } } - fn emit_enum_variant_arg(&self, _idx: uint, f: fn()) { + fn emit_enum_variant_arg(&self, _idx: uint, f: &fn()) { f() } - fn emit_borrowed_vec(&self, _len: uint, f: fn()) { + fn emit_borrowed_vec(&self, _len: uint, f: &fn()) { self.wr.write_char('['); self.indent += 2; f(); self.indent -= 2; self.wr.write_char(']'); } - fn emit_owned_vec(&self, len: uint, f: fn()) { + fn emit_owned_vec(&self, len: uint, f: &fn()) { self.emit_borrowed_vec(len, f) } - fn emit_managed_vec(&self, len: uint, f: fn()) { + fn emit_managed_vec(&self, len: uint, f: &fn()) { self.emit_borrowed_vec(len, f) } - fn emit_vec_elt(&self, idx: uint, f: fn()) { + fn emit_vec_elt(&self, idx: uint, f: &fn()) { if idx == 0 { self.wr.write_char('\n'); } else { @@ -293,17 +293,17 @@ impl serialize::Encoder for PrettyEncoder { f() } - fn emit_rec(&self, f: fn()) { + fn emit_rec(&self, f: &fn()) { self.wr.write_char('{'); self.indent += 2; f(); self.indent -= 2; self.wr.write_char('}'); } - fn emit_struct(&self, _name: &str, _len: uint, f: fn()) { + fn emit_struct(&self, _name: &str, _len: uint, f: &fn()) { self.emit_rec(f) } - fn emit_field(&self, name: &str, idx: uint, f: fn()) { + fn emit_field(&self, name: &str, idx: uint, f: &fn()) { if idx == 0 { self.wr.write_char('\n'); } else { @@ -314,10 +314,10 @@ impl serialize::Encoder for PrettyEncoder { self.wr.write_str(": "); f(); } - fn emit_tup(&self, sz: uint, f: fn()) { + fn emit_tup(&self, sz: uint, f: &fn()) { self.emit_borrowed_vec(sz, f); } - fn emit_tup_elt(&self, idx: uint, f: fn()) { + fn emit_tup_elt(&self, idx: uint, f: &fn()) { self.emit_vec_elt(idx, f) } } @@ -828,23 +828,23 @@ impl serialize::Decoder for Decoder/&self { } } - fn read_owned<T>(&self, f: fn() -> T) -> T { + fn read_owned<T>(&self, f: &fn() -> T) -> T { debug!("read_owned()"); f() } - fn read_managed<T>(&self, f: fn() -> T) -> T { + fn read_managed<T>(&self, f: &fn() -> T) -> T { debug!("read_managed()"); f() } - fn read_enum<T>(&self, name: &str, f: fn() -> T) -> T { + fn read_enum<T>(&self, name: &str, f: &fn() -> T) -> T { debug!("read_enum(%s)", name); if name != ~"option" { fail!(~"only supports the option enum") } f() } - fn read_enum_variant<T>(&self, f: fn(uint) -> T) -> T { + fn read_enum_variant<T>(&self, f: &fn(uint) -> T) -> T { debug!("read_enum_variant()"); let idx = match *self.peek() { Null => 0, @@ -853,13 +853,13 @@ impl serialize::Decoder for Decoder/&self { f(idx) } - fn read_enum_variant_arg<T>(&self, idx: uint, f: fn() -> T) -> T { + fn read_enum_variant_arg<T>(&self, idx: uint, f: &fn() -> T) -> T { debug!("read_enum_variant_arg(idx=%u)", idx); if idx != 0 { fail!(~"unknown index") } f() } - fn read_owned_vec<T>(&self, f: fn(uint) -> T) -> T { + fn read_owned_vec<T>(&self, f: &fn(uint) -> T) -> T { debug!("read_owned_vec()"); let len = match *self.peek() { List(ref list) => list.len(), @@ -870,7 +870,7 @@ impl serialize::Decoder for Decoder/&self { res } - fn read_managed_vec<T>(&self, f: fn(uint) -> T) -> T { + fn read_managed_vec<T>(&self, f: &fn(uint) -> T) -> T { debug!("read_owned_vec()"); let len = match *self.peek() { List(ref list) => list.len(), @@ -881,7 +881,7 @@ impl serialize::Decoder for Decoder/&self { res } - fn read_vec_elt<T>(&self, idx: uint, f: fn() -> T) -> T { + fn read_vec_elt<T>(&self, idx: uint, f: &fn() -> T) -> T { debug!("read_vec_elt(idx=%u)", idx); match *self.peek() { List(ref list) => { @@ -892,21 +892,21 @@ impl serialize::Decoder for Decoder/&self { } } - fn read_rec<T>(&self, f: fn() -> T) -> T { + fn read_rec<T>(&self, f: &fn() -> T) -> T { debug!("read_rec()"); let value = f(); self.pop(); value } - fn read_struct<T>(&self, _name: &str, _len: uint, f: fn() -> T) -> T { + fn read_struct<T>(&self, _name: &str, _len: uint, f: &fn() -> T) -> T { debug!("read_struct()"); let value = f(); self.pop(); value } - fn read_field<T>(&self, name: &str, idx: uint, f: fn() -> T) -> T { + fn read_field<T>(&self, name: &str, idx: uint, f: &fn() -> T) -> T { debug!("read_rec_field(%s, idx=%u)", name, idx); let top = self.peek(); match *top { @@ -929,14 +929,14 @@ impl serialize::Decoder for Decoder/&self { } } - fn read_tup<T>(&self, len: uint, f: fn() -> T) -> T { + fn read_tup<T>(&self, len: uint, f: &fn() -> T) -> T { debug!("read_tup(len=%u)", len); let value = f(); self.pop(); value } - fn read_tup_elt<T>(&self, idx: uint, f: fn() -> T) -> T { + fn read_tup_elt<T>(&self, idx: uint, f: &fn() -> T) -> T { debug!("read_tup_elt(idx=%u)", idx); match *self.peek() { List(ref list) => { diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 5ab1722ae83..3a0f299257e 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -39,7 +39,7 @@ pub pure fn from_vec<T:Copy>(v: &[T]) -> @List<T> { * * z - The initial value * * f - The function to apply */ -pub fn foldl<T:Copy,U>(z: T, ls: @List<U>, f: fn(&T, &U) -> T) -> T { +pub fn foldl<T:Copy,U>(z: T, ls: @List<U>, f: &fn(&T, &U) -> T) -> T { let mut accum: T = z; do iter(ls) |elt| { accum = f(&accum, elt);} accum @@ -52,7 +52,7 @@ pub fn foldl<T:Copy,U>(z: T, ls: @List<U>, 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. */ -pub pure fn find<T:Copy>(ls: @List<T>, f: fn(&T) -> bool) -> Option<T> { +pub pure fn find<T:Copy>(ls: @List<T>, f: &fn(&T) -> bool) -> Option<T> { let mut ls = ls; loop { ls = match *ls { @@ -125,7 +125,7 @@ pure fn push<T:Copy>(ll: &mut @list<T>, vv: T) { */ /// Iterate over a list -pub pure fn iter<T>(l: @List<T>, f: fn(&T)) { +pub pure fn iter<T>(l: @List<T>, f: &fn(&T)) { let mut cur = l; loop { cur = match *cur { @@ -139,7 +139,7 @@ pub pure fn iter<T>(l: @List<T>, f: fn(&T)) { } /// Iterate over a list -pub pure fn each<T>(l: @List<T>, f: fn(&T) -> bool) { +pub pure fn each<T>(l: @List<T>, f: &fn(&T) -> bool) { let mut cur = l; loop { cur = match *cur { diff --git a/src/libstd/md4.rs b/src/libstd/md4.rs index eb4bd6fe23f..df254543512 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -105,7 +105,7 @@ pub pure fn md4(msg: &[u8]) -> Quad { pub pure fn md4_str(msg: &[u8]) -> ~str { let Quad {a, b, c, d} = md4(msg); - pure fn app(a: u32, b: u32, c: u32, d: u32, f: fn(u32)) { + pure fn app(a: u32, b: u32, c: u32, d: u32, f: &fn(u32)) { f(a); f(b); f(c); f(d); } let mut result = ~""; diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index 0f6434f1b2b..18527cfece1 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -134,7 +134,7 @@ pub mod chained { } pub impl<K:Eq + IterBytes + Hash,V> T<K, V> { - pure fn each_entry(&self, blk: fn(@Entry<K,V>) -> bool) { + pure fn each_entry(&self, blk: &fn(@Entry<K,V>) -> bool) { // n.b. we can't use vec::iter() here because self.chains // is stored in a mutable location. let mut i = 0u, n = self.chains.len(); @@ -236,17 +236,17 @@ pub mod chained { } } - pure fn each(&self, blk: fn(key: &K, value: &V) -> bool) { + pure fn each(&self, blk: &fn(key: &K, value: &V) -> bool) { for self.each_entry |entry| { if !blk(&entry.key, &entry.value) { break; } } } - pure fn each_key(&self, blk: fn(key: &K) -> bool) { + pure fn each_key(&self, blk: &fn(key: &K) -> bool) { self.each(|k, _v| blk(k)) } - pure fn each_value(&self, blk: fn(value: &V) -> bool) { + pure fn each_value(&self, blk: &fn(value: &V) -> bool) { self.each(|_k, v| blk(v)) } } @@ -260,8 +260,8 @@ pub mod chained { } } - fn update_with_key(&self, key: K, newval: V, ff: fn(K, V, V) -> V) - -> bool { + fn update_with_key(&self, key: K, newval: V, ff: &fn(K, V, V) -> V) + -> bool { /* match self.find(key) { None => return self.insert(key, val), @@ -312,7 +312,7 @@ pub mod chained { } } - fn update(&self, key: K, newval: V, ff: fn(V, V) -> V) -> bool { + fn update(&self, key: K, newval: V, ff: &fn(V, V) -> V) -> bool { return self.update_with_key(key, newval, |_k, v, v1| ff(v,v1)); } diff --git a/src/libstd/prettyprint.rs b/src/libstd/prettyprint.rs index ed02ea87dac..d2d80eb7da8 100644 --- a/src/libstd/prettyprint.rs +++ b/src/libstd/prettyprint.rs @@ -98,87 +98,87 @@ impl serialize::Encoder for Serializer { self.wr.write_str(fmt!("@%?", v)); } - fn emit_borrowed(&self, f: fn()) { + fn emit_borrowed(&self, f: &fn()) { self.wr.write_str(~"&"); f(); } - fn emit_owned(&self, f: fn()) { + fn emit_owned(&self, f: &fn()) { self.wr.write_str(~"~"); f(); } - fn emit_managed(&self, f: fn()) { + fn emit_managed(&self, f: &fn()) { self.wr.write_str(~"@"); f(); } - fn emit_enum(&self, _name: &str, f: fn()) { + fn emit_enum(&self, _name: &str, f: &fn()) { f(); } fn emit_enum_variant(&self, v_name: &str, _v_id: uint, sz: uint, - f: fn()) { + f: &fn()) { self.wr.write_str(v_name); if sz > 0u { self.wr.write_str(~"("); } f(); if sz > 0u { self.wr.write_str(~")"); } } - fn emit_enum_variant_arg(&self, idx: uint, f: fn()) { + fn emit_enum_variant_arg(&self, idx: uint, f: &fn()) { if idx > 0u { self.wr.write_str(~", "); } f(); } - fn emit_borrowed_vec(&self, _len: uint, f: fn()) { + fn emit_borrowed_vec(&self, _len: uint, f: &fn()) { self.wr.write_str(~"&["); f(); self.wr.write_str(~"]"); } - fn emit_owned_vec(&self, _len: uint, f: fn()) { + fn emit_owned_vec(&self, _len: uint, f: &fn()) { self.wr.write_str(~"~["); f(); self.wr.write_str(~"]"); } - fn emit_managed_vec(&self, _len: uint, f: fn()) { + fn emit_managed_vec(&self, _len: uint, f: &fn()) { self.wr.write_str(~"@["); f(); self.wr.write_str(~"]"); } - fn emit_vec_elt(&self, idx: uint, f: fn()) { + fn emit_vec_elt(&self, idx: uint, f: &fn()) { if idx > 0u { self.wr.write_str(~", "); } f(); } - fn emit_rec(&self, f: fn()) { + fn emit_rec(&self, f: &fn()) { self.wr.write_str(~"{"); f(); self.wr.write_str(~"}"); } - fn emit_struct(&self, name: &str, _len: uint, f: fn()) { + fn emit_struct(&self, name: &str, _len: uint, f: &fn()) { self.wr.write_str(fmt!("%s {", name)); f(); self.wr.write_str(~"}"); } - fn emit_field(&self, name: &str, idx: uint, f: fn()) { + fn emit_field(&self, name: &str, idx: uint, f: &fn()) { if idx > 0u { self.wr.write_str(~", "); } self.wr.write_str(name); self.wr.write_str(~": "); f(); } - fn emit_tup(&self, _len: uint, f: fn()) { + fn emit_tup(&self, _len: uint, f: &fn()) { self.wr.write_str(~"("); f(); self.wr.write_str(~")"); } - fn emit_tup_elt(&self, idx: uint, f: fn()) { + fn emit_tup_elt(&self, idx: uint, f: &fn()) { if idx > 0u { self.wr.write_str(~", "); } f(); } diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index 676bc68e4e5..31f29ce23f2 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -31,7 +31,7 @@ impl<T:Ord> BaseIter<T> for PriorityQueue<T> { /// Visit all values in the underlying vector. /// /// The values are **not** visited in order. - pure fn each(&self, f: fn(&T) -> bool) { self.data.each(f) } + pure fn each(&self, f: &fn(&T) -> bool) { self.data.each(f) } pure fn size_hint(&self) -> Option<uint> { self.data.size_hint() } } diff --git a/src/libstd/rl.rs b/src/libstd/rl.rs index b2b30c1057e..a8b25767ce5 100644 --- a/src/libstd/rl.rs +++ b/src/libstd/rl.rs @@ -68,7 +68,7 @@ pub unsafe fn read(prompt: ~str) -> Option<~str> { } } -pub type CompletionCb = @fn(~str, fn(~str)); +pub type CompletionCb<'self> = @fn(~str, &'self fn(~str)); fn complete_key(_v: @CompletionCb) {} diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index d511ac9744e..dd2f5b58fb9 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -393,7 +393,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(c: 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) @@ -407,7 +407,7 @@ pub fn loop_chars(rope: Rope, it: fn(c: char) -> bool) -> bool { * * rope - A rope to traverse. It may be empty * * it - A block to execute with each consecutive character of the rope. */ -pub fn iter_chars(rope: Rope, it: fn(char)) { +pub fn iter_chars(rope: Rope, it: &fn(char)) { do loop_chars(rope) |x| { it(x); true @@ -436,7 +436,7 @@ pub fn iter_chars(rope: Rope, it: fn(char)) { * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ -pub fn loop_leaves(rope: Rope, it: fn(node::Leaf) -> bool) -> bool{ +pub fn loop_leaves(rope: Rope, it: &fn(node::Leaf) -> bool) -> bool{ match (rope) { node::Empty => return true, node::Content(x) => return node::loop_leaves(x, it) @@ -1078,7 +1078,7 @@ pub mod node { return result; } - pub fn loop_chars(node: @Node, it: fn(c: 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, @@ -1100,7 +1100,7 @@ pub mod node { * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ - pub fn loop_leaves(node: @Node, it: fn(Leaf) -> bool) -> bool{ + pub fn loop_leaves(node: @Node, it: &fn(Leaf) -> bool) -> bool{ let mut current = node; loop { match (*current) { diff --git a/src/libstd/semver.rs b/src/libstd/semver.rs index bf4091e1e90..7b8a06f1b93 100644 --- a/src/libstd/semver.rs +++ b/src/libstd/semver.rs @@ -140,7 +140,7 @@ condition! { fn take_nonempty_prefix(rdr: io::Reader, ch: char, - pred: fn(char) -> bool) -> (~str, char) { + pred: &fn(char) -> bool) -> (~str, char) { let mut buf = ~""; let mut ch = ch; while pred(ch) { diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index 5bbd926ba6b..0288155d29e 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -43,25 +43,25 @@ pub trait Encoder { fn emit_managed_str(&self, v: &str); // Compound types: - fn emit_borrowed(&self, f: fn()); - fn emit_owned(&self, f: fn()); - fn emit_managed(&self, f: fn()); + fn emit_borrowed(&self, f: &fn()); + fn emit_owned(&self, f: &fn()); + fn emit_managed(&self, f: &fn()); - fn emit_enum(&self, name: &str, f: fn()); - fn emit_enum_variant(&self, v_name: &str, v_id: uint, sz: uint, f: fn()); - fn emit_enum_variant_arg(&self, idx: uint, f: fn()); + fn emit_enum(&self, name: &str, f: &fn()); + fn emit_enum_variant(&self, v_name: &str, v_id: uint, sz: uint, f: &fn()); + fn emit_enum_variant_arg(&self, idx: uint, f: &fn()); - fn emit_borrowed_vec(&self, len: uint, f: fn()); - fn emit_owned_vec(&self, len: uint, f: fn()); - fn emit_managed_vec(&self, len: uint, f: fn()); - fn emit_vec_elt(&self, idx: uint, f: fn()); + fn emit_borrowed_vec(&self, len: uint, f: &fn()); + fn emit_owned_vec(&self, len: uint, f: &fn()); + fn emit_managed_vec(&self, len: uint, f: &fn()); + fn emit_vec_elt(&self, idx: uint, f: &fn()); - fn emit_rec(&self, f: fn()); - fn emit_struct(&self, name: &str, _len: uint, f: fn()); - fn emit_field(&self, f_name: &str, f_idx: uint, f: fn()); + fn emit_rec(&self, f: &fn()); + fn emit_struct(&self, name: &str, _len: uint, f: &fn()); + fn emit_field(&self, f_name: &str, f_idx: uint, f: &fn()); - fn emit_tup(&self, len: uint, f: fn()); - fn emit_tup_elt(&self, idx: uint, f: fn()); + fn emit_tup(&self, len: uint, f: &fn()); + fn emit_tup_elt(&self, idx: uint, f: &fn()); } pub trait Decoder { @@ -86,23 +86,23 @@ pub trait Decoder { fn read_managed_str(&self) -> @str; // Compound types: - fn read_enum<T>(&self, name: &str, f: fn() -> T) -> T; - fn read_enum_variant<T>(&self, f: fn(uint) -> T) -> T; - fn read_enum_variant_arg<T>(&self, idx: uint, f: fn() -> T) -> T; + fn read_enum<T>(&self, name: &str, f: &fn() -> T) -> T; + fn read_enum_variant<T>(&self, f: &fn(uint) -> T) -> T; + fn read_enum_variant_arg<T>(&self, idx: uint, f: &fn() -> T) -> T; - fn read_owned<T>(&self, f: fn() -> T) -> T; - fn read_managed<T>(&self, f: fn() -> T) -> T; + fn read_owned<T>(&self, f: &fn() -> T) -> T; + fn read_managed<T>(&self, f: &fn() -> T) -> T; - fn read_owned_vec<T>(&self, f: fn(uint) -> T) -> T; - fn read_managed_vec<T>(&self, f: fn(uint) -> T) -> T; - fn read_vec_elt<T>(&self, idx: uint, f: fn() -> T) -> T; + fn read_owned_vec<T>(&self, f: &fn(uint) -> T) -> T; + fn read_managed_vec<T>(&self, f: &fn(uint) -> T) -> T; + fn read_vec_elt<T>(&self, idx: uint, f: &fn() -> T) -> T; - fn read_rec<T>(&self, f: fn() -> T) -> T; - fn read_struct<T>(&self, name: &str, _len: uint, f: fn() -> T) -> T; - fn read_field<T>(&self, name: &str, idx: uint, f: fn() -> T) -> T; + fn read_rec<T>(&self, f: &fn() -> T) -> T; + fn read_struct<T>(&self, name: &str, _len: uint, f: &fn() -> T) -> T; + fn read_field<T>(&self, name: &str, idx: uint, f: &fn() -> T) -> T; - fn read_tup<T>(&self, sz: uint, f: fn() -> T) -> T; - fn read_tup_elt<T>(&self, idx: uint, f: fn() -> T) -> T; + fn read_tup<T>(&self, sz: uint, f: &fn() -> T) -> T; + fn read_tup_elt<T>(&self, idx: uint, f: &fn() -> T) -> T; } pub trait Encodable<S:Encoder> { @@ -547,11 +547,11 @@ impl< // In some cases, these should eventually be coded as traits. pub trait EncoderHelpers { - fn emit_from_vec<T>(&self, v: &[T], f: fn(v: &T)); + fn emit_from_vec<T>(&self, v: &[T], f: &fn(v: &T)); } impl<S:Encoder> EncoderHelpers for S { - fn emit_from_vec<T>(&self, v: &[T], f: fn(v: &T)) { + fn emit_from_vec<T>(&self, v: &[T], f: &fn(v: &T)) { do self.emit_owned_vec(v.len()) { for v.eachi |i, e| { do self.emit_vec_elt(i) { @@ -563,11 +563,11 @@ impl<S:Encoder> EncoderHelpers for S { } pub trait DecoderHelpers { - fn read_to_vec<T>(&self, f: fn() -> T) -> ~[T]; + fn read_to_vec<T>(&self, f: &fn() -> T) -> ~[T]; } impl<D:Decoder> DecoderHelpers for D { - fn read_to_vec<T>(&self, f: fn() -> T) -> ~[T] { + fn read_to_vec<T>(&self, f: &fn() -> T) -> ~[T] { do self.read_owned_vec |len| { do vec::from_fn(len) |i| { self.read_vec_elt(i, || f()) diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 84600ac74ee..726e7c36abd 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -24,7 +24,7 @@ pub struct SmallIntMap<T> { impl<V> BaseIter<(uint, &self/V)> for SmallIntMap<V> { /// Visit all key-value pairs in order - pure fn each(&self, it: fn(&(uint, &self/V)) -> bool) { + pure fn each(&self, it: &fn(&(uint, &self/V)) -> bool) { for uint::range(0, self.v.len()) |i| { match self.v[i] { Some(ref elt) => if !it(&(i, elt)) { break }, @@ -38,7 +38,7 @@ impl<V> BaseIter<(uint, &self/V)> for SmallIntMap<V> { impl<V> ReverseIter<(uint, &self/V)> for SmallIntMap<V> { /// Visit all key-value pairs in reverse order - pure fn each_reverse(&self, it: fn(&(uint, &self/V)) -> bool) { + pure fn each_reverse(&self, it: &fn(&(uint, &self/V)) -> bool) { for uint::range_rev(self.v.len(), 0) |i| { match self.v[i - 1] { Some(ref elt) => if !it(&(i - 1, elt)) { break }, @@ -76,12 +76,12 @@ impl<V> Map<uint, V> for SmallIntMap<V> { } /// Visit all keys in order - pure fn each_key(&self, blk: fn(key: &uint) -> bool) { + pure fn each_key(&self, blk: &fn(key: &uint) -> bool) { self.each(|&(k, _)| blk(&k)) } /// Visit all values in order - pure fn each_value(&self, blk: fn(value: &V) -> bool) { + pure fn each_value(&self, blk: &fn(value: &V) -> bool) { self.each(|&(_, v)| blk(v)) } @@ -133,7 +133,7 @@ pub impl<V> SmallIntMap<V> { pub impl<V:Copy> SmallIntMap<V> { fn update_with_key(&mut self, key: uint, val: V, - ff: fn(uint, V, V) -> V) -> bool { + ff: &fn(uint, V, V) -> V) -> bool { let new_val = match self.find(&key) { None => val, Some(orig) => ff(key, *orig, val) @@ -141,7 +141,7 @@ pub impl<V:Copy> SmallIntMap<V> { self.insert(key, new_val) } - fn update(&mut self, key: uint, newval: V, ff: fn(V, V) -> V) -> bool { + fn update(&mut self, key: uint, newval: V, ff: &fn(V, V) -> V) -> bool { self.update_with_key(key, newval, |_k, v, v1| ff(v,v1)) } } diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index d143c665d83..2190475d943 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -79,8 +79,9 @@ struct SemInner<Q> { // a condition variable attached, others should. blocked: Q } + #[doc(hidden)] -enum Sem<Q> = Exclusive<SemInner<Q>>; +struct Sem<Q>(Exclusive<SemInner<Q>>); #[doc(hidden)] fn new_sem<Q:Owned>(count: int, q: Q) -> Sem<Q> { @@ -135,7 +136,7 @@ pub impl<Q:Owned> &self/Sem<Q> { // FIXME(#3154) move both copies of this into Sem<Q>, and unify the 2 structs #[doc(hidden)] pub impl &self/Sem<()> { - fn access<U>(&self, blk: fn() -> U) -> U { + fn access<U>(&self, blk: &fn() -> U) -> U { let mut release = None; unsafe { do task::unkillable { @@ -148,7 +149,7 @@ pub impl &self/Sem<()> { } #[doc(hidden)] pub impl &self/Sem<~[Waitqueue]> { - fn access<U>(&self, blk: fn() -> U) -> U { + fn access<U>(&self, blk: &fn() -> U) -> U { let mut release = None; unsafe { do task::unkillable { @@ -332,7 +333,7 @@ pub impl Condvar/&self { #[inline(always)] #[doc(hidden)] fn check_cvar_bounds<U>(out_of_bounds: Option<uint>, id: uint, act: &str, - blk: fn() -> U) -> U { + blk: &fn() -> U) -> U { match out_of_bounds { Some(0) => fail!(fmt!("%s with illegal ID %u - this lock has no condvars!", @@ -347,7 +348,7 @@ fn check_cvar_bounds<U>(out_of_bounds: Option<uint>, id: uint, act: &str, #[doc(hidden)] pub impl Sem<~[Waitqueue]> { // The only other place that condvars get built is rwlock_write_mode. - fn access_cond<U>(&self, blk: fn(c: &Condvar) -> U) -> U { + fn access_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U { do self.access { blk(&Condvar { sem: self }) } } } @@ -385,7 +386,7 @@ pub impl Semaphore { fn release(&self) { (&self.sem).release() } /// Run a function with ownership of one of the semaphore's resources. - fn access<U>(&self, blk: fn() -> U) -> U { (&self.sem).access(blk) } + fn access<U>(&self, blk: &fn() -> U) -> U { (&self.sem).access(blk) } } /**************************************************************************** @@ -421,10 +422,10 @@ impl Clone for Mutex { pub impl Mutex { /// Run a function with ownership of the mutex. - fn lock<U>(&self, blk: fn() -> U) -> U { (&self.sem).access(blk) } + fn lock<U>(&self, blk: &fn() -> U) -> U { (&self.sem).access(blk) } /// Run a function with ownership of the mutex and a handle to a condvar. - fn lock_cond<U>(&self, blk: fn(c: &Condvar) -> U) -> U { + fn lock_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U { (&self.sem).access_cond(blk) } } @@ -480,7 +481,7 @@ pub impl RWlock { * Run a function with the rwlock in read mode. Calls to 'read' from other * tasks may run concurrently with this one. */ - fn read<U>(&self, blk: fn() -> U) -> U { + fn read<U>(&self, blk: &fn() -> U) -> U { let mut release = None; unsafe { do task::unkillable { @@ -511,7 +512,7 @@ pub impl RWlock { * Run a function with the rwlock in write mode. No calls to 'read' or * 'write' from other tasks will run concurrently with this one. */ - fn write<U>(&self, blk: fn() -> U) -> U { + fn write<U>(&self, blk: &fn() -> U) -> U { unsafe { do task::unkillable { (&self.order_lock).acquire(); @@ -529,7 +530,7 @@ pub impl RWlock { * the waiting task is signalled. (Note: a writer that waited and then * was signalled might reacquire the lock before other waiting writers.) */ - fn write_cond<U>(&self, blk: fn(c: &Condvar) -> U) -> U { + fn write_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U { // NB: You might think I should thread the order_lock into the cond // wait call, so that it gets waited on before access_lock gets // reacquired upon being woken up. However, (a) this would be not @@ -564,7 +565,7 @@ pub impl RWlock { * } * ~~~ */ - fn write_downgrade<U>(&self, blk: fn(v: RWlockWriteMode) -> U) -> U { + fn write_downgrade<U>(&self, blk: &fn(v: RWlockWriteMode) -> U) -> U { // Implementation slightly different from the slicker 'write's above. // The exit path is conditional on whether the caller downgrades. let mut _release = None; @@ -692,16 +693,16 @@ impl Drop for RWlockReadMode/&self { fn finalize(&self) {} } pub impl RWlockWriteMode/&self { /// Access the pre-downgrade rwlock in write mode. - fn write<U>(&self, blk: fn() -> U) -> U { blk() } + fn write<U>(&self, blk: &fn() -> U) -> U { blk() } /// Access the pre-downgrade rwlock in write mode with a condvar. - fn write_cond<U>(&self, blk: fn(c: &Condvar) -> U) -> U { + fn write_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U { blk(&Condvar { sem: &self.lock.access_lock }) } } pub impl RWlockReadMode/&self { /// Access the post-downgrade rwlock in read mode. - fn read<U>(&self, blk: fn() -> U) -> U { blk() } + fn read<U>(&self, blk: &fn() -> U) -> U { blk() } } /**************************************************************************** @@ -1082,7 +1083,7 @@ mod tests { #[cfg(test)] pub enum RWlockMode { Read, Write, Downgrade, DowngradeRead } #[cfg(test)] - pub fn lock_rwlock_in_mode(x: &RWlock, mode: RWlockMode, blk: fn()) { + pub fn lock_rwlock_in_mode(x: &RWlock, mode: RWlockMode, blk: &fn()) { match mode { Read => x.read(blk), Write => x.write(blk), @@ -1239,7 +1240,7 @@ mod tests { dg1: bool, dg2: bool) { // Much like the mutex broadcast test. Downgrade-enabled. - fn lock_cond(x: &RWlock, downgrade: bool, blk: fn(c: &Condvar)) { + fn lock_cond(x: &RWlock, downgrade: bool, blk: &fn(c: &Condvar)) { if downgrade { do x.write_downgrade |mode| { (&mode).write_cond(blk) diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index f06f64dde01..72351aac339 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -96,7 +96,7 @@ impl<K: Ord + TotalOrd, V> Ord for TreeMap<K, V> { impl<'self, K: TotalOrd, V> BaseIter<(&'self K, &'self V)> for TreeMap<K, V> { /// Visit all key-value pairs in order - pure fn each(&self, f: fn(&(&self/K, &self/V)) -> bool) { + pure fn each(&self, f: &fn(&(&self/K, &self/V)) -> bool) { each(&self.root, f) } pure fn size_hint(&self) -> Option<uint> { Some(self.len()) } @@ -107,7 +107,7 @@ impl<'self, K: TotalOrd, V> for TreeMap<K, V> { /// Visit all key-value pairs in reverse order - pure fn each_reverse(&self, f: fn(&(&self/K, &self/V)) -> bool) { + pure fn each_reverse(&self, f: &fn(&(&self/K, &self/V)) -> bool) { each_reverse(&self.root, f); } } @@ -135,10 +135,12 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> { } /// Visit all keys in order - pure fn each_key(&self, f: fn(&K) -> bool) { self.each(|&(k, _)| f(k)) } + pure fn each_key(&self, f: &fn(&K) -> bool) { self.each(|&(k, _)| f(k)) } /// Visit all values in order - pure fn each_value(&self, f: fn(&V) -> bool) { self.each(|&(_, v)| f(v)) } + pure fn each_value(&self, f: &fn(&V) -> bool) { + self.each(|&(_, v)| f(v)) + } /// Return the value corresponding to the key in the map pure fn find(&self, key: &K) -> Option<&self/V> { @@ -180,12 +182,12 @@ pub impl<K: TotalOrd, V> TreeMap<K, V> { static pure fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} } /// Visit all keys in reverse order - pure fn each_key_reverse(&self, f: fn(&K) -> bool) { + pure fn each_key_reverse(&self, f: &fn(&K) -> bool) { self.each_reverse(|&(k, _)| f(k)) } /// Visit all values in reverse order - pure fn each_value_reverse(&self, f: fn(&V) -> bool) { + pure fn each_value_reverse(&self, f: &fn(&V) -> bool) { self.each_reverse(|&(_, v)| f(v)) } @@ -225,7 +227,7 @@ pub fn map_next<K, V>(iter: &mut TreeMapIterator/&r<K, V>) /// Advance the iterator through the map pub fn map_advance<K, V>(iter: &mut TreeMapIterator/&r<K, V>, - f: fn((&r/K, &r/V)) -> bool) { + f: &fn((&r/K, &r/V)) -> bool) { loop { match map_next(iter) { Some(x) => { @@ -242,13 +244,13 @@ pub struct TreeSet<T> { impl<T: TotalOrd> BaseIter<T> for TreeSet<T> { /// Visit all values in order - pure fn each(&self, f: fn(&T) -> bool) { self.map.each_key(f) } + pure fn each(&self, f: &fn(&T) -> bool) { self.map.each_key(f) } pure fn size_hint(&self) -> Option<uint> { Some(self.len()) } } impl<T: TotalOrd> ReverseIter<T> for TreeSet<T> { /// Visit all values in reverse order - pure fn each_reverse(&self, f: fn(&T) -> bool) { + pure fn each_reverse(&self, f: &fn(&T) -> bool) { self.map.each_key_reverse(f) } } @@ -350,7 +352,7 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> { } /// Visit the values (in-order) representing the difference - pure fn difference(&self, other: &TreeSet<T>, f: fn(&T) -> bool) { + pure fn difference(&self, other: &TreeSet<T>, f: &fn(&T) -> bool) { let mut x = self.iter(); let mut y = other.iter(); @@ -383,7 +385,7 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> { /// Visit the values (in-order) representing the symmetric difference pure fn symmetric_difference(&self, other: &TreeSet<T>, - f: fn(&T) -> bool) { + f: &fn(&T) -> bool) { let mut x = self.iter(); let mut y = other.iter(); @@ -422,7 +424,7 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> { } /// Visit the values (in-order) representing the intersection - pure fn intersection(&self, other: &TreeSet<T>, f: fn(&T) -> bool) { + pure fn intersection(&self, other: &TreeSet<T>, f: &fn(&T) -> bool) { let mut x = self.iter(); let mut y = other.iter(); @@ -449,7 +451,7 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> { } /// Visit the values (in-order) representing the union - pure fn union(&self, other: &TreeSet<T>, f: fn(&T) -> bool) { + pure fn union(&self, other: &TreeSet<T>, f: &fn(&T) -> bool) { let mut x = self.iter(); let mut y = other.iter(); @@ -508,7 +510,7 @@ pub fn set_next<T>(iter: &mut TreeSetIterator/&r<T>) -> Option<&r/T> { /// Advance the iterator through the set fn set_advance<T>(iter: &mut TreeSetIterator/&r<T>, - f: fn(&r/T) -> bool) { + f: &fn(&r/T) -> bool) { do map_advance(&mut iter.iter) |(k, _)| { f(k) } } @@ -530,7 +532,7 @@ pub impl<K: TotalOrd, V> TreeNode<K, V> { } pure fn each<K: TotalOrd, V>(node: &r/Option<~TreeNode<K, V>>, - f: fn(&(&r/K, &r/V)) -> bool) { + 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) } @@ -538,7 +540,7 @@ pure fn each<K: TotalOrd, V>(node: &r/Option<~TreeNode<K, V>>, } pure fn each_reverse<K: TotalOrd, V>(node: &r/Option<~TreeNode<K, V>>, - f: fn(&(&r/K, &r/V)) -> bool) { + 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) } diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index eac6e090f1f..68a6f8effaa 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -269,7 +269,7 @@ pub impl Context { Decodable<json::Decoder/&static>>( // FIXME(#5121) @self, fn_name:&str, - blk: fn(@Mut<Prep>)->Work<T>) -> Work<T> { + blk: &fn(@Mut<Prep>)->Work<T>) -> Work<T> { let p = @Mut(Prep {ctxt: self, fn_name: fn_name.to_owned(), declared_inputs: LinearMap::new()}); |
