From 248e439638dbabf822bf9017eb99b44f0e1a0370 Mon Sep 17 00:00:00 2001 From: Lindsey Kuper Date: Mon, 21 May 2012 13:05:06 -0700 Subject: [PATCH] Region checking: this one currently passes, but only "by accident". --- src/test/compile-fail/regions-fns.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/test/compile-fail/regions-fns.rs diff --git a/src/test/compile-fail/regions-fns.rs b/src/test/compile-fail/regions-fns.rs new file mode 100644 index 00000000000..0f636d27dc4 --- /dev/null +++ b/src/test/compile-fail/regions-fns.rs @@ -0,0 +1,21 @@ +// Should fail region checking, because g can only accept a pointer +// with lifetime r, and a is a pointer with unspecified lifetime. +fn not_ok_1(a: &uint) { + let mut g: fn@(x: &uint) = fn@(x: &r.uint) {}; + //!^ ERROR mismatched types + g(a); +} + +// Should fail region checking, because g can only accept a pointer +// with lifetime r, and a is a pointer with lifetime s. +fn not_ok_2(s: &s.uint) +{ + let mut g: fn@(x: &uint) = fn@(x: &r.uint) {}; + //!^ ERROR mismatched types + g(s); +} + +fn main() { +} + +