summaryrefslogtreecommitdiffstats
path: root/src/test/ui/associated-types/associated-types-subtyping-1.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/associated-types/associated-types-subtyping-1.rs')
-rw-r--r--src/test/ui/associated-types/associated-types-subtyping-1.rs49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/test/ui/associated-types/associated-types-subtyping-1.rs b/src/test/ui/associated-types/associated-types-subtyping-1.rs
new file mode 100644
index 000000000..c4758f255
--- /dev/null
+++ b/src/test/ui/associated-types/associated-types-subtyping-1.rs
@@ -0,0 +1,49 @@
+#![allow(unused_variables)]
+
+fn make_any<T>() -> T { loop {} }
+
+trait Trait<'a> {
+ type Type;
+
+ fn method(&'a self) { }
+}
+
+fn method1<'a,'b,T>(x: &'a T, y: &'b T)
+ where T : for<'z> Trait<'z>, 'a : 'b
+{
+ // Note that &'static T <: &'a T.
+ let a: <T as Trait<'a>>::Type = make_any();
+ let b: <T as Trait<'b>>::Type = make_any();
+ let _c: <T as Trait<'a>>::Type = a;
+}
+
+fn method2<'a,'b,T>(x: &'a T, y: &'b T)
+ where T : for<'z> Trait<'z>, 'a : 'b
+{
+ // Note that &'static T <: &'a T.
+ let a: <T as Trait<'a>>::Type = make_any();
+ //~^ ERROR lifetime may not live long enough
+ let b: <T as Trait<'b>>::Type = make_any();
+ let _c: <T as Trait<'b>>::Type = a;
+}
+
+fn method3<'a,'b,T>(x: &'a T, y: &'b T)
+ where T : for<'z> Trait<'z>, 'a : 'b
+{
+ // Note that &'static T <: &'a T.
+ let a: <T as Trait<'a>>::Type = make_any();
+ let b: <T as Trait<'b>>::Type = make_any();
+ let _c: <T as Trait<'a>>::Type = b;
+ //~^ ERROR lifetime may not live long enough
+}
+
+fn method4<'a,'b,T>(x: &'a T, y: &'b T)
+ where T : for<'z> Trait<'z>, 'a : 'b
+{
+ // Note that &'static T <: &'a T.
+ let a: <T as Trait<'a>>::Type = make_any();
+ let b: <T as Trait<'b>>::Type = make_any();
+ let _c: <T as Trait<'b>>::Type = b;
+}
+
+fn main() { }