@@ -58,12 +58,6 @@ mod linear {
58
58
buckets: vec:: from_fn ( initial_capacity, |_i| none) } )
59
59
}
60
60
61
- // FIXME(#2979) would allow us to use region type for k
62
- unsafe fn borrow < K > ( & & k: K ) -> & K {
63
- let p: * K = ptr:: addr_of ( k) ;
64
- unsafe :: reinterpret_cast ( p)
65
- }
66
-
67
61
priv impl < K , V > & const LinearMap < K , V > {
68
62
#[ inline( always) ]
69
63
pure fn to_bucket ( h : uint ) -> uint {
@@ -155,8 +149,7 @@ mod linear {
155
149
/// Assumes that there will be a bucket.
156
150
/// True if there was no previous entry with that key
157
151
fn insert_internal ( hash : uint , +k : K , +v : V ) -> bool {
158
- match self . bucket_for_key_with_hash ( self . buckets , hash,
159
- unsafe { borrow ( k) } ) {
152
+ match self . bucket_for_key_with_hash ( self . buckets , hash, & k) {
160
153
TableFull => { fail ~"Internal logic error"; }
161
154
FoundHole ( idx) => {
162
155
debug ! { "insert fresh (%?->%?) at idx %?, hash %?" ,
@@ -187,7 +180,7 @@ mod linear {
187
180
self . expand ( ) ;
188
181
}
189
182
190
- let hash = self . hashfn ( unsafe { borrow ( k ) } ) ;
183
+ let hash = self . hashfn ( & k ) ;
191
184
self . insert_internal ( hash, k, v)
192
185
}
193
186
@@ -279,11 +272,19 @@ mod linear {
279
272
280
273
impl < K , V > & LinearMap < K , V > {
281
274
/*
282
- FIXME --- #2979 must be fixed to typecheck this
283
- fn find_ptr(k: K) -> option<&V> {
284
- //XXX this should not type check as written, but it should
285
- //be *possible* to typecheck it...
286
- self.with_ptr(k, |v| v)
275
+ FIXME(#3148)--region inference fails to capture needed deps
276
+
277
+ fn find_ref(k: &K) -> option<&self/V> {
278
+ match self.bucket_for_key(self.buckets, k) {
279
+ FoundEntry(idx) => {
280
+ match check self.buckets[idx] {
281
+ some(ref bkt) => some(&bkt.value)
282
+ }
283
+ }
284
+ TableFull | FoundHole(_) => {
285
+ none
286
+ }
287
+ }
287
288
}
288
289
*/
289
290
0 commit comments