]> git.lizzy.rs Git - rust.git/commitdiff
Added test to make sure we can refer to the declared traits of a generic associated...
authorSunjay Varma <varma.sunjay@gmail.com>
Wed, 13 Dec 2017 23:50:22 +0000 (18:50 -0500)
committerSunjay Varma <varma.sunjay@gmail.com>
Wed, 13 Dec 2017 23:50:22 +0000 (18:50 -0500)
src/test/ui/rfc1598-generic-associated-types/iterable.rs
src/test/ui/rfc1598-generic-associated-types/iterable.stderr

index 94b2fc4062f961cbbcf62571346d419faea07935..1287ddaf7f7feb3f722b1896a88042f2ef856904 100644 (file)
@@ -10,6 +10,8 @@
 
 #![feature(generic_associated_types)]
 
+use std::ops::Deref;
+
 //FIXME(#44265): "lifetime parameters are not allowed on this type" errors will be addressed in a
 //follow-up PR
 
@@ -18,6 +20,11 @@ trait Iterable {
     type Iter<'a>: Iterator<Item = Self::Item<'a>>;
     //~^ ERROR lifetime parameters are not allowed on this type [E0110]
 
+    // This weird type tests that we can use universal function call syntax to access the Item on
+    // Self::Iter which we have declared to be an Iterator
+    type Iter2<'a>: Deref<Target = <Self::Iter<'a> as Iterator>::Item>;
+    //~^ ERROR lifetime parameters are not allowed on this type [E0110]
+
     fn iter<'a>(&'a self) -> Self::Iter<'a>;
     //~^ ERROR lifetime parameters are not allowed on this type [E0110]
 }
index 9d325cb0855c60047a552cbcb53adea9cc0c1a3d..d12ca5e5d4ef74fa4043f9475a327763b70f4862 100644 (file)
@@ -1,14 +1,20 @@
 error[E0110]: lifetime parameters are not allowed on this type
-  --> $DIR/iterable.rs:18:47
+  --> $DIR/iterable.rs:20:47
    |
-18 |     type Iter<'a>: Iterator<Item = Self::Item<'a>>;
+20 |     type Iter<'a>: Iterator<Item = Self::Item<'a>>;
    |                                               ^^ lifetime parameter not allowed on this type
 
 error[E0110]: lifetime parameters are not allowed on this type
-  --> $DIR/iterable.rs:21:41
+  --> $DIR/iterable.rs:25:48
    |
-21 |     fn iter<'a>(&'a self) -> Self::Iter<'a>;
+25 |     type Iter2<'a>: Deref<Target = <Self::Iter<'a> as Iterator>::Item>;
+   |                                                ^^ lifetime parameter not allowed on this type
+
+error[E0110]: lifetime parameters are not allowed on this type
+  --> $DIR/iterable.rs:28:41
+   |
+28 |     fn iter<'a>(&'a self) -> Self::Iter<'a>;
    |                                         ^^ lifetime parameter not allowed on this type
 
-error: aborting due to 2 previous errors
+error: aborting due to 3 previous errors