From b90e9c9b2cf04920c08569953c4e3ee5e339524b Mon Sep 17 00:00:00 2001 From: Sunjay Varma Date: Wed, 13 Dec 2017 18:50:22 -0500 Subject: [PATCH] Added test to make sure we can refer to the declared traits of a generic associated type --- .../rfc1598-generic-associated-types/iterable.rs | 7 +++++++ .../iterable.stderr | 16 +++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/test/ui/rfc1598-generic-associated-types/iterable.rs b/src/test/ui/rfc1598-generic-associated-types/iterable.rs index 94b2fc4062f9..1287ddaf7f7f 100644 --- a/src/test/ui/rfc1598-generic-associated-types/iterable.rs +++ b/src/test/ui/rfc1598-generic-associated-types/iterable.rs @@ -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>; //~^ 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 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] } diff --git a/src/test/ui/rfc1598-generic-associated-types/iterable.stderr b/src/test/ui/rfc1598-generic-associated-types/iterable.stderr index 9d325cb0855c..d12ca5e5d4ef 100644 --- a/src/test/ui/rfc1598-generic-associated-types/iterable.stderr +++ b/src/test/ui/rfc1598-generic-associated-types/iterable.stderr @@ -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>; +20 | type Iter<'a>: Iterator>; | ^^ 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 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