Skip to content

Commit 0a1d468

Browse files
committed
---
yaml --- r: 22625 b: refs/heads/master c: f676547 h: refs/heads/master i: 22623: ecd562a v: v3
1 parent 926964b commit 0a1d468

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 978ca03cb2f46e13f9f8d512e17867aa26e8432f
2+
refs/heads/master: f676547c9788b919762bfb379b1e26ebd94d3dc9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/rustc/middle/typeck/infer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,8 @@ impl of combine for glb {
23712371
}
23722372
}
23732373

2374-
(ty::re_scope(a_id), ty::re_scope(b_id)) {
2374+
(ty::re_scope(a_id), ty::re_scope(b_id)) |
2375+
(ty::re_free(a_id, _), ty::re_free(b_id, _)) {
23752376
// We want to generate a region that is contained by both of
23762377
// these: so, if one of these scopes is a subscope of the
23772378
// other, return it. Otherwise fail.
@@ -2385,7 +2386,6 @@ impl of combine for glb {
23852386

23862387
// For these types, we cannot define any additional
23872388
// relationship:
2388-
(ty::re_free(_, _), ty::re_free(_, _)) |
23892389
(ty::re_bound(_), ty::re_bound(_)) |
23902390
(ty::re_bound(_), ty::re_free(_, _)) |
23912391
(ty::re_bound(_), ty::re_scope(_)) |
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
fn select(x: &int, y: &int) -> &int { x }
2+
3+
fn with<T>(f: fn(x: &int) -> T) -> T {
4+
f(&20)
5+
}
6+
7+
fn manip(x: &a/int) -> int {
8+
let z = do with |y| { select(x, y) };
9+
//~^ ERROR reference is not valid outside of its lifetime
10+
*z
11+
}
12+
13+
fn main() {
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
fn takes_two(x: &int, y: &int) -> int { *x + *y }
2+
3+
fn with<T>(f: fn(x: &int) -> T) -> T {
4+
f(&20)
5+
}
6+
7+
fn has_one(x: &a/int) -> int {
8+
do with |y| { takes_two(x, y) }
9+
}
10+
11+
fn main() {
12+
assert has_one(&2) == 22;
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fn takes_two(x: &int, y: &int) -> int { *x + *y }
2+
3+
fn has_two(x: &a/int, y: &b/int) -> int {
4+
takes_two(x, y)
5+
}
6+
7+
fn main() {
8+
assert has_two(&20, &2) == 22;
9+
}

0 commit comments

Comments
 (0)