Skip to content

Commit af418d9

Browse files
committed
Test illustrating issue #2263.
1 parent 34b42ee commit af418d9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//xfail-test
2+
3+
// Issue #2263.
4+
5+
// Should pass region checking.
6+
fn ok(f: fn@(x: &uint)) {
7+
// Here, g is a function that can accept a uint pointer with
8+
// lifetime r, and f is a function that can accept a uint pointer
9+
// with any lifetime. The assignment g = f should be OK (i.e., f
10+
// should be a subtype of g), because f can be used in any context
11+
// that expects g's type. But this currently fails.
12+
let mut g: fn@(y: &r.uint) = fn@(x: &r.uint) { };
13+
g = f;
14+
}
15+
16+
// This version is the same as above, except that here, g's type is
17+
// inferred.
18+
fn ok_inferred(f: fn@(x: &uint)) {
19+
let mut g = fn@(x: &r.uint) { };
20+
g = f;
21+
}
22+
23+
fn main() {
24+
}

0 commit comments

Comments
 (0)