Skip to content

Commit 2110792

Browse files
committed
---
yaml --- r: 28518 b: refs/heads/try c: 34cece9 h: refs/heads/master v: v3
1 parent fabb887 commit 2110792

File tree

2 files changed

+27
-33
lines changed

2 files changed

+27
-33
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
5-
refs/heads/try: 6a3756b0ba3dbab0c1957a7c829e09e9505c7574
5+
refs/heads/try: 34cece99cce373546d62aed06a7ec55d04aaa124
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df

branches/try/src/libcore/send_map.rs

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -275,40 +275,31 @@ mod linear {
275275
}
276276
}
277277

278-
/*
279-
FIXME(#3148)--region inference fails to capture needed deps
280-
281-
fn find_ref(&self, k: &K) -> option<&self/V> {
282-
match self.bucket_for_key(self.buckets, k) {
283-
FoundEntry(idx) => {
284-
match check self.buckets[idx] {
285-
some(ref bkt) => some(&bkt.value)
286-
}
287-
}
288-
TableFull | FoundHole(_) => {
289-
none
290-
}
291-
}
292-
}
293-
*/
294-
295-
fn with_find_ref<T>(&self, k: &K, blk: fn(Option<&V>) -> T) -> T {
278+
fn find_ref(&self, k: &K) -> Option<&self/V> {
296279
match self.bucket_for_key(self.buckets, k) {
297280
FoundEntry(idx) => {
298281
match self.buckets[idx] {
299-
Some(bkt) => blk(Some(&bkt.value)),
300-
None => fail ~"LinearMap::find: internal logic error"
282+
Some(ref bkt) => {
283+
let ptr = unsafe {
284+
// FIXME(#3148)--region inference
285+
// fails to capture needed deps.
286+
// Here, the bucket value is known to
287+
// live as long as self, because self
288+
// is immutable. But the region
289+
// inference stupidly infers a
290+
// lifetime for `ref bkt` that is
291+
// shorter than it needs to be.
292+
unsafe::copy_lifetime(self, &bkt.value)
293+
};
294+
Some(ptr)
295+
}
296+
None => {
297+
fail ~"LinearMap::find: internal logic error"
298+
}
301299
}
302300
}
303-
TableFull | FoundHole(_) => blk(None),
304-
}
305-
}
306-
307-
fn with_get_ref<T>(&self, k: &K, blk: fn(v: &V) -> T) -> T {
308-
do self.with_find_ref(k) |v| {
309-
match v {
310-
Some(v) => blk(v),
311-
None => fail fmt!("No entry found for key: %?", k),
301+
TableFull | FoundHole(_) => {
302+
None
312303
}
313304
}
314305
}
@@ -451,10 +442,13 @@ mod test {
451442
}
452443

453444
#[test]
454-
fn with_find_ref() {
445+
fn find_ref() {
455446
let mut m = ~LinearMap();
456-
m.with_find_ref(&1, |v| assert v.is_none());
447+
assert m.find_ref(&1).is_none();
457448
m.insert(1, 2);
458-
m.with_find_ref(&1, |v| assert *v.get() == 2);
449+
match m.find_ref(&1) {
450+
None => fail,
451+
Some(v) => assert *v == 2
452+
}
459453
}
460454
}

0 commit comments

Comments
 (0)