]> git.lizzy.rs Git - rust.git/commitdiff
regionck.rs: correct misuse of ty.regions() rather than regions()
authorNiko Matsakis <niko@alum.mit.edu>
Tue, 11 Aug 2015 13:54:06 +0000 (09:54 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 12 Aug 2015 21:58:57 +0000 (17:58 -0400)
and add a test that was (incorrectly) failing to compile with
existing code

src/librustc_typeck/check/regionck.rs
src/test/compile-fail/regions-outlives-projection-hrtype.rs [new file with mode: 0644]

index fe40ade136da5614e8e769462352936fb259ba8d..1d575128663dc0072310233621203dcf3bd628af 100644 (file)
@@ -1785,7 +1785,7 @@ fn recursive_type_bound<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
 
     let mut regions = ty.regions();
     regions.retain(|r| !r.is_bound()); // ignore late-bound regions
-    bounds.push(VerifyBound::AllRegions(ty.regions()));
+    bounds.push(VerifyBound::AllRegions(regions));
 
     // remove bounds that must hold, since they are not interesting
     bounds.retain(|b| !b.must_hold());
diff --git a/src/test/compile-fail/regions-outlives-projection-hrtype.rs b/src/test/compile-fail/regions-outlives-projection-hrtype.rs
new file mode 100644 (file)
index 0000000..2d271b7
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test for the outlives relation when applied to a projection on a
+// type with bound regions. In this case, we are checking that
+// `<for<'r> fn(&'r T) as TheTrait>::TheType: 'a` If we're not
+// careful, we could wind up with a constraint that `'r:'a`, but since
+// `'r` is bound, that leads to badness. This test checks that
+// everything works.
+
+#![feature(rustc_attrs)]
+#![allow(dead_code)]
+
+trait TheTrait {
+    type TheType;
+}
+
+fn wf<T>() { }
+
+type FnType<T> = for<'r> fn(&'r T);
+
+fn foo<'a,'b,T>()
+    where FnType<T>: TheTrait
+{
+    wf::< <FnType<T> as TheTrait>::TheType >();
+}
+
+#[rustc_error]
+fn main() { } //~ ERROR compilation successful