Skip to content

Commit 248e439

Browse files
committed
Region checking: this one currently passes, but only "by accident".
1 parent af418d9 commit 248e439

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/test/compile-fail/regions-fns.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Should fail region checking, because g can only accept a pointer
2+
// with lifetime r, and a is a pointer with unspecified lifetime.
3+
fn not_ok_1(a: &uint) {
4+
let mut g: fn@(x: &uint) = fn@(x: &r.uint) {};
5+
//!^ ERROR mismatched types
6+
g(a);
7+
}
8+
9+
// Should fail region checking, because g can only accept a pointer
10+
// with lifetime r, and a is a pointer with lifetime s.
11+
fn not_ok_2(s: &s.uint)
12+
{
13+
let mut g: fn@(x: &uint) = fn@(x: &r.uint) {};
14+
//!^ ERROR mismatched types
15+
g(s);
16+
}
17+
18+
fn main() {
19+
}
20+
21+

0 commit comments

Comments
 (0)