trait PointerFamily<U> {
type Pointer<T>: Deref<Target = T>;
+ //~^ ERROR generic associated types are unstable
type Pointer2<T>: Deref<Target = T> where T: Clone, U: Clone;
+ //~^ ERROR generic associated types are unstable
}
struct Foo;
impl PointerFamily<u32> for Foo {
type Pointer<usize> = Box<usize>;
+ //~^ ERROR generic associated types are unstable
type Pointer2<u32> = Box<u32>;
+ //~^ ERROR generic associated types are unstable
}
fn main() {}
+++ /dev/null
-// 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T> Baz for T where T: Foo {
- type Quux<'a> = <T as Foo>::Bar<'a, 'static>;
-}
-
-fn main() {}
+++ /dev/null
-// 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T> where T: Display;
- type WithDefault<T> where T: Debug = Iterator<Item=T>;
-}
-
-struct Bar;
-
-impl Foo for Bar {
- type Assoc = usize;
- type Assoc2<T> = Vec<T>;
- type WithDefault<'a, T> = &'a Iterator<T>;
-}
-
-fn main() {}
+++ /dev/null
-// 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<Item = Self::Item<'a>>;
-
- fn iter<'a>(&'a self) -> Self::Iter<'a>;
-}
-
-fn main() {}
+++ /dev/null
-// 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T>: Deref<Target = T>;
- fn new<T>(value: T) -> Self::Pointer<T>;
-}
-
-struct ArcFamily;
-
-impl PointerFamily for ArcFamily {
- type Pointer<T> = Arc<T>;
- fn new<T>(value: T) -> Self::Pointer<T> {
- Arc::new(value)
- }
-}
-
-struct RcFamily;
-
-impl PointerFamily for RcFamily {
- type Pointer<T> = Rc<T>;
- fn new<T>(value: T) -> Self::Pointer<T> {
- Rc::new(value)
- }
-}
-
-struct Foo<P: PointerFamily> {
- bar: P::Pointer<String>,
-}
-
-fn main() {}
+++ /dev/null
-// 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<Self::Item<'a>>;
-}
-
-struct Foo<T: StreamingIterator> {
- // Applying a concrete lifetime to the constructor outside the trait.
- bar: <T as StreamingIterator>::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<T: for<'a> StreamingIterator<Item<'a>=&'a [i32]>>(iter: T) { /* ... */ }
-fn foo<T>(iter: T) where T: StreamingIterator, for<'a> T::Item<'a>: Display { /* ... */ }
-
-fn main() {}
+++ /dev/null
-// 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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 <T >where T: Display;
- type WithDefault <T> = Iterator <Item=T> where T: Debug;
- // No generics on this associated type
- type NoGenerics;
-}
-
-struct Bar;
-
-impl Foo for Bar {
- type Assoc = usize;
- type Assoc2 <T> = Vec<T>;
- type WithDefault<'a, T> = &'a Iterator<T>;
- type NoGenerics = f64;
-}
-
-fn main() {}
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T> Baz for T where T: Foo {
+ type Quux<'a> = <T as Foo>::Bar<'a, 'static>;
+ //~^ ERROR undeclared lifetime
+}
+
+fn main() {}
--- /dev/null
+error[E0261]: use of undeclared lifetime name `'a`
+ --> $DIR/construct_with_other_type.rs:24:37
+ |
+24 | type Quux<'a> = <T as Foo>::Bar<'a, 'static>;
+ | ^^ undeclared lifetime
+
+error: aborting due to previous error
+
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T> where T: Display;
+ type WithDefault<T> where T: Debug = Iterator<Item=T>;
+ type NoGenerics;
+}
+
+struct Bar;
+
+impl Foo for Bar {
+ type Assoc = usize;
+ type Assoc2<T> = Vec<T>;
+ type WithDefault<'a, T> = &'a Iterator<T>;
+ //~^ ERROR undeclared lifetime
+ type NoGenerics = ::std::cell::Cell<i32>;
+}
+
+fn main() {}
--- /dev/null
+error[E0261]: use of undeclared lifetime name `'a`
+ --> $DIR/generic-associated-types-where.rs:32:32
+ |
+32 | type WithDefault<'a, T> = &'a Iterator<T>;
+ | ^^ undeclared lifetime
+
+error: aborting due to previous error
+
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<Item = Self::Item<'a>>;
+ //~^ ERROR undeclared lifetime
+
+ fn iter<'a>(&'a self) -> Self::Iter<'a>;
+}
+
+fn main() {}
--- /dev/null
+error[E0261]: use of undeclared lifetime name `'a`
+ --> $DIR/iterable.rs:17:47
+ |
+17 | type Iter<'a>: Iterator<Item = Self::Item<'a>>;
+ | ^^ undeclared lifetime
+
+error: aborting due to previous error
+
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T>: Deref<Target = T>;
+ fn new<T>(value: T) -> Self::Pointer<T>;
+ //~^ ERROR type parameters are not allowed on this type [E0109]
+}
+
+struct ArcFamily;
+
+impl PointerFamily for ArcFamily {
+ type Pointer<T> = Arc<T>;
+ fn new<T>(value: T) -> Self::Pointer<T> {
+ //~^ ERROR type parameters are not allowed on this type [E0109]
+ Arc::new(value)
+ }
+}
+
+struct RcFamily;
+
+impl PointerFamily for RcFamily {
+ type Pointer<T> = Rc<T>;
+ fn new<T>(value: T) -> Self::Pointer<T> {
+ //~^ ERROR type parameters are not allowed on this type [E0109]
+ Rc::new(value)
+ }
+}
+
+struct Foo<P: PointerFamily> {
+ bar: P::Pointer<String>,
+ //~^ ERROR type parameters are not allowed on this type [E0109]
+}
+
+fn main() {}
--- /dev/null
+error[E0109]: type parameters are not allowed on this type
+ --> $DIR/pointer_family.rs:46:21
+ |
+46 | bar: P::Pointer<String>,
+ | ^^^^^^ type parameter not allowed
+
+error[E0109]: type parameters are not allowed on this type
+ --> $DIR/pointer_family.rs:21:42
+ |
+21 | fn new<T>(value: T) -> Self::Pointer<T>;
+ | ^ type parameter not allowed
+
+error[E0109]: type parameters are not allowed on this type
+ --> $DIR/pointer_family.rs:29:42
+ |
+29 | fn new<T>(value: T) -> Self::Pointer<T> {
+ | ^ type parameter not allowed
+
+error[E0109]: type parameters are not allowed on this type
+ --> $DIR/pointer_family.rs:39:42
+ |
+39 | fn new<T>(value: T) -> Self::Pointer<T> {
+ | ^ type parameter not allowed
+
+error: aborting due to 4 previous errors
+
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<Self::Item<'a>>;
+ //~^ ERROR lifetime parameters are not allowed on this type [E0110]
+}
+
+struct Foo<T: StreamingIterator> {
+ // Applying a concrete lifetime to the constructor outside the trait.
+ bar: <T as StreamingIterator>::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<T: for<'a> StreamingIterator<Item<'a>=&'a [i32]>>(iter: T) { /* ... */ }
+fn foo<T>(iter: T) where T: StreamingIterator, for<'a> T::Item<'a>: Display { /* ... */ }
+//~^ ERROR lifetime parameters are not allowed on this type [E0110]
+
+fn main() {}
--- /dev/null
+error[E0110]: lifetime parameters are not allowed on this type
+ --> $DIR/streaming_iterator.rs:27:41
+ |
+27 | bar: <T as StreamingIterator>::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<T>(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<Self::Item<'a>>;
+ | ^^ lifetime parameter not allowed on this type
+
+error: aborting due to 3 previous errors
+