Stabilize GATs

This commit is contained in:
Jack Huey 2022-05-04 10:22:19 -04:00
parent 02654a0844
commit 3cf0e98dc9
280 changed files with 313 additions and 808 deletions

View File

@ -342,25 +342,6 @@ fn maybe_report_invalid_custom_discriminants(&self, variants: &[ast::Variant]) {
}
}
fn check_gat(&self, generics: &ast::Generics, span: Span) {
if !generics.params.is_empty() {
gate_feature_post!(
&self,
generic_associated_types,
span,
"generic associated types are unstable"
);
}
if !generics.where_clause.predicates.is_empty() {
gate_feature_post!(
&self,
generic_associated_types,
span,
"where clauses on associated types are unstable"
);
}
}
/// Feature gate `impl Trait` inside `type Alias = $type_expr;`.
fn check_impl_trait(&self, ty: &ast::Ty) {
struct ImplTraitVisitor<'a> {
@ -719,7 +700,7 @@ fn visit_assoc_constraint(&mut self, constraint: &'a AssocConstraint) {
fn visit_assoc_item(&mut self, i: &'a ast::AssocItem, ctxt: AssocCtxt) {
let is_fn = match i.kind {
ast::AssocItemKind::Fn(_) => true,
ast::AssocItemKind::TyAlias(box ast::TyAlias { ref generics, ref ty, .. }) => {
ast::AssocItemKind::TyAlias(box ast::TyAlias { ref ty, .. }) => {
if let (Some(_), AssocCtxt::Trait) = (ty, ctxt) {
gate_feature_post!(
&self,
@ -731,7 +712,6 @@ fn visit_assoc_item(&mut self, i: &'a ast::AssocItem, ctxt: AssocCtxt) {
if let Some(ty) = ty {
self.check_impl_trait(ty);
}
self.check_gat(generics, i.span);
false
}
_ => false,

View File

@ -161,6 +161,8 @@ macro_rules! declare_features {
(accepted, fn_must_use, "1.27.0", Some(43302), None),
/// Allows capturing variables in scope using format_args!
(accepted, format_args_capture, "1.58.0", Some(67984), None),
/// Allows associated types to be generic, e.g., `type Foo<T>;` (RFC 1598).
(accepted, generic_associated_types, "CURRENT_RUSTC_VERSION", Some(44265), None),
/// Allows attributes on lifetime/type formal parameters in generics (RFC 1327).
(accepted, generic_param_attrs, "1.27.0", Some(48848), None),
/// Allows the `#[global_allocator]` attribute.

View File

@ -398,8 +398,6 @@ pub fn set(&self, features: &mut Features, span: Span) {
(active, generators, "1.21.0", Some(43122), None),
/// Infer generic args for both consts and types.
(active, generic_arg_infer, "1.55.0", Some(85077), None),
/// Allows associated types to be generic, e.g., `type Foo<T>;` (RFC 1598).
(active, generic_associated_types, "1.23.0", Some(44265), None),
/// An extension to the `generic_associated_types` feature, allowing incomplete features.
(incomplete, generic_associated_types_extended, "1.61.0", Some(95451), None),
/// Allows non-trivial generic constants which have to have wfness manually propagated to callers

View File

@ -3989,8 +3989,6 @@
/// ### Example
///
/// ```rust
/// #![feature(generic_associated_types)]
///
/// trait Trait {
/// type Assoc<'a> where Self: 'a;
/// }

View File

@ -2,7 +2,7 @@
#![feature(decl_macro)]
#![feature(drain_filter)]
#![feature(generators)]
#![feature(generic_associated_types)]
#![cfg_attr(bootstrap, feature(generic_associated_types))]
#![feature(iter_from_generator)]
#![feature(let_chains)]
#![feature(let_else)]

View File

@ -31,7 +31,7 @@
#![feature(discriminant_kind)]
#![feature(exhaustive_patterns)]
#![feature(get_mut_unchecked)]
#![feature(generic_associated_types)]
#![cfg_attr(bootstrap, feature(generic_associated_types))]
#![feature(if_let_guard)]
#![feature(map_first_last)]
#![feature(negative_impls)]

View File

@ -2064,8 +2064,6 @@ fn confirm_impl_candidate<'cx, 'tcx>(
// Get obligations corresponding to the predicates from the where-clause of the
// associated type itself.
// Note: `feature(generic_associated_types)` is required to write such
// predicates, even for non-generic associated types.
fn assoc_ty_own_obligations<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>,

View File

@ -16,7 +16,7 @@
#![feature(type_ascription)]
#![feature(iter_intersperse)]
#![feature(type_alias_impl_trait)]
#![feature(generic_associated_types)]
#![cfg_attr(bootstrap, feature(generic_associated_types))]
#![recursion_limit = "256"]
#![warn(rustc::internal)]
#![allow(clippy::collapsible_if, clippy::collapsible_else_if)]

View File

@ -3,8 +3,6 @@
// pretty-compare-only
#![feature(generic_associated_types)]
trait X {
type Y<T>: Trait where Self: Sized;
}

View File

@ -1,7 +1,7 @@
// ignore-tidy-linelength
#![no_core]
#![feature(generic_associated_types, lang_items, no_core)]
#![feature(lang_items, no_core)]
#[lang = "sized"]
pub trait Sized {}

View File

@ -1,5 +1,4 @@
#![crate_name = "foo"]
#![feature(generic_associated_types)]
// @has foo/trait.LendingIterator.html
pub trait LendingIterator {

View File

@ -1,5 +1,4 @@
#![crate_name = "foo"]
#![feature(generic_associated_types)]
pub trait Trait {
type Gat<'a>;

View File

@ -1,4 +1,3 @@
#![feature(generic_associated_types)]
#![crate_name = "foo"]
pub trait MyTrait { fn dummy(&self) { } }

View File

@ -1,5 +1,3 @@
#![feature(generic_associated_types)]
trait Trait {
type Bound<'a>;
}

View File

@ -1,5 +1,5 @@
error: `for<...>` is not allowed on associated type bounds
--> $DIR/binder-on-bound.rs:7:22
--> $DIR/binder-on-bound.rs:5:22
|
LL | fn foo() where Trait<for<'a> Bound<'a> = &'a ()> {
| ^^^^^^^^^^^^^^^^^

View File

@ -2,7 +2,6 @@
#![allow(incomplete_features)]
#![feature(associated_type_bounds)]
#![feature(generic_associated_types)]
trait MP {
type T<'a>;

View File

@ -1,7 +1,5 @@
// check-pass
#![feature(generic_associated_types)]
trait CallWithShim: Sized {
type Shim<'s>
where

View File

@ -1,31 +0,0 @@
use std::ops::Deref;
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
//~| ERROR where clauses on 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
//~| ERROR the trait bound `U32: Clone` is not satisfied
}
trait Bar {
type Assoc where Self: Sized;
//~^ ERROR where clauses on associated types are unstable
}
impl Bar for Foo {
type Assoc = Foo where Self: Sized;
//~^ ERROR where clauses on associated types are unstable
}
fn main() {}

View File

@ -1,78 +0,0 @@
error[E0658]: generic associated types are unstable
--> $DIR/feature-gate-generic_associated_types.rs:4:5
|
LL | type Pointer<T>: Deref<Target = T>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
= help: add `#![feature(generic_associated_types)]` to the crate attributes to enable
error[E0658]: generic associated types are unstable
--> $DIR/feature-gate-generic_associated_types.rs:6:5
|
LL | type Pointer2<T>: Deref<Target = T> where T: Clone, U: Clone;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
= help: add `#![feature(generic_associated_types)]` to the crate attributes to enable
error[E0658]: where clauses on associated types are unstable
--> $DIR/feature-gate-generic_associated_types.rs:6:5
|
LL | type Pointer2<T>: Deref<Target = T> where T: Clone, U: Clone;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
= help: add `#![feature(generic_associated_types)]` to the crate attributes to enable
error[E0658]: generic associated types are unstable
--> $DIR/feature-gate-generic_associated_types.rs:14:5
|
LL | type Pointer<Usize> = Box<Usize>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
= help: add `#![feature(generic_associated_types)]` to the crate attributes to enable
error[E0658]: generic associated types are unstable
--> $DIR/feature-gate-generic_associated_types.rs:16:5
|
LL | type Pointer2<U32> = Box<U32>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
= help: add `#![feature(generic_associated_types)]` to the crate attributes to enable
error[E0658]: where clauses on associated types are unstable
--> $DIR/feature-gate-generic_associated_types.rs:22:5
|
LL | type Assoc where Self: Sized;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
= help: add `#![feature(generic_associated_types)]` to the crate attributes to enable
error[E0658]: where clauses on associated types are unstable
--> $DIR/feature-gate-generic_associated_types.rs:27:5
|
LL | type Assoc = Foo where Self: Sized;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
= help: add `#![feature(generic_associated_types)]` to the crate attributes to enable
error[E0277]: the trait bound `U32: Clone` is not satisfied
--> $DIR/feature-gate-generic_associated_types.rs:16:26
|
LL | type Pointer2<U32> = Box<U32>;
| ^^^^^^^^ the trait `Clone` is not implemented for `U32`
|
help: consider restricting type parameter `U32`
|
LL | type Pointer2<U32: std::clone::Clone> = Box<U32>;
| +++++++++++++++++++
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0277, E0658.
For more information about an error, try `rustc --explain E0277`.

View File

@ -1,5 +1,3 @@
#![feature(generic_associated_types)]
// This feature doesn't *currently* fire on any specific code; it's just a
// behavior change. Future changes might.
#[rustc_error] //~ the

View File

@ -1,5 +1,5 @@
error[E0658]: the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable
--> $DIR/feature-gate-generic_associated_types_extended.rs:5:1
--> $DIR/feature-gate-generic_associated_types_extended.rs:3:1
|
LL | #[rustc_error]
| ^^^^^^^^^^^^^^

View File

@ -1,7 +1,6 @@
// check-pass
//
// regression test for #98702
#![feature(generic_associated_types)]
trait Foo {
type Assoc<T>;

View File

@ -1,5 +1,3 @@
#![feature(generic_associated_types)]
use std::{future::Future, pin::Pin};
pub trait Foo {

View File

@ -3,8 +3,6 @@
// This should pass, but it requires `Sized` to be coinductive.
#![feature(generic_associated_types)]
trait Allocator {
type Allocated<T>;
}

View File

@ -1,11 +1,11 @@
error[E0275]: overflow evaluating the requirement `LinkedList<A>: Sized`
--> $DIR/issue-80626.rs:14:10
--> $DIR/issue-80626.rs:12:10
|
LL | Next(A::Allocated<Self>)
| ^^^^^^^^^^^^^^^^^^
|
note: required by a bound in `Allocator::Allocated`
--> $DIR/issue-80626.rs:9:20
--> $DIR/issue-80626.rs:7:20
|
LL | type Allocated<T>;
| ^ required by this bound in `Allocator::Allocated`

View File

@ -3,7 +3,6 @@
// This should pass, but seems to run into a TAIT issue.
#![feature(generic_associated_types)]
#![feature(type_alias_impl_trait)]
pub trait Stream {

View File

@ -1,17 +1,17 @@
error[E0477]: the type `<() as Yay<&'a ()>>::InnerStream<'s>` does not fulfill the required lifetime
--> $DIR/issue-86218.rs:23:28
--> $DIR/issue-86218.rs:22:28
|
LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: type must outlive the lifetime `'s` as defined here as required by this binding
--> $DIR/issue-86218.rs:23:22
--> $DIR/issue-86218.rs:22:22
|
LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
| ^^
error: unconstrained opaque type
--> $DIR/issue-86218.rs:23:28
--> $DIR/issue-86218.rs:22:28
|
LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -3,8 +3,6 @@
// This should pass, but we need an extension of implied bounds (probably).
#![feature(generic_associated_types)]
pub trait AsRef2 {
type Output<'a> where Self: 'a;

View File

@ -1,5 +1,5 @@
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
--> $DIR/issue-87735.rs:27:13
--> $DIR/issue-87735.rs:25:13
|
LL | impl<'b, T, U> AsRef2 for Foo<T>
| ^ unconstrained type parameter

View File

@ -3,8 +3,6 @@
// This should pass.
#![feature(generic_associated_types)]
use std::fmt::Debug;
trait Foo {

View File

@ -1,5 +1,5 @@
error[E0275]: overflow evaluating the requirement `<Bar as Foo>::Ass == _`
--> $DIR/issue-87755.rs:18:16
--> $DIR/issue-87755.rs:16:16
|
LL | type Ass = Bar;
| ^^^

View File

@ -4,8 +4,6 @@
// This should pass, but using a type alias vs a reference directly
// changes late-bound -> early-bound.
#![feature(generic_associated_types)]
trait Scanner {
type Input<'a>;
type Token<'a>;

View File

@ -1,5 +1,5 @@
error[E0195]: lifetime parameters or bounds on method `scan` do not match the trait declaration
--> $DIR/issue-87803.rs:22:12
--> $DIR/issue-87803.rs:20:12
|
LL | fn scan<'a>(&mut self, i : Self::Input<'a>) -> Self::Token<'a>;
| ---- lifetimes in impl do not match this method in trait

View File

@ -3,8 +3,6 @@
// This should pass, but has a missed normalization due to HRTB.
#![feature(generic_associated_types)]
trait Iterable {
type Iterator<'a> where Self: 'a;
fn iter(&self) -> Self::Iterator<'_>;

View File

@ -1,5 +1,5 @@
error[E0631]: type mismatch in function arguments
--> $DIR/issue-88382.rs:28:40
--> $DIR/issue-88382.rs:26:40
|
LL | do_something(SomeImplementation(), test);
| ------------ ^^^^ expected due to this
@ -12,7 +12,7 @@ LL | fn test<'a, I: Iterable>(_: &mut I::Iterator<'a>) {}
= note: expected function signature `for<'r> fn(&'r mut std::iter::Empty<usize>) -> _`
found function signature `for<'a, 'r> fn(&'r mut <_ as Iterable>::Iterator<'a>) -> _`
note: required by a bound in `do_something`
--> $DIR/issue-88382.rs:22:48
--> $DIR/issue-88382.rs:20:48
|
LL | fn do_something<I: Iterable>(i: I, mut f: impl for<'a> Fn(&mut I::Iterator<'a>)) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `do_something`

View File

@ -3,8 +3,6 @@
// This should pass, but has a missed normalization due to HRTB.
#![feature(generic_associated_types)]
pub trait Marker {}
pub trait Trait {

View File

@ -1,5 +1,5 @@
error[E0277]: the trait bound `for<'a> <_ as Trait>::Assoc<'a>: Marker` is not satisfied
--> $DIR/issue-88460.rs:30:10
--> $DIR/issue-88460.rs:28:10
|
LL | test(Foo);
| ---- ^^^ the trait `for<'a> Marker` is not implemented for `<_ as Trait>::Assoc<'a>`
@ -8,7 +8,7 @@ LL | test(Foo);
|
= help: the trait `Marker` is implemented for `()`
note: required by a bound in `test`
--> $DIR/issue-88460.rs:17:27
--> $DIR/issue-88460.rs:15:27
|
LL | fn test<T>(value: T)
| ---- required by a bound in this

View File

@ -3,8 +3,6 @@
// This should pass, but requires more logic.
#![feature(generic_associated_types)]
trait A {
type I<'a>;
}

View File

@ -1,5 +1,5 @@
error[E0207]: the type parameter `I` is not constrained by the impl trait, self type, or predicates
--> $DIR/issue-88526.rs:27:13
--> $DIR/issue-88526.rs:25:13
|
LL | impl<'q, Q, I, F> A for TestB<Q, F>
| ^ unconstrained type parameter

View File

@ -5,7 +5,6 @@
// This should pass, but seems to run into a TAIT bug.
#![feature(type_alias_impl_trait)]
#![feature(generic_associated_types)]
use std::future::Future;

View File

@ -1,5 +1,5 @@
error[E0271]: type mismatch resolving `<Empty<_> as Stream>::Item == Repr`
--> $DIR/issue-89008.rs:39:43
--> $DIR/issue-89008.rs:38:43
|
LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {
| ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Empty<_> as Stream>::Item == Repr`
@ -7,7 +7,7 @@ LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {
| this type parameter
|
note: expected this to be `()`
--> $DIR/issue-89008.rs:18:17
--> $DIR/issue-89008.rs:17:17
|
LL | type Item = ();
| ^^

View File

@ -1,13 +1,12 @@
// check-fail
// known-bug
// FIXME(generic_associated_types): We almost certaintly want this to pass, but
// We almost certaintly want this to pass, but
// it's particularly difficult currently, because we need a way of specifying
// that `<Self::Base as Functor>::With<T> = Self` without using that when we have
// a `U`. See `https://github.com/rust-lang/rust/pull/92728` for a (hacky)
// solution. This might be better to just wait for Chalk.
#![feature(generic_associated_types)]
pub trait Functor {
type With<T>;

View File

@ -1,5 +1,5 @@
error[E0282]: type annotations needed
--> $DIR/issue-91762.rs:25:15
--> $DIR/issue-91762.rs:24:15
|
LL | ret = <Self::Base as Functor>::fmap(arg);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the associated function `fmap`

View File

@ -1,4 +1,3 @@
#![feature(generic_associated_types)]
#![feature(associated_type_defaults)]
// A Collection trait and collection families. Based on

View File

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/collections-project-default.rs:59:5
--> $DIR/collections-project-default.rs:58:5
|
LL | fn floatify_sibling<C>(ints: &C) -> <C as Collection<i32>>::Sibling<f32>
| ------------------------------------ expected `<C as Collection<i32>>::Sibling<f32>` because of return type

View File

@ -1,4 +1,3 @@
#![feature(generic_associated_types)]
#![feature(associated_type_defaults)]
// A Collection trait and collection families. Based on

View File

@ -1,7 +1,5 @@
// Regression test from https://github.com/rust-lang/rust/pull/98109
#![feature(generic_associated_types)]
pub trait Get {
type Value<'a>
where

View File

@ -1,5 +1,5 @@
error: `T` does not live long enough
--> $DIR/collectivity-regression.rs:15:5
--> $DIR/collectivity-regression.rs:13:5
|
LL | / || {
LL | |

View File

@ -1,5 +1,4 @@
// run-pass
#![feature(generic_associated_types)]
// This test unsures that with_opt_const_param returns the
// def_id of the N param in the Foo::Assoc GAT.

View File

@ -1,5 +1,4 @@
// run-pass
#![feature(generic_associated_types)]
// This test unsures that with_opt_const_param returns the
// def_id of the N param in the Foo::Assoc GAT.

View File

@ -1,5 +1,4 @@
// run-pass
#![feature(generic_associated_types)]
// This test unsures that with_opt_const_param returns the
// def_id of the N param in the Bar::Assoc GAT.

View File

@ -1,5 +1,3 @@
#![feature(generic_associated_types)]
trait Trait {
type Foo<const N: u8>;
}

View File

@ -1,5 +1,5 @@
error[E0053]: type `Foo` has an incompatible generic parameter for trait `Trait`
--> $DIR/const_params_have_right_type.rs:8:14
--> $DIR/const_params_have_right_type.rs:6:14
|
LL | trait Trait {
| -----

View File

@ -1,7 +1,5 @@
// Test that correct syntax is used in suggestion to constrain associated type
#![feature(generic_associated_types)]
trait X {
type Y<T>;
}

View File

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/constraint-assoc-type-suggestion.rs:12:23
--> $DIR/constraint-assoc-type-suggestion.rs:10:23
|
LL | let b: Vec<i32> = a;
| -------- ^ expected struct `Vec`, found associated type

View File

@ -1,5 +1,3 @@
#![feature(generic_associated_types)]
// check-pass
use std::ops::Deref;

View File

@ -5,7 +5,7 @@ LL | type Bar = ();
| ^^ the trait `AsRef<()>` is not implemented for `()`
|
note: required by a bound in `foo_defn::Foo::Bar`
--> $DIR/auxiliary/foo_defn.rs:6:15
--> $DIR/auxiliary/foo_defn.rs:4:15
|
LL | type Bar: AsRef<()>;
| ^^^^^^^^^ required by this bound in `foo_defn::Foo::Bar`

View File

@ -1,4 +1,3 @@
#![feature(generic_associated_types)]
#![allow(unused)]
pub trait Trait {

View File

@ -1,11 +1,11 @@
error[E0107]: missing generics for associated type `Trait::Assoc`
--> $DIR/elided-in-expr-position.rs:10:26
--> $DIR/elided-in-expr-position.rs:9:26
|
LL | fn g(&self) -> Self::Assoc;
| ^^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/elided-in-expr-position.rs:5:10
--> $DIR/elided-in-expr-position.rs:4:10
|
LL | type Assoc<'a> where Self: 'a;
| ^^^^^ --
@ -15,13 +15,13 @@ LL | fn g(&self) -> Self::Assoc<'a>;
| ~~~~~~~~~
error[E0107]: missing generics for associated type `Trait::Assoc`
--> $DIR/elided-in-expr-position.rs:32:26
--> $DIR/elided-in-expr-position.rs:31:26
|
LL | fn g(&self) -> Self::Assoc {
| ^^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/elided-in-expr-position.rs:5:10
--> $DIR/elided-in-expr-position.rs:4:10
|
LL | type Assoc<'a> where Self: 'a;
| ^^^^^ --

View File

@ -1,5 +1,3 @@
#![feature(generic_associated_types)]
trait Foo {
type Bar<,>;
//~^ ERROR expected one of `#`, `>`, `const`, identifier, or lifetime, found `,`

View File

@ -1,5 +1,5 @@
error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `,`
--> $DIR/empty_generics.rs:4:14
--> $DIR/empty_generics.rs:2:14
|
LL | trait Foo {
| - while parsing this item list starting here

View File

@ -1,5 +1,5 @@
error[E0276]: impl has stricter requirements than trait
--> $DIR/lending_iterator.rs:14:45
--> $DIR/lending_iterator.rs:13:45
|
LL | fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self;
| ------------------------------------------------------------------------ definition of `from_iter` from trait

View File

@ -2,7 +2,6 @@
//[base] check-fail
//[extended] check-pass
#![feature(generic_associated_types)]
#![cfg_attr(extended, feature(generic_associated_types_extended))]
#![cfg_attr(extended, allow(incomplete_features))]

View File

@ -1,5 +1,5 @@
error[E0276]: impl has stricter requirements than trait
--> $DIR/lending_iterator_2.rs:14:45
--> $DIR/lending_iterator_2.rs:13:45
|
LL | fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self;
| ------------------------------------------------------------------------ definition of `from_iter` from trait

View File

@ -2,7 +2,6 @@
//[base] check-fail
//[extended] check-pass
#![feature(generic_associated_types)]
#![cfg_attr(extended, feature(generic_associated_types_extended))]
#![cfg_attr(extended, allow(incomplete_features))]

View File

@ -1,16 +0,0 @@
// rust-lang/rust#60654: Do not ICE on an attempt to use GATs that is
// missing the feature gate.
struct Foo;
trait MyTrait {
type Item<T>;
//~^ ERROR generic associated types are unstable [E0658]
}
impl MyTrait for Foo {
type Item<T> = T;
//~^ ERROR generic associated types are unstable [E0658]
}
fn main() { }

View File

@ -1,21 +0,0 @@
error[E0658]: generic associated types are unstable
--> $DIR/gat-dont-ice-on-absent-feature-2.rs:7:5
|
LL | type Item<T>;
| ^^^^^^^^^^^^^
|
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
= help: add `#![feature(generic_associated_types)]` to the crate attributes to enable
error[E0658]: generic associated types are unstable
--> $DIR/gat-dont-ice-on-absent-feature-2.rs:12:5
|
LL | type Item<T> = T;
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
= help: add `#![feature(generic_associated_types)]` to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,16 +0,0 @@
// rust-lang/rust#60654: Do not ICE on an attempt to use GATs that is
// missing the feature gate.
struct Foo;
impl Iterator for Foo {
type Item<'b> = &'b Foo;
//~^ ERROR generic associated types are unstable [E0658]
//~| ERROR lifetime parameters or bounds on type `Item` do not match the trait declaration
fn next(&mut self) -> Option<Self::Item> {
None
}
}
fn main() { }

View File

@ -1,19 +0,0 @@
error[E0658]: generic associated types are unstable
--> $DIR/gat-dont-ice-on-absent-feature.rs:7:5
|
LL | type Item<'b> = &'b Foo;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
= help: add `#![feature(generic_associated_types)]` to the crate attributes to enable
error[E0195]: lifetime parameters or bounds on type `Item` do not match the trait declaration
--> $DIR/gat-dont-ice-on-absent-feature.rs:7:14
|
LL | type Item<'b> = &'b Foo;
| ^^^^ lifetimes do not match type in trait
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0195, E0658.
For more information about an error, try `rustc --explain E0195`.

View File

@ -1,5 +1,3 @@
#![feature(generic_associated_types)]
trait X {
type Y<'x>;
}

View File

@ -1,5 +1,5 @@
error[E0261]: use of undeclared lifetime name `'x`
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:8:35
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:6:35
|
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
| ^^ undeclared lifetime
@ -15,7 +15,7 @@ LL | fn _f<'x>(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
| ++++
error[E0582]: binding for associated type `Y` references lifetime `'a`, which does not appear in the trait input types
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:8:33
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:6:33
|
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
| ^^^^^^^^^^^^^^^^^

View File

@ -1,11 +1,11 @@
error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/gat-in-trait-path.rs:27:17
--> $DIR/gat-in-trait-path.rs:26:17
|
LL | fn f(_arg : Box<dyn for<'a> Foo<A<'a> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/gat-in-trait-path.rs:11:10
--> $DIR/gat-in-trait-path.rs:10:10
|
LL | trait Foo {
| --- this trait cannot be made into an object...

View File

@ -2,7 +2,6 @@
//[base] check-fail
//[extended] check-pass
#![feature(generic_associated_types)]
#![feature(associated_type_defaults)]
#![cfg_attr(extended, feature(generic_associated_types_extended))]
#![cfg_attr(extended, allow(incomplete_features))]

View File

@ -1,5 +0,0 @@
// run-pass
#![feature(generic_associated_types)]
fn main() {}

View File

@ -1,5 +1,3 @@
#![feature(generic_associated_types)]
trait Foo {
type F<'a>;

View File

@ -1,5 +1,5 @@
error[E0403]: the name `T1` is already used for a generic parameter in this item's generic parameters
--> $DIR/gat-trait-path-generic-type-arg.rs:11:12
--> $DIR/gat-trait-path-generic-type-arg.rs:9:12
|
LL | impl <T, T1> Foo for T {
| -- first use of `T1`
@ -8,13 +8,13 @@ LL | type F<T1> = &[u8];
| ^^ already used
error[E0637]: `&` without an explicit lifetime name cannot be used here
--> $DIR/gat-trait-path-generic-type-arg.rs:11:18
--> $DIR/gat-trait-path-generic-type-arg.rs:9:18
|
LL | type F<T1> = &[u8];
| ^ explicit lifetime name needed here
error[E0207]: the type parameter `T1` is not constrained by the impl trait, self type, or predicates
--> $DIR/gat-trait-path-generic-type-arg.rs:9:10
--> $DIR/gat-trait-path-generic-type-arg.rs:7:10
|
LL | impl <T, T1> Foo for T {
| ^^ unconstrained type parameter

View File

@ -1,5 +1,3 @@
#![feature(generic_associated_types)]
trait X {
type Y<'a>;

View File

@ -1,11 +1,11 @@
error[E0107]: missing generics for associated type `X::Y`
--> $DIR/gat-trait-path-missing-lifetime.rs:10:20
--> $DIR/gat-trait-path-missing-lifetime.rs:8:20
|
LL | fn foo<'a, T1: X<Y = T1>>(t : T1) -> T1::Y<'a> {
| ^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/gat-trait-path-missing-lifetime.rs:4:8
--> $DIR/gat-trait-path-missing-lifetime.rs:2:8
|
LL | type Y<'a>;
| ^ --
@ -15,13 +15,13 @@ LL | fn foo<'a, T1: X<Y<'a> = T1>>(t : T1) -> T1::Y<'a> {
| ~~~~~
error[E0107]: missing generics for associated type `X::Y`
--> $DIR/gat-trait-path-missing-lifetime.rs:10:20
--> $DIR/gat-trait-path-missing-lifetime.rs:8:20
|
LL | fn foo<'a, T1: X<Y = T1>>(t : T1) -> T1::Y<'a> {
| ^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/gat-trait-path-missing-lifetime.rs:4:8
--> $DIR/gat-trait-path-missing-lifetime.rs:2:8
|
LL | type Y<'a>;
| ^ --

View File

@ -1,5 +1,3 @@
#![feature(generic_associated_types)]
trait X {
type Y<'a>;
}

View File

@ -1,11 +1,11 @@
error: lifetime in trait object type must be followed by `+`
--> $DIR/gat-trait-path-parenthesised-args.rs:7:29
--> $DIR/gat-trait-path-parenthesised-args.rs:5:29
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^^
error: parenthesized generic arguments cannot be used in associated type constraints
--> $DIR/gat-trait-path-parenthesised-args.rs:7:27
--> $DIR/gat-trait-path-parenthesised-args.rs:5:27
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^^^^^
@ -16,7 +16,7 @@ LL | fn foo<'a>(arg: Box<dyn X<Y<'a> = &'a ()>>) {}
| ~ ~
error: parenthesized generic arguments cannot be used in associated type constraints
--> $DIR/gat-trait-path-parenthesised-args.rs:14:27
--> $DIR/gat-trait-path-parenthesised-args.rs:12:27
|
LL | fn bar<'a>(arg: Box<dyn X<Y() = ()>>) {}
| ^--
@ -24,13 +24,13 @@ LL | fn bar<'a>(arg: Box<dyn X<Y() = ()>>) {}
| help: remove these parentheses
error[E0107]: this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/gat-trait-path-parenthesised-args.rs:7:27
--> $DIR/gat-trait-path-parenthesised-args.rs:5:27
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/gat-trait-path-parenthesised-args.rs:4:8
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
LL | type Y<'a>;
| ^ --
@ -40,7 +40,7 @@ LL | fn foo<'a>(arg: Box<dyn X<Y('a, 'a) = &'a ()>>) {}
| +++
error[E0107]: this associated type takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/gat-trait-path-parenthesised-args.rs:7:27
--> $DIR/gat-trait-path-parenthesised-args.rs:5:27
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^---- help: remove these generics
@ -48,19 +48,19 @@ LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| expected 0 generic arguments
|
note: associated type defined here, with 0 generic parameters
--> $DIR/gat-trait-path-parenthesised-args.rs:4:8
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
LL | type Y<'a>;
| ^
error[E0107]: this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/gat-trait-path-parenthesised-args.rs:14:27
--> $DIR/gat-trait-path-parenthesised-args.rs:12:27
|
LL | fn bar<'a>(arg: Box<dyn X<Y() = ()>>) {}
| ^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/gat-trait-path-parenthesised-args.rs:4:8
--> $DIR/gat-trait-path-parenthesised-args.rs:2:8
|
LL | type Y<'a>;
| ^ --

View File

@ -1,7 +1,5 @@
// run-pass
#![feature(generic_associated_types)]
pub trait X {
type Y<'a> where Self: 'a;
fn m(&self) -> Self::Y<'_>;

View File

@ -1,5 +1,3 @@
#![feature(generic_associated_types)]
// Checking the interaction with this other feature
#![feature(associated_type_defaults)]

View File

@ -1,5 +1,5 @@
error[E0277]: `T` doesn't implement `std::fmt::Display`
--> $DIR/generic-associated-types-where.rs:20:22
--> $DIR/generic-associated-types-where.rs:18:22
|
LL | type Assoc2<T> = Vec<T>;
| ^^^^^^ `T` cannot be formatted with the default formatter
@ -11,7 +11,7 @@ LL | type Assoc2<T: std::fmt::Display> = Vec<T>;
| +++++++++++++++++++
error[E0276]: impl has stricter requirements than trait
--> $DIR/generic-associated-types-where.rs:22:38
--> $DIR/generic-associated-types-where.rs:20:38
|
LL | type Assoc3<T>;
| -------------- definition of `Assoc3` from trait

View File

@ -1,5 +1,3 @@
#![feature(generic_associated_types)]
use std::ops::Deref;
trait Iterable {

View File

@ -1,5 +1,5 @@
error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:8:37
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:6:37
|
LL | + Deref<Target = Self::Item<'b>>;
| ^^ undeclared lifetime
@ -19,7 +19,7 @@ LL | trait Iterable<'b> {
| ++++
error[E0261]: use of undeclared lifetime name `'undeclared`
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:11:41
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:9:41
|
LL | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>;
| ^^^^^^^^^^^ undeclared lifetime

View File

@ -1,4 +1,3 @@
#![feature(generic_associated_types)]
#![feature(associated_type_defaults)]
trait Foo {

View File

@ -1,5 +1,5 @@
error[E0276]: impl has stricter requirements than trait
--> $DIR/impl_bounds.rs:15:39
--> $DIR/impl_bounds.rs:14:39
|
LL | type A<'a> where Self: 'a;
| ---------- definition of `A` from trait
@ -8,7 +8,7 @@ LL | type A<'a> = (&'a ()) where Self: 'static;
| ^^^^^^^ impl has extra requirement `T: 'static`
error[E0276]: impl has stricter requirements than trait
--> $DIR/impl_bounds.rs:17:48
--> $DIR/impl_bounds.rs:16:48
|
LL | type B<'a, 'b> where 'a: 'b;
| -------------- definition of `B` from trait
@ -17,7 +17,7 @@ LL | type B<'a, 'b> = (&'a(), &'b ()) where 'b: 'a;
| ^^ impl has extra requirement `'b: 'a`
error[E0478]: lifetime bound not satisfied
--> $DIR/impl_bounds.rs:17:22
--> $DIR/impl_bounds.rs:16:22
|
LL | type B<'a, 'b> where 'a: 'b;
| -------------- definition of `B` from trait
@ -26,29 +26,29 @@ LL | type B<'a, 'b> = (&'a(), &'b ()) where 'b: 'a;
| ^^^^^^^^^^^^^^^ - help: try copying this clause from the trait: `, 'a: 'b`
|
note: lifetime parameter instantiated with the lifetime `'a` as defined here
--> $DIR/impl_bounds.rs:17:12
--> $DIR/impl_bounds.rs:16:12
|
LL | type B<'a, 'b> = (&'a(), &'b ()) where 'b: 'a;
| ^^
note: but lifetime parameter must outlive the lifetime `'b` as defined here
--> $DIR/impl_bounds.rs:17:16
--> $DIR/impl_bounds.rs:16:16
|
LL | type B<'a, 'b> = (&'a(), &'b ()) where 'b: 'a;
| ^^
error[E0277]: the trait bound `T: Copy` is not satisfied
--> $DIR/impl_bounds.rs:20:33
--> $DIR/impl_bounds.rs:19:33
|
LL | type C = String where Self: Copy;
| ^^^^ the trait `Copy` is not implemented for `T`
|
note: required for `Fooy<T>` to implement `Copy`
--> $DIR/impl_bounds.rs:11:10
--> $DIR/impl_bounds.rs:10:10
|
LL | #[derive(Copy, Clone)]
| ^^^^
note: the requirement `Fooy<T>: Copy` appears on the `impl`'s associated type `C` but not on the corresponding trait's associated type
--> $DIR/impl_bounds.rs:7:10
--> $DIR/impl_bounds.rs:6:10
|
LL | trait Foo {
| --- in this trait
@ -62,18 +62,18 @@ LL | impl<T: std::marker::Copy> Foo for Fooy<T> {
| +++++++++++++++++++
error[E0277]: the trait bound `T: Copy` is not satisfied
--> $DIR/impl_bounds.rs:22:24
--> $DIR/impl_bounds.rs:21:24
|
LL | fn d() where Self: Copy {}
| ^^^^ the trait `Copy` is not implemented for `T`
|
note: required for `Fooy<T>` to implement `Copy`
--> $DIR/impl_bounds.rs:11:10
--> $DIR/impl_bounds.rs:10:10
|
LL | #[derive(Copy, Clone)]
| ^^^^
note: the requirement `Fooy<T>: Copy` appears on the `impl`'s method `d` but not on the corresponding trait's method
--> $DIR/impl_bounds.rs:8:8
--> $DIR/impl_bounds.rs:7:8
|
LL | trait Foo {
| --- in this trait

View File

@ -1,6 +1,5 @@
// check-pass
#![feature(generic_associated_types)]
#![feature(associated_type_defaults)]
trait Foo {

View File

@ -1,5 +1,3 @@
#![feature(generic_associated_types)]
pub trait LendingIterator {
type Item<'a>
where

View File

@ -1,5 +1,5 @@
error[E0277]: the trait bound `for<'a> &'a mut (): Foo<&'a mut ()>` is not satisfied
--> $DIR/issue-101020.rs:33:5
--> $DIR/issue-101020.rs:31:5
|
LL | (&mut EmptyIter).consume(());
| ^^^^^^^^^^^^^^^^ ------- required by a bound introduced by this call
@ -7,12 +7,12 @@ LL | (&mut EmptyIter).consume(());
| the trait `for<'a> Foo<&'a mut ()>` is not implemented for `&'a mut ()`
|
note: required for `&'a mut ()` to implement `for<'a> FuncInput<'a, &'a mut ()>`
--> $DIR/issue-101020.rs:29:20
--> $DIR/issue-101020.rs:27:20
|
LL | impl<'a, T, F: 'a> FuncInput<'a, F> for T where F: Foo<T> {}
| ^^^^^^^^^^^^^^^^ ^
note: required by a bound in `LendingIterator::consume`
--> $DIR/issue-101020.rs:11:33
--> $DIR/issue-101020.rs:9:33
|
LL | fn consume<F>(self, _f: F)
| ------- required by a bound in this

View File

@ -1,7 +1,5 @@
// Check that this program doesn't cause the compiler to error without output.
#![feature(generic_associated_types)]
trait Foo {
type Assoc3<T>;
}

View File

@ -1,5 +1,5 @@
error[E0276]: impl has stricter requirements than trait
--> $DIR/issue-47206-where-clause.rs:12:38
--> $DIR/issue-47206-where-clause.rs:10:38
|
LL | type Assoc3<T>;
| -------------- definition of `Assoc3` from trait

View File

@ -1,7 +1,5 @@
// check-pass
#![feature(generic_associated_types)]
trait Cert {
type PublicKey<'a>: From<&'a [u8]>;
}

View File

@ -1,5 +1,3 @@
#![feature(generic_associated_types)]
// check-pass
trait Iterator {

View File

@ -1,3 +1,4 @@
// check-pass
// Fixed by #67160
trait Trait1 {
@ -6,7 +7,6 @@ trait Trait1 {
trait Trait2 {
type Type1<B>: Trait1<A=B>;
//~^ ERROR: generic associated types are unstable
}
fn main() {}

View File

@ -1,12 +0,0 @@
error[E0658]: generic associated types are unstable
--> $DIR/issue-67424.rs:8:5
|
LL | type Type1<B>: Trait1<A=B>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
= help: add `#![feature(generic_associated_types)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View File

@ -1,11 +1,11 @@
error[E0038]: the trait `X` cannot be made into an object
--> $DIR/issue-67510-pass.rs:13:23
--> $DIR/issue-67510-pass.rs:12:23
|
LL | fn _func1<'a>(_x: Box<dyn X<Y<'a>=&'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-67510-pass.rs:10:10
--> $DIR/issue-67510-pass.rs:9:10
|
LL | trait X {
| - this trait cannot be made into an object...

View File

@ -2,7 +2,6 @@
//[base] check-fail
//[extended] check-pass
#![feature(generic_associated_types)]
#![cfg_attr(extended, feature(generic_associated_types_extended))]
#![cfg_attr(extended, allow(incomplete_features))]

View File

@ -1,5 +1,3 @@
#![feature(generic_associated_types)]
trait X {
type Y<'a>;
}

View File

@ -1,5 +1,5 @@
error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/issue-67510.rs:7:21
--> $DIR/issue-67510.rs:5:21
|
LL | fn f(x: Box<dyn X<Y<'a> = &'a ()>>) {}
| ^^ undeclared lifetime
@ -15,7 +15,7 @@ LL | fn f<'a>(x: Box<dyn X<Y<'a> = &'a ()>>) {}
| ++++
error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/issue-67510.rs:7:28
--> $DIR/issue-67510.rs:5:28
|
LL | fn f(x: Box<dyn X<Y<'a> = &'a ()>>) {}
| ^^ undeclared lifetime
@ -30,13 +30,13 @@ LL | fn f<'a>(x: Box<dyn X<Y<'a> = &'a ()>>) {}
| ++++
error[E0038]: the trait `X` cannot be made into an object
--> $DIR/issue-67510.rs:7:13
--> $DIR/issue-67510.rs:5:13
|
LL | fn f(x: Box<dyn X<Y<'a> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-67510.rs:4:10
--> $DIR/issue-67510.rs:2:10
|
LL | trait X {
| - this trait cannot be made into an object...

Some files were not shown because too many files have changed in this diff Show More