Skip to content

Commit 392ffd0

Browse files
committed
---
yaml --- r: 30540 b: refs/heads/incoming c: 34cece9 h: refs/heads/master v: v3
1 parent 5de2bd8 commit 392ffd0

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
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: 6a3756b0ba3dbab0c1957a7c829e09e9505c7574
9+
refs/heads/incoming: 34cece99cce373546d62aed06a7ec55d04aaa124
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/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)