mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Auto merge of #96709 - jackh726:gats-stabilization, r=compiler-errors
Stabilize generic associated types Closes #44265 r? `@nikomatsakis` # ⚡ Status of the discussion ⚡ * [x] There have been several serious concerns raised, [summarized here](https://github.com/rust-lang/rust/pull/96709#issuecomment-1129311660). * [x] There has also been a [deep-dive comment](https://github.com/rust-lang/rust/pull/96709#issuecomment-1167220240) explaining some of the "patterns of code" that are enabled by GATs, based on use-cases posted to this thread or on the tracking issue. * [x] We have modeled some aspects of GATs in [a-mir-formality](https://github.com/nikomatsakis/a-mir-formality) to give better confidence in how they will be resolved in the future. [You can read a write-up here](https://github.com/rust-lang/types-team/blob/master/minutes/2022-07-08-implied-bounds-and-wf-checking.md). * [x] The major points of the discussion have been [summarized on the GAT initiative repository](https://rust-lang.github.io/generic-associated-types-initiative/mvp.html). * [x] [FCP has been proposed](https://github.com/rust-lang/rust/pull/96709#issuecomment-1129311660) and we are awaiting final decisions and discussion amidst the relevant team members. # Stabilization proposal This PR proposes the stabilization of `#![feature(generic_associated_types)]`. While there a number of future additions to be made and bugs to be fixed (both discussed below), properly doing these will require significant language design and will ultimately likely be backwards-compatible. Given the overwhelming desire to have some form of generic associated types (GATs) available on stable and the stability of the "simple" uses, stabilizing the current subset of GAT features is almost certainly the correct next step. Tracking issue: #44265 Initiative: https://rust-lang.github.io/generic-associated-types-initiative/ RFC: https://github.com/rust-lang/rfcs/blob/master/text/1598-generic_associated_types.md Version: 1.65 (2022-08-22 => beta, 2022-11-03 => stable). ## Motivation There are a myriad of potential use cases for GATs. Stabilization unblocks probable future language features (e.g. async functions in traits), potential future standard library features (e.g. a `LendingIterator` or some form of `Iterator` with a lifetime generic), and a plethora of user use cases (some of which can be seen just by scrolling through the tracking issue and looking at all the issues linking to it). There are a myriad of potential use cases for GATs. First, there are many users that have chosen to not use GATs primarily because they are not stable (some of which can be seen just by scrolling through the tracking issue and looking at all the issues linking to it). Second, while language feature desugaring isn't *blocked* on stabilization, it gives more confidence on using the feature. Likewise, library features like `LendingIterator` are not necessarily blocked on stabilization to be implemented unstably; however few, if any, public-facing APIs actually use unstable features. This feature has a long history of design, discussion, and developement - the RFC was first introduced roughly 6 years ago. While there are still a number of features left to implement and bugs left to fix, it's clear that it's unlikely those will have backwards-incompatibility concerns. Additionally, the bugs that do exist do not strongly impede the most-common use cases. ## What is stabilized The primary language feature stabilized here is the ability to have generics on associated types, as so. Additionally, where clauses on associated types will now be accepted, regardless if the associated type is generic or not. ```rust trait ATraitWithGATs { type Assoc<'a, T> where T: 'a; } trait ATraitWithoutGATs<'a, T> { type Assoc where T: 'a; } ``` When adding an impl for a trait with generic associated types, the generics for the associated type are copied as well. Note that where clauses are allowed both after the specified type and before the equals sign; however, the latter is a warn-by-default deprecation. ```rust struct X; struct Y; impl ATraitWithGATs for X { type Assoc<'a, T> = &'a T where T: 'a; } impl ATraitWithGATs for Y { type Assoc<'a, T> where T: 'a = &'a T; } ``` To use a GAT in a function, generics are specified on the associated type, as if it was a struct or enum. GATs can also be specified in trait bounds: ```rust fn accepts_gat<'a, T>(t: &'a T) -> T::Assoc<'a, T> where for<'x> T: ATraitWithGATs<Assoc<'a, T> = &'a T> { ... } ``` GATs can also appear in trait methods. However, depending on how they are used, they may confer where clauses on the associated type definition. More information can be found [here](https://github.com/rust-lang/rust/issues/87479). Briefly, where clauses are required when those bounds can be proven in the methods that *construct* the GAT or other associated types that use the GAT in the trait. This allows impls to have maximum flexibility in the types defined for the associated type. To take a relatively simple example: ```rust trait Iterable { type Item<'a>; type Iterator<'a>: Iterator<Item = Self::Item<'a>>; fn iter<'x>(&'x self) -> Self::Iterator<'x>; //^ We know that `Self: 'a` for `Iterator<'a>`, so we require that bound on `Iterator` // `Iterator` uses `Self::Item`, so we also require a `Self: 'a` on `Item` too } ``` A couple well-explained examples are available in a previous [blog post](https://blog.rust-lang.org/2021/08/03/GATs-stabilization-push.html). ## What isn't stabilized/implemented ### Universal type/const quantification Currently, you can write a bound like `X: for<'a> Trait<Assoc<'a> = &'a ()>`. However, you cannot currently write `for<T> X: Trait<Assoc<T> = T>` or `for<const N> X: Trait<Assoc<N> = [usize; N]>`. Here is an example where this is needed: ```rust trait Foo {} trait Trait { type Assoc<F: Foo>; } trait Trait2: Sized { fn foo<F: Foo, T: Trait<Assoc<F> = F>>(_t: T); } ``` In the above example, the *caller* must specify `F`, which is likely not what is desired. ### Object-safe GATs Unlike non-generic associated types, traits with GATs are not currently object-safe. In other words the following are not allowed: ```rust trait Trait { type Assoc<'a>; } fn foo(t: &dyn for<'a> Trait<Assoc<'a> = &'a ()>) {} //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not allowed let ty: Box<dyn for<'a> Trait<Assoc<'a> = &'a ()>>; //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not allowed ``` ### Higher-kinded types You cannot write currently (and there are no current plans to implement this): ```rust struct Struct<'a> {} fn foo(s: for<'a> Struct<'a>) {} ``` ## Tests There are many tests covering GATs that can be found in `src/test/ui/generic-associated-types`. Here, I'll list (in alphanumeric order) tests highlight some important behavior or contain important patterns. - `./parse/*`: Parsing of GATs in traits and impls, and the trait path with GATs - `./collections-project-default.rs`: Interaction with associated type defaults - `./collections.rs`: The `Collection` pattern - `./const-generics-gat-in-trait-return-type-*.rs`: Const parameters - `./constraint-assoc-type-suggestion.rs`: Emit correct syntax in suggestion - `./cross-crate-bounds.rs`: Ensure we handles bounds across crates the same - `./elided-in-expr-position.rs`: Disallow lifetime elision in return position - `./gat-in-trait-path-undeclared-lifetime.rs`: Ensure we error on undeclared lifetime in trait path - `./gat-in-trait-path.rs`: Base trait path case - `./gat-trait-path-generic-type-arg.rs`: Don't allow shadowing of parameters - `./gat-trait-path-parenthesised-args.rs`: Don't allow paranthesized args in trait path - `./generic-associated-types-where.rs`: Ensure that we require where clauses from trait to be met on impl - `./impl_bounds.rs`: Check that the bounds on GATs in an impl are checked - `./issue-76826.rs`: `Windows` pattern - `./issue-78113-lifetime-mismatch-dyn-trait-box.rs`: Implicit 'static diagnostics - `./issue-84931.rs`: Ensure that we have a where clause on GAT to ensure trait parameter lives long enough - `./issue-87258_a.rs`: Unconstrained opaque type with TAITs - `./issue-87429-2.rs`: Ensure we can use bound vars in the bounds - `./issue-87429-associated-type-default.rs`: Ensure bounds hold with associated type defaults, for both trait and impl - `./issue-87429-specialization.rs`: Check that bounds hold under specialization - `./issue-88595.rs`: Under the outlives lint, we require a bound for both trait and GAT lifetime when trait lifetime is used in function - `./issue-90014.rs`: Lifetime bounds are checked with TAITs - `./issue-91139.rs`: Under migrate mode, but not NLL, we don't capture implied bounds from HRTB lifetimes used in a function and GATs - `./issue-91762.rs`: We used to too eagerly pick param env candidates when normalizing with GATs. We now require explicit parameters specified. - `./issue-95305.rs`: Disallow lifetime elision in trait paths - `./iterable.rs`: `Iterable` pattern - `./method-unsatified-assoc-type-predicate.rs`: Print predicates with GATs correctly in method resolve error - `./missing_lifetime_const.rs`: Ensure we must specify lifetime args (not elidable) - `./missing-where-clause-on-trait.rs`: Ensure we don't allow stricter bounds on impl than trait - `./parameter_number_and_kind_impl.rs`: Ensure paramters on GAT in impl match GAT in trait - `./pointer_family.rs`: `PointerFamily` pattern - `./projection-bound-cycle.rs`: Don't allow invalid cycles to prove bounds - `./self-outlives-lint.rs`: Ensures that an e.g. `Self: 'a` is written on the traits GAT if that bound can be implied from the GAT usage in the trait - `./shadowing.rs`: Don't allow lifetime shadowing in params - `./streaming_iterator.rs`: `StreamingIterator`(`LendingIterator`) pattern - `./trait-objects.rs`: Disallow trait objects for traits with GATs - `./variance_constraints.rs`: Require that GAT substs be invariant ## Remaining bugs and open issues A full list of remaining open issues can be found at: https://github.com/rust-lang/rust/labels/F-generic_associated_types There are some `known-bug` tests in-tree at `src/test/ui/generic-associated-types/bugs`. Here I'll categorize most of those that GAT bugs (or involve a pattern found more with GATs), but not those that include GATs but not a GAT issue in and of itself. (I also won't include issues directly for things listed elsewhere here.) Using the concrete type of a GAT instead of the projection type can give errors, since lifetimes are chosen to be early-bound vs late-bound. - #85533 - #87803 In certain cases, we can run into cycle or overflow errors. This is more generally a problem with associated types. - #87755 - #87758 Bounds on an associatd type need to be proven by an impl, but where clauses need to be proven by the usage. This can lead to confusion when users write one when they mean the other. - #87831 - #90573 We sometimes can't normalize closure signatures fully. Really an asociated types issue, but might happen a bit more frequently with GATs, since more obvious place for HRTB lifetimes. - #88382 When calling a function, we assign types to parameters "too late", after we already try (and fail) to normalize projections. Another associated types issue that might pop up more with GATs. - #88460 - #96230 We don't fully have implied bounds for lifetimes appearing in GAT trait paths, which can lead to unconstrained type errors. - #88526 Suggestion for adding lifetime bounds can suggest unhelpful fixes (`T: 'a` instead of `Self: 'a`), but the next compiler error after making the suggested change is helpful. - #90816 - #92096 - #95268 We can end up requiring that `for<'a> I: 'a` when we really want `for<'a where I: 'a> I: 'a`. This can leave unhelpful errors than effectively can't be satisfied unless `I: 'static`. Requires bigger changes and not only GATs. - #91693 Unlike with non-generic associated types, we don't eagerly normalize with param env candidates. This is intended behavior (for now), to avoid accidentaly stabilizing picking arbitrary impls. - #91762 Some Iterator adapter patterns (namely `filter`) require Polonius or unsafe to work. - #92985 ## Potential Future work ### Universal type/const quantification No work has been done to implement this. There are also some questions around implied bounds. ### Object-safe GATs The intention is to make traits with GATs object-safe. There are some design work to be done around well-formedness rules and general implementation. ### GATified std lib types It would be helpful to either introduce new std lib traits (like `LendingIterator`) or to modify existing ones (adding a `'a` generic to `Iterator::Item`). There also a number of other candidates, like `Index`/`IndexMut` and `Fn`/`FnMut`/`FnOnce`. ### Reduce the need for `for<'a>` Seen [here](https://github.com/rust-lang/rfcs/pull/1598#issuecomment-2611378730). One possible syntax: ```rust trait Iterable { type Iter<'a>: Iterator<Item = Self::Item<'a>>; } fn foo<T>() where T: Iterable, T::Item<let 'a>: Display { } //note the `let`! ``` ### Better implied bounds on higher-ranked things Currently if we have a `type Item<'a> where self: 'a`, and a `for<'a> T: Iterator<Item<'a> = &'a ()`, this requires `for<'a> Self: 'a`. Really, we want `for<'a where T: 'a> ...` There was some mentions of this all the back in the RFC thread [here](https://github.com/rust-lang/rfcs/pull/1598#issuecomment-264340514). ## Alternatives ### Make generics on associated type in bounds a binder Imagine the bound `for<'a> T: Trait<Item<'a>= &'a ()>`. It might be that `for<'a>` is "too large" and it should instead be `T: Trait<for<'a> Item<'a>= &'a ()>`. Brought up in RFC thread [here](https://github.com/rust-lang/rfcs/pull/1598#issuecomment-229443863) and in a few places since. Another related question: Is `for<'a>` the right syntax? Maybe `where<'a>`? Also originally found in RFC thread [here](https://github.com/rust-lang/rfcs/pull/1598#issuecomment-261639969). ### Stabilize lifetime GATs first This has been brought up a few times. The idea is to only allow GATs with lifetime parameters to in initial stabilization. This was probably most useful prior to actual implementation. At this point, lifetimes, types, and consts are all implemented and work. It feels like an arbitrary split without strong reason. ## History * On 2016-04-30, [RFC opened](https://github.com/rust-lang/rfcs/pull/1598) * On 2017-09-02, RFC merged and [tracking issue opened](https://github.com/rust-lang/rust/issues/44265) * On 2017-10-23, [Move Generics from MethodSig to TraitItem and ImplItem](https://github.com/rust-lang/rust/pull/44766) * On 2017-12-01, [Generic Associated Types Parsing & Name Resolution](https://github.com/rust-lang/rust/pull/45904) * On 2017-12-15, [https://github.com/rust-lang/rust/pull/46706](https://github.com/rust-lang/rust/pull/46706) * On 2018-04-23, [Feature gate where clauses on associated types](https://github.com/rust-lang/rust/pull/49368) * On 2018-05-10, [Extend tests for RFC1598 (GAT)](https://github.com/rust-lang/rust/pull/49423) * On 2018-05-24, [Finish implementing GATs (Chalk)](https://github.com/rust-lang/chalk/pull/134) * On 2019-12-21, [Make GATs less ICE-prone](https://github.com/rust-lang/rust/pull/67160) * On 2020-02-13, [fix lifetime shadowing check in GATs](https://github.com/rust-lang/rust/pull/68938) * On 2020-06-20, [Projection bound validation](https://github.com/rust-lang/rust/pull/72788) * On 2020-10-06, [Separate projection bounds and predicates](https://github.com/rust-lang/rust/pull/73905) * On 2021-02-05, [Generic associated types in trait paths](https://github.com/rust-lang/rust/pull/79554) * On 2021-02-06, [Trait objects do not work with generic associated types](https://github.com/rust-lang/rust/issues/81823) * On 2021-04-28, [Make traits with GATs not object safe](https://github.com/rust-lang/rust/pull/84622) * On 2021-05-11, [Improve diagnostics for GATs](https://github.com/rust-lang/rust/pull/82272) * On 2021-07-16, [Make GATs no longer an incomplete feature](https://github.com/rust-lang/rust/pull/84623) * On 2021-07-16, [Replace associated item bound vars with placeholders when projecting](https://github.com/rust-lang/rust/pull/86993) * On 2021-07-26, [GATs: Decide whether to have defaults for `where Self: 'a`](https://github.com/rust-lang/rust/issues/87479) * On 2021-08-25, [Normalize projections under binders](https://github.com/rust-lang/rust/pull/85499) * On 2021-08-03, [The push for GATs stabilization](https://blog.rust-lang.org/2021/08/03/GATs-stabilization-push.html) * On 2021-08-12, [Detect stricter constraints on gats where clauses in impls vs trait](https://github.com/rust-lang/rust/pull/88336) * On 2021-09-20, [Proposal: Change syntax of where clauses on type aliases](https://github.com/rust-lang/rust/issues/89122) * On 2021-11-06, [Implementation of GATs outlives lint](https://github.com/rust-lang/rust/pull/89970) * On 2021-12-29. [Parse and suggest moving where clauses after equals for type aliases](https://github.com/rust-lang/rust/pull/92118) * On 2022-01-15, [Ignore static lifetimes for GATs outlives lint](https://github.com/rust-lang/rust/pull/92865) * On 2022-02-08, [Don't constrain projection predicates with inference vars in GAT substs](https://github.com/rust-lang/rust/pull/92917) * On 2022-02-15, [Rework GAT where clause check](https://github.com/rust-lang/rust/pull/93820) * On 2022-02-19, [Only mark projection as ambiguous if GAT substs are constrained](https://github.com/rust-lang/rust/pull/93892) * On 2022-03-03, [Support GATs in Rustdoc](https://github.com/rust-lang/rust/pull/94009) * On 2022-03-06, [Change location of where clause on GATs](https://github.com/rust-lang/rust/pull/90076) * On 2022-05-04, [A shiny future with GATs blog post](https://jackh726.github.io/rust/2022/05/04/a-shiny-future-with-gats.html) * On 2022-05-04, [Stabilization PR](https://github.com/rust-lang/rust/pull/96709)
This commit is contained in:
commit
7098c181f8
@ -340,25 +340,6 @@ impl<'a> PostExpansionVisitor<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
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> {
|
||||
@ -717,7 +698,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||
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,
|
||||
@ -729,7 +710,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||
if let Some(ty) = ty {
|
||||
self.check_impl_trait(ty);
|
||||
}
|
||||
self.check_gat(generics, i.span);
|
||||
false
|
||||
}
|
||||
_ => false,
|
||||
|
@ -161,6 +161,8 @@ 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.
|
||||
|
@ -404,8 +404,6 @@ declare_features! (
|
||||
(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
|
||||
|
@ -3988,8 +3988,6 @@ declare_lint! {
|
||||
/// ### Example
|
||||
///
|
||||
/// ```rust
|
||||
/// #![feature(generic_associated_types)]
|
||||
///
|
||||
/// trait Trait {
|
||||
/// type Assoc<'a> where Self: 'a;
|
||||
/// }
|
||||
|
@ -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)]
|
||||
|
@ -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)]
|
||||
|
@ -2227,8 +2227,6 @@ fn confirm_impl_trait_in_trait_candidate<'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>,
|
||||
|
@ -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)]
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
// pretty-compare-only
|
||||
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
trait X {
|
||||
type Y<T>: Trait where Self: Sized;
|
||||
}
|
||||
|
@ -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 {}
|
||||
|
@ -1,5 +1,4 @@
|
||||
#![crate_name = "foo"]
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
// @has foo/trait.LendingIterator.html
|
||||
pub trait LendingIterator {
|
||||
|
@ -1,5 +1,4 @@
|
||||
#![crate_name = "foo"]
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
pub trait Trait {
|
||||
type Gat<'a>;
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
#![crate_name = "foo"]
|
||||
|
||||
pub trait MyTrait { fn dummy(&self) { } }
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
trait Trait {
|
||||
type Bound<'a>;
|
||||
}
|
||||
|
@ -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 ()> {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#![allow(incomplete_features)]
|
||||
#![feature(associated_type_bounds)]
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
trait MP {
|
||||
type T<'a>;
|
||||
|
@ -1,7 +1,5 @@
|
||||
// check-pass
|
||||
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
trait CallWithShim: Sized {
|
||||
type Shim<'s>
|
||||
where
|
||||
|
@ -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() {}
|
@ -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`.
|
@ -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
|
||||
|
@ -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]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
@ -1,7 +1,6 @@
|
||||
// check-pass
|
||||
//
|
||||
// regression test for #98702
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
trait Foo {
|
||||
type Assoc<T>;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
use std::{future::Future, pin::Pin};
|
||||
|
||||
pub trait Foo {
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
// This should pass, but it requires `Sized` to be coinductive.
|
||||
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
trait Allocator {
|
||||
type Allocated<T>;
|
||||
}
|
||||
|
@ -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`
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
// This should pass.
|
||||
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
trait Foo {
|
||||
|
@ -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;
|
||||
| ^^^
|
||||
|
@ -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>;
|
||||
|
@ -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
|
||||
|
@ -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<'_>;
|
||||
|
@ -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`
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
// This should pass, but requires more logic.
|
||||
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
trait A {
|
||||
type I<'a>;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 = ();
|
||||
| ^^
|
||||
|
@ -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>;
|
||||
|
@ -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`
|
@ -1,4 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
#![feature(associated_type_defaults)]
|
||||
|
||||
// A Collection trait and collection families. Based on
|
||||
|
@ -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
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
#![feature(associated_type_defaults)]
|
||||
|
||||
// A Collection trait and collection families. Based on
|
||||
|
@ -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
|
||||
|
@ -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 | |
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
trait Trait {
|
||||
type Foo<const N: u8>;
|
||||
}
|
||||
|
@ -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 {
|
||||
| -----
|
||||
|
@ -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>;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
// check-pass
|
||||
|
||||
use std::ops::Deref;
|
||||
|
@ -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`
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
#![allow(unused)]
|
||||
|
||||
pub trait Trait {
|
||||
|
@ -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;
|
||||
| ^^^^^ --
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
trait Foo {
|
||||
type Bar<,>;
|
||||
//~^ ERROR expected one of `#`, `>`, `const`, identifier, or lifetime, found `,`
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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))]
|
||||
|
||||
|
@ -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
|
||||
|
@ -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))]
|
||||
|
||||
|
@ -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() { }
|
@ -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`.
|
@ -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() { }
|
@ -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`.
|
@ -1,5 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
trait X {
|
||||
type Y<'x>;
|
||||
}
|
||||
|
@ -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]>>) {}
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
@ -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...
|
||||
|
@ -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))]
|
||||
|
@ -1,5 +0,0 @@
|
||||
// run-pass
|
||||
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
fn main() {}
|
@ -1,5 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
trait Foo {
|
||||
type F<'a>;
|
||||
|
||||
|
@ -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
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
trait X {
|
||||
type Y<'a>;
|
||||
|
||||
|
@ -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>;
|
||||
| ^ --
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
trait X {
|
||||
type Y<'a>;
|
||||
}
|
||||
|
@ -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>;
|
||||
| ^ --
|
||||
|
@ -1,7 +1,5 @@
|
||||
// run-pass
|
||||
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
pub trait X {
|
||||
type Y<'a> where Self: 'a;
|
||||
fn m(&self) -> Self::Y<'_>;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
// Checking the interaction with this other feature
|
||||
#![feature(associated_type_defaults)]
|
||||
|
||||
|
@ -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
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
trait Iterable {
|
||||
|
@ -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
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
#![feature(associated_type_defaults)]
|
||||
|
||||
trait Foo {
|
||||
|
@ -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
|
||||
|
@ -1,6 +1,5 @@
|
||||
// check-pass
|
||||
|
||||
#![feature(generic_associated_types)]
|
||||
#![feature(associated_type_defaults)]
|
||||
|
||||
trait Foo {
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
pub trait LendingIterator {
|
||||
type Item<'a>
|
||||
where
|
||||
|
@ -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
|
||||
|
@ -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>;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -1,7 +1,5 @@
|
||||
// check-pass
|
||||
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
trait Cert {
|
||||
type PublicKey<'a>: From<&'a [u8]>;
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
// check-pass
|
||||
|
||||
trait Iterator {
|
||||
|
@ -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() {}
|
||||
|
@ -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`.
|
@ -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...
|
||||
|
@ -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))]
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
trait X {
|
||||
type Y<'a>;
|
||||
}
|
||||
|
@ -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
Loading…
Reference in New Issue
Block a user