From 182814ef8191e2b153806380f8d3d46069c69a8d Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 21 Aug 2012 08:10:32 -0700 Subject: [PATCH] remove some FIXMEd code as the relevant issue is fixed --- src/libcore/send_map.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/libcore/send_map.rs b/src/libcore/send_map.rs index cb8d596cf88..52a63dacbfc 100644 --- a/src/libcore/send_map.rs +++ b/src/libcore/send_map.rs @@ -58,12 +58,6 @@ fn linear_map_with_capacity( buckets: vec::from_fn(initial_capacity, |_i| none)}) } - // FIXME(#2979) would allow us to use region type for k - unsafe fn borrow(&&k: K) -> &K { - let p: *K = ptr::addr_of(k); - unsafe::reinterpret_cast(p) - } - priv impl &const LinearMap { #[inline(always)] pure fn to_bucket(h: uint) -> uint { @@ -155,8 +149,7 @@ fn insert_bucket(+bucket: option>) { /// Assumes that there will be a bucket. /// True if there was no previous entry with that key fn insert_internal(hash: uint, +k: K, +v: V) -> bool { - match self.bucket_for_key_with_hash(self.buckets, hash, - unsafe{borrow(k)}) { + match self.bucket_for_key_with_hash(self.buckets, hash, &k) { TableFull => {fail ~"Internal logic error";} FoundHole(idx) => { debug!{"insert fresh (%?->%?) at idx %?, hash %?", @@ -187,7 +180,7 @@ fn insert(+k: K, +v: V) -> bool { self.expand(); } - let hash = self.hashfn(unsafe{borrow(k)}); + let hash = self.hashfn(&k); self.insert_internal(hash, k, v) } @@ -279,11 +272,19 @@ fn get(k: &K) -> V { impl &LinearMap { /* - FIXME --- #2979 must be fixed to typecheck this - fn find_ptr(k: K) -> option<&V> { - //XXX this should not type check as written, but it should - //be *possible* to typecheck it... - self.with_ptr(k, |v| v) + FIXME(#3148)--region inference fails to capture needed deps + + fn find_ref(k: &K) -> option<&self/V> { + match self.bucket_for_key(self.buckets, k) { + FoundEntry(idx) => { + match check self.buckets[idx] { + some(ref bkt) => some(&bkt.value) + } + } + TableFull | FoundHole(_) => { + none + } + } } */