From fdf6c652cecdb09b28cd4701917b9857f7ce0cb7 Mon Sep 17 00:00:00 2001 From: Sunjay Varma Date: Tue, 28 Nov 2017 23:39:46 -0500 Subject: Moved all of the tests over to ui and annotated why they are failing with appropriate fixme comments --- .../feature-gate-generic_associated_types.rs | 4 ++ .../construct_with_other_type.rs | 25 ----------- .../generic-associated-types-where.rs | 32 -------------- .../rfc1598-generic-associated-types/iterable.rs | 20 --------- .../pointer_family.rs | 44 ------------------- .../streaming_iterator.rs | 32 -------------- .../whitespace-before-generics.rs | 35 --------------- .../construct_with_other_type.rs | 28 ++++++++++++ .../construct_with_other_type.stderr | 8 ++++ .../generic-associated-types-where.rs | 37 ++++++++++++++++ .../generic-associated-types-where.stderr | 8 ++++ .../rfc1598-generic-associated-types/iterable.rs | 23 ++++++++++ .../iterable.stderr | 8 ++++ .../pointer_family.rs | 50 ++++++++++++++++++++++ .../pointer_family.stderr | 26 +++++++++++ .../streaming_iterator.rs | 38 ++++++++++++++++ .../streaming_iterator.stderr | 20 +++++++++ 17 files changed, 250 insertions(+), 188 deletions(-) delete mode 100644 src/test/run-pass/rfc1598-generic-associated-types/construct_with_other_type.rs delete mode 100644 src/test/run-pass/rfc1598-generic-associated-types/generic-associated-types-where.rs delete mode 100644 src/test/run-pass/rfc1598-generic-associated-types/iterable.rs delete mode 100644 src/test/run-pass/rfc1598-generic-associated-types/pointer_family.rs delete mode 100644 src/test/run-pass/rfc1598-generic-associated-types/streaming_iterator.rs delete mode 100644 src/test/run-pass/rfc1598-generic-associated-types/whitespace-before-generics.rs create mode 100644 src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.rs create mode 100644 src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.stderr create mode 100644 src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs create mode 100644 src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.stderr create mode 100644 src/test/ui/rfc1598-generic-associated-types/iterable.rs create mode 100644 src/test/ui/rfc1598-generic-associated-types/iterable.stderr create mode 100644 src/test/ui/rfc1598-generic-associated-types/pointer_family.rs create mode 100644 src/test/ui/rfc1598-generic-associated-types/pointer_family.stderr create mode 100644 src/test/ui/rfc1598-generic-associated-types/streaming_iterator.rs create mode 100644 src/test/ui/rfc1598-generic-associated-types/streaming_iterator.stderr diff --git a/src/test/compile-fail/feature-gate-generic_associated_types.rs b/src/test/compile-fail/feature-gate-generic_associated_types.rs index e2643bafd38..724ec2496f2 100644 --- a/src/test/compile-fail/feature-gate-generic_associated_types.rs +++ b/src/test/compile-fail/feature-gate-generic_associated_types.rs @@ -12,13 +12,17 @@ use std::ops::Deref; trait PointerFamily { type Pointer: Deref; + //~^ ERROR generic associated types are unstable type Pointer2: Deref where T: Clone, U: Clone; + //~^ ERROR generic associated types are unstable } struct Foo; impl PointerFamily for Foo { type Pointer = Box; + //~^ ERROR generic associated types are unstable type Pointer2 = Box; + //~^ ERROR generic associated types are unstable } fn main() {} diff --git a/src/test/run-pass/rfc1598-generic-associated-types/construct_with_other_type.rs b/src/test/run-pass/rfc1598-generic-associated-types/construct_with_other_type.rs deleted file mode 100644 index 81475c6888d..00000000000 --- a/src/test/run-pass/rfc1598-generic-associated-types/construct_with_other_type.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(generic_associated_types)] - -trait Foo { - type Bar<'a, 'b>; -} - -trait Baz { - type Quux<'a>; -} - -impl Baz for T where T: Foo { - type Quux<'a> = ::Bar<'a, 'static>; -} - -fn main() {} diff --git a/src/test/run-pass/rfc1598-generic-associated-types/generic-associated-types-where.rs b/src/test/run-pass/rfc1598-generic-associated-types/generic-associated-types-where.rs deleted file mode 100644 index cad8a96b8f0..00000000000 --- a/src/test/run-pass/rfc1598-generic-associated-types/generic-associated-types-where.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2012 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(generic_associated_types)] - -// Checking the interaction with this other feature -#![feature(associated_type_defaults)] - -use std::fmt::{Display, Debug}; - -trait Foo { - type Assoc where Self: Sized; - type Assoc2 where T: Display; - type WithDefault where T: Debug = Iterator; -} - -struct Bar; - -impl Foo for Bar { - type Assoc = usize; - type Assoc2 = Vec; - type WithDefault<'a, T> = &'a Iterator; -} - -fn main() {} diff --git a/src/test/run-pass/rfc1598-generic-associated-types/iterable.rs b/src/test/run-pass/rfc1598-generic-associated-types/iterable.rs deleted file mode 100644 index 40b1d131292..00000000000 --- a/src/test/run-pass/rfc1598-generic-associated-types/iterable.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(generic_associated_types)] - -trait Iterable { - type Item<'a>; - type Iter<'a>: Iterator>; - - fn iter<'a>(&'a self) -> Self::Iter<'a>; -} - -fn main() {} diff --git a/src/test/run-pass/rfc1598-generic-associated-types/pointer_family.rs b/src/test/run-pass/rfc1598-generic-associated-types/pointer_family.rs deleted file mode 100644 index 0d0f1396969..00000000000 --- a/src/test/run-pass/rfc1598-generic-associated-types/pointer_family.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2012 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(generic_associated_types)] - -use std::rc::Rc; -use std::sync::Arc; -use std::ops::Deref; - -trait PointerFamily { - type Pointer: Deref; - fn new(value: T) -> Self::Pointer; -} - -struct ArcFamily; - -impl PointerFamily for ArcFamily { - type Pointer = Arc; - fn new(value: T) -> Self::Pointer { - Arc::new(value) - } -} - -struct RcFamily; - -impl PointerFamily for RcFamily { - type Pointer = Rc; - fn new(value: T) -> Self::Pointer { - Rc::new(value) - } -} - -struct Foo { - bar: P::Pointer, -} - -fn main() {} diff --git a/src/test/run-pass/rfc1598-generic-associated-types/streaming_iterator.rs b/src/test/run-pass/rfc1598-generic-associated-types/streaming_iterator.rs deleted file mode 100644 index 58ec14d1075..00000000000 --- a/src/test/run-pass/rfc1598-generic-associated-types/streaming_iterator.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2012 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(generic_associated_types)] - -use std::fmt::Display; - -trait StreamingIterator { - type Item<'a>; - // Applying the lifetime parameter `'a` to `Self::Item` inside the trait. - fn next<'a>(&'a self) -> Option>; -} - -struct Foo { - // Applying a concrete lifetime to the constructor outside the trait. - bar: ::Item<'static>, -} - -// Users can bound parameters by the type constructed by that trait's associated type constructor -// of a trait using HRTB. Both type equality bounds and trait bounds of this kind are valid: -//FIXME(sunjay): This next line should parse and be valid -//fn foo StreamingIterator=&'a [i32]>>(iter: T) { /* ... */ } -fn foo(iter: T) where T: StreamingIterator, for<'a> T::Item<'a>: Display { /* ... */ } - -fn main() {} diff --git a/src/test/run-pass/rfc1598-generic-associated-types/whitespace-before-generics.rs b/src/test/run-pass/rfc1598-generic-associated-types/whitespace-before-generics.rs deleted file mode 100644 index 892a925f3d5..00000000000 --- a/src/test/run-pass/rfc1598-generic-associated-types/whitespace-before-generics.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(generic_associated_types)] - -// Checking the interaction with this other feature -#![feature(associated_type_defaults)] - -use std::fmt::{Display, Debug}; - -trait Foo { - type Assoc where Self: Sized; - type Assoc2 where T: Display; - type WithDefault = Iterator where T: Debug; - // No generics on this associated type - type NoGenerics; -} - -struct Bar; - -impl Foo for Bar { - type Assoc = usize; - type Assoc2 = Vec; - type WithDefault<'a, T> = &'a Iterator; - type NoGenerics = f64; -} - -fn main() {} diff --git a/src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.rs b/src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.rs new file mode 100644 index 00000000000..87a0b33e63b --- /dev/null +++ b/src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.rs @@ -0,0 +1,28 @@ +// Copyright 2012 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(generic_associated_types)] + +//FIXME(#44265): "undeclared lifetime" errors will be addressed in a follow-up PR + +trait Foo { + type Bar<'a, 'b>; +} + +trait Baz { + type Quux<'a>; +} + +impl Baz for T where T: Foo { + type Quux<'a> = ::Bar<'a, 'static>; + //~^ ERROR undeclared lifetime +} + +fn main() {} diff --git a/src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.stderr b/src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.stderr new file mode 100644 index 00000000000..3c3c5d12627 --- /dev/null +++ b/src/test/ui/rfc1598-generic-associated-types/construct_with_other_type.stderr @@ -0,0 +1,8 @@ +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/construct_with_other_type.rs:24:37 + | +24 | type Quux<'a> = ::Bar<'a, 'static>; + | ^^ undeclared lifetime + +error: aborting due to previous error + diff --git a/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs b/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs new file mode 100644 index 00000000000..af580aeccf7 --- /dev/null +++ b/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs @@ -0,0 +1,37 @@ +// Copyright 2012 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(generic_associated_types)] + +// Checking the interaction with this other feature +#![feature(associated_type_defaults)] + +//FIXME(#44265): "undeclared lifetime" errors will be addressed in a follow-up PR + +use std::fmt::{Display, Debug}; + +trait Foo { + type Assoc where Self: Sized; + type Assoc2 where T: Display; + type WithDefault where T: Debug = Iterator; + type NoGenerics; +} + +struct Bar; + +impl Foo for Bar { + type Assoc = usize; + type Assoc2 = Vec; + type WithDefault<'a, T> = &'a Iterator; + //~^ ERROR undeclared lifetime + type NoGenerics = ::std::cell::Cell; +} + +fn main() {} diff --git a/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.stderr b/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.stderr new file mode 100644 index 00000000000..1ffeb36f6ae --- /dev/null +++ b/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.stderr @@ -0,0 +1,8 @@ +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/generic-associated-types-where.rs:32:32 + | +32 | type WithDefault<'a, T> = &'a Iterator; + | ^^ undeclared lifetime + +error: aborting due to previous error + diff --git a/src/test/ui/rfc1598-generic-associated-types/iterable.rs b/src/test/ui/rfc1598-generic-associated-types/iterable.rs new file mode 100644 index 00000000000..0019c4be5e8 --- /dev/null +++ b/src/test/ui/rfc1598-generic-associated-types/iterable.rs @@ -0,0 +1,23 @@ +// Copyright 2012 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(generic_associated_types)] + +//FIXME(#44265): "undeclared lifetime" errors will be addressed in a follow-up PR + +trait Iterable { + type Item<'a>; + type Iter<'a>: Iterator>; + //~^ ERROR undeclared lifetime + + fn iter<'a>(&'a self) -> Self::Iter<'a>; +} + +fn main() {} diff --git a/src/test/ui/rfc1598-generic-associated-types/iterable.stderr b/src/test/ui/rfc1598-generic-associated-types/iterable.stderr new file mode 100644 index 00000000000..0e565047afe --- /dev/null +++ b/src/test/ui/rfc1598-generic-associated-types/iterable.stderr @@ -0,0 +1,8 @@ +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/iterable.rs:17:47 + | +17 | type Iter<'a>: Iterator>; + | ^^ undeclared lifetime + +error: aborting due to previous error + diff --git a/src/test/ui/rfc1598-generic-associated-types/pointer_family.rs b/src/test/ui/rfc1598-generic-associated-types/pointer_family.rs new file mode 100644 index 00000000000..cbeeb1d6ca7 --- /dev/null +++ b/src/test/ui/rfc1598-generic-associated-types/pointer_family.rs @@ -0,0 +1,50 @@ +// Copyright 2012 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(generic_associated_types)] + +//FIXME(#44265): "type parameter not allowed" errors will be addressed in a follow-up PR + +use std::rc::Rc; +use std::sync::Arc; +use std::ops::Deref; + +trait PointerFamily { + type Pointer: Deref; + fn new(value: T) -> Self::Pointer; + //~^ ERROR type parameters are not allowed on this type [E0109] +} + +struct ArcFamily; + +impl PointerFamily for ArcFamily { + type Pointer = Arc; + fn new(value: T) -> Self::Pointer { + //~^ ERROR type parameters are not allowed on this type [E0109] + Arc::new(value) + } +} + +struct RcFamily; + +impl PointerFamily for RcFamily { + type Pointer = Rc; + fn new(value: T) -> Self::Pointer { + //~^ ERROR type parameters are not allowed on this type [E0109] + Rc::new(value) + } +} + +struct Foo { + bar: P::Pointer, + //~^ ERROR type parameters are not allowed on this type [E0109] +} + +fn main() {} diff --git a/src/test/ui/rfc1598-generic-associated-types/pointer_family.stderr b/src/test/ui/rfc1598-generic-associated-types/pointer_family.stderr new file mode 100644 index 00000000000..cc7f06f3b86 --- /dev/null +++ b/src/test/ui/rfc1598-generic-associated-types/pointer_family.stderr @@ -0,0 +1,26 @@ +error[E0109]: type parameters are not allowed on this type + --> $DIR/pointer_family.rs:46:21 + | +46 | bar: P::Pointer, + | ^^^^^^ type parameter not allowed + +error[E0109]: type parameters are not allowed on this type + --> $DIR/pointer_family.rs:21:42 + | +21 | fn new(value: T) -> Self::Pointer; + | ^ type parameter not allowed + +error[E0109]: type parameters are not allowed on this type + --> $DIR/pointer_family.rs:29:42 + | +29 | fn new(value: T) -> Self::Pointer { + | ^ type parameter not allowed + +error[E0109]: type parameters are not allowed on this type + --> $DIR/pointer_family.rs:39:42 + | +39 | fn new(value: T) -> Self::Pointer { + | ^ type parameter not allowed + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.rs b/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.rs new file mode 100644 index 00000000000..f9e270ee92e --- /dev/null +++ b/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.rs @@ -0,0 +1,38 @@ +// Copyright 2012 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(generic_associated_types)] + +//FIXME(#44265): "lifetime parameter not allowed on this type" errors will be addressed in a +// follow-up PR + +use std::fmt::Display; + +trait StreamingIterator { + type Item<'a>; + // Applying the lifetime parameter `'a` to `Self::Item` inside the trait. + fn next<'a>(&'a self) -> Option>; + //~^ ERROR lifetime parameters are not allowed on this type [E0110] +} + +struct Foo { + // Applying a concrete lifetime to the constructor outside the trait. + bar: ::Item<'static>, + //~^ ERROR lifetime parameters are not allowed on this type [E0110] +} + +// Users can bound parameters by the type constructed by that trait's associated type constructor +// of a trait using HRTB. Both type equality bounds and trait bounds of this kind are valid: +//FIXME(sunjay): This next line should parse and be valid +//fn foo StreamingIterator=&'a [i32]>>(iter: T) { /* ... */ } +fn foo(iter: T) where T: StreamingIterator, for<'a> T::Item<'a>: Display { /* ... */ } +//~^ ERROR lifetime parameters are not allowed on this type [E0110] + +fn main() {} diff --git a/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.stderr b/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.stderr new file mode 100644 index 00000000000..b1908d022ed --- /dev/null +++ b/src/test/ui/rfc1598-generic-associated-types/streaming_iterator.stderr @@ -0,0 +1,20 @@ +error[E0110]: lifetime parameters are not allowed on this type + --> $DIR/streaming_iterator.rs:27:41 + | +27 | bar: ::Item<'static>, + | ^^^^^^^ lifetime parameter not allowed on this type + +error[E0110]: lifetime parameters are not allowed on this type + --> $DIR/streaming_iterator.rs:35:64 + | +35 | fn foo(iter: T) where T: StreamingIterator, for<'a> T::Item<'a>: Display { /* ... */ } + | ^^ lifetime parameter not allowed on this type + +error[E0110]: lifetime parameters are not allowed on this type + --> $DIR/streaming_iterator.rs:21:48 + | +21 | fn next<'a>(&'a self) -> Option>; + | ^^ lifetime parameter not allowed on this type + +error: aborting due to 3 previous errors + -- cgit 1.4.1-3-g733a5