Update tests with Nikos comments

This commit is contained in:
Tomas Gavenciak 2018-04-11 23:41:20 +02:00
parent 0617b925e8
commit 571337b3dd
7 changed files with 65 additions and 47 deletions

View file

@ -19,16 +19,19 @@
// associated-type-constructors-part-2-family-traits/
trait Collection<T> {
fn empty() -> Self;
fn add(&mut self, value: T);
fn iterate<'iter>(&'iter self) -> Self::Iter<'iter>;
//~^ ERROR lifetime parameters are not allowed on this type [E0110]
type Iter<'iter>: Iterator<Item=&'iter T>;
type Family: CollectionFamily;
// Test associated type defaults with parameters
type Sibling<U>: Collection<U> = <<Self as Collection<T>>::Family as CollectionFamily>::
Member<U>;
//~^ ERROR type parameters are not allowed on this type [E0109]
fn empty() -> Self;
fn add(&mut self, value: T);
fn iterate<'iter>(&'iter self) -> Self::Iter<'iter>;
//~^ ERROR lifetime parameters are not allowed on this type [E0110]
}
trait CollectionFamily {
@ -42,23 +45,28 @@ impl CollectionFamily for VecFamily {
}
impl<T> Collection<T> for Vec<T> {
type Iter<'iter> = std::slice::Iter<'iter, T>;
type Family = VecFamily;
fn empty() -> Self {
Vec::new()
}
fn add(&mut self, value: T) {
self.push(value)
}
fn iterate<'iter>(&'iter self) -> Self::Iter<'iter> {
//~^ ERROR lifetime parameters are not allowed on this type [E0110]
self.iter()
}
type Iter<'iter> = std::slice::Iter<'iter, T>;
type Family = VecFamily;
}
fn floatify<C>(ints: &C) -> <<C as Collection<i32>>::Family as CollectionFamily>::Member<f32>
//~^ ERROR type parameters are not allowed on this type [E0109]
where C: Collection<i32> {
where
C: Collection<i32>,
{
let mut res = C::Family::Member::<f32>::empty();
for &v in ints.iterate() {
res.add(v as f32);
@ -68,7 +76,9 @@ fn floatify<C>(ints: &C) -> <<C as Collection<i32>>::Family as CollectionFamily>
fn floatify_sibling<C>(ints: &C) -> <C as Collection<i32>>::Sibling<f32>
//~^ ERROR type parameters are not allowed on this type [E0109]
where C: Collection<i32> {
where
C: Collection<i32>,
{
let mut res = C::Family::Member::<f32>::empty();
for &v in ints.iterate() {
res.add(v as f32);

View file

@ -1,29 +1,29 @@
error[E0109]: type parameters are not allowed on this type
--> $DIR/collections.rs:59:90
--> $DIR/collections.rs:65:90
|
LL | fn floatify<C>(ints: &C) -> <<C as Collection<i32>>::Family as CollectionFamily>::Member<f32>
| ^^^ type parameter not allowed
error[E0109]: type parameters are not allowed on this type
--> $DIR/collections.rs:69:69
--> $DIR/collections.rs:77:69
|
LL | fn floatify_sibling<C>(ints: &C) -> <C as Collection<i32>>::Sibling<f32>
| ^^^ type parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/collections.rs:24:50
|
LL | fn iterate<'iter>(&'iter self) -> Self::Iter<'iter>;
| ^^^^^ lifetime parameter not allowed on this type
error[E0109]: type parameters are not allowed on this type
--> $DIR/collections.rs:30:16
--> $DIR/collections.rs:26:16
|
LL | Member<U>;
| ^ type parameter not allowed
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/collections.rs:51:50
--> $DIR/collections.rs:33:50
|
LL | fn iterate<'iter>(&'iter self) -> Self::Iter<'iter>;
| ^^^^^ lifetime parameter not allowed on this type
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/collections.rs:59:50
|
LL | fn iterate<'iter>(&'iter self) -> Self::Iter<'iter> {
| ^^^^^ lifetime parameter not allowed on this type

View 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,11 +20,18 @@ trait Foo {
}
trait Baz {
type Quux<'a>;
type Quux<'a>: Foo;
// This weird type tests that we can use universal function call syntax to access the Item on
type Baa<'a>: Deref<Target = <Self::Quux<'a> as Foo>::Bar<'a, 'static>>;
//~^ ERROR lifetime parameters are not allowed on this type [E0110]
//~| ERROR lifetime parameters are not allowed on this type [E0110]
}
impl<T> Baz for T where T: Foo {
type Quux<'a> = <T as Foo>::Bar<'a, 'static>;
type Quux<'a> = T;
type Baa<'a> = &'a <T as Foo>::Bar<'a, 'static>;
//~^ ERROR lifetime parameters are not allowed on this type [E0110]
}

View file

@ -1,9 +1,21 @@
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/construct_with_other_type.rs:25:37
--> $DIR/construct_with_other_type.rs:26:46
|
LL | type Quux<'a> = <T as Foo>::Bar<'a, 'static>;
| ^^ lifetime parameter not allowed on this type
LL | type Baa<'a>: Deref<Target = <Self::Quux<'a> as Foo>::Bar<'a, 'static>>;
| ^^ lifetime parameter not allowed on this type
error: aborting due to previous error
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/construct_with_other_type.rs:26:63
|
LL | type Baa<'a>: Deref<Target = <Self::Quux<'a> as Foo>::Bar<'a, 'static>>;
| ^^ lifetime parameter not allowed on this type
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/construct_with_other_type.rs:34:40
|
LL | type Baa<'a> = &'a <T as Foo>::Bar<'a, 'static>;
| ^^ lifetime parameter not allowed on this type
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0110`.

View file

@ -20,11 +20,6 @@ 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]
}
@ -33,8 +28,7 @@ trait Iterable {
impl<T> Iterable for Vec<T> {
type Item<'a> = &'a T;
type Iter<'a> = std::slice::Iter<'a, T>;
type Iter2<'a> = &'a T;
// gavento: ^^^ Not 100% sure about the intention here
fn iter<'a>(&'a self) -> Self::Iter<'a> {
//~^ ERROR lifetime parameters are not allowed on this type [E0110]
self.iter()
@ -45,8 +39,7 @@ impl<T> Iterable for Vec<T> {
impl<T> Iterable for [T] {
type Item<'a> = &'a T;
type Iter<'a> = std::slice::Iter<'a, T>;
type Iter2<'a> = &'a T;
// gavento: ^^^ Not 100% sure about the intention here
fn iter<'a>(&'a self) -> Self::Iter<'a> {
//~^ ERROR lifetime parameters are not allowed on this type [E0110]
self.iter()

View file

@ -5,41 +5,35 @@ LL | 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:25:48
|
LL | 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:56:53
--> $DIR/iterable.rs:49:53
|
LL | fn make_iter<'a, I: Iterable>(it: &'a I) -> I::Iter<'a> {
| ^^ lifetime parameter not allowed on this type
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/iterable.rs:61:60
--> $DIR/iterable.rs:54:60
|
LL | fn get_first<'a, I: Iterable>(it: &'a I) -> Option<I::Item<'a>> {
| ^^ lifetime parameter not allowed on this type
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/iterable.rs:28:41
--> $DIR/iterable.rs:23:41
|
LL | fn iter<'a>(&'a self) -> Self::Iter<'a>;
| ^^ lifetime parameter not allowed on this type
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/iterable.rs:38:41
--> $DIR/iterable.rs:32:41
|
LL | fn iter<'a>(&'a self) -> Self::Iter<'a> {
| ^^ lifetime parameter not allowed on this type
error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/iterable.rs:50:41
--> $DIR/iterable.rs:43:41
|
LL | fn iter<'a>(&'a self) -> Self::Iter<'a> {
| ^^ lifetime parameter not allowed on this type
error: aborting due to 7 previous errors
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0110`.

View file

@ -11,8 +11,8 @@
#![feature(generic_associated_types)]
//FIXME(#44265): The lifetime shadowing and type parameter shadowing
// should cause an error. This will be addressed by a future PR.
// For now this compiles:
// should cause an error. Now it compiles (errorneously) and this will be addressed
// by a future PR. Then remove the following:
// must-compile-successfully
trait Shadow<'a> {