Skip to content

Commit 3cf0e98

Browse files
committed
Stabilize GATs
1 parent 02654a0 commit 3cf0e98

File tree

280 files changed

+313
-808
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

280 files changed

+313
-808
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

+1-21
Original file line numberDiff line numberDiff line change
@@ -342,25 +342,6 @@ impl<'a> PostExpansionVisitor<'a> {
342342
}
343343
}
344344

345-
fn check_gat(&self, generics: &ast::Generics, span: Span) {
346-
if !generics.params.is_empty() {
347-
gate_feature_post!(
348-
&self,
349-
generic_associated_types,
350-
span,
351-
"generic associated types are unstable"
352-
);
353-
}
354-
if !generics.where_clause.predicates.is_empty() {
355-
gate_feature_post!(
356-
&self,
357-
generic_associated_types,
358-
span,
359-
"where clauses on associated types are unstable"
360-
);
361-
}
362-
}
363-
364345
/// Feature gate `impl Trait` inside `type Alias = $type_expr;`.
365346
fn check_impl_trait(&self, ty: &ast::Ty) {
366347
struct ImplTraitVisitor<'a> {
@@ -719,7 +700,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
719700
fn visit_assoc_item(&mut self, i: &'a ast::AssocItem, ctxt: AssocCtxt) {
720701
let is_fn = match i.kind {
721702
ast::AssocItemKind::Fn(_) => true,
722-
ast::AssocItemKind::TyAlias(box ast::TyAlias { ref generics, ref ty, .. }) => {
703+
ast::AssocItemKind::TyAlias(box ast::TyAlias { ref ty, .. }) => {
723704
if let (Some(_), AssocCtxt::Trait) = (ty, ctxt) {
724705
gate_feature_post!(
725706
&self,
@@ -731,7 +712,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
731712
if let Some(ty) = ty {
732713
self.check_impl_trait(ty);
733714
}
734-
self.check_gat(generics, i.span);
735715
false
736716
}
737717
_ => false,

compiler/rustc_feature/src/accepted.rs

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

compiler/rustc_feature/src/active.rs

-2
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,6 @@ declare_features! (
398398
(active, generators, "1.21.0", Some(43122), None),
399399
/// Infer generic args for both consts and types.
400400
(active, generic_arg_infer, "1.55.0", Some(85077), None),
401-
/// Allows associated types to be generic, e.g., `type Foo<T>;` (RFC 1598).
402-
(active, generic_associated_types, "1.23.0", Some(44265), None),
403401
/// An extension to the `generic_associated_types` feature, allowing incomplete features.
404402
(incomplete, generic_associated_types_extended, "1.61.0", Some(95451), None),
405403
/// Allows non-trivial generic constants which have to have wfness manually propagated to callers

compiler/rustc_lint_defs/src/builtin.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3989,8 +3989,6 @@ declare_lint! {
39893989
/// ### Example
39903990
///
39913991
/// ```rust
3992-
/// #![feature(generic_associated_types)]
3993-
///
39943992
/// trait Trait {
39953993
/// type Assoc<'a> where Self: 'a;
39963994
/// }

compiler/rustc_metadata/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![feature(decl_macro)]
33
#![feature(drain_filter)]
44
#![feature(generators)]
5-
#![feature(generic_associated_types)]
5+
#![cfg_attr(bootstrap, feature(generic_associated_types))]
66
#![feature(iter_from_generator)]
77
#![feature(let_chains)]
88
#![feature(let_else)]

compiler/rustc_middle/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#![feature(discriminant_kind)]
3232
#![feature(exhaustive_patterns)]
3333
#![feature(get_mut_unchecked)]
34-
#![feature(generic_associated_types)]
34+
#![cfg_attr(bootstrap, feature(generic_associated_types))]
3535
#![feature(if_let_guard)]
3636
#![feature(map_first_last)]
3737
#![feature(negative_impls)]

compiler/rustc_trait_selection/src/traits/project.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2064,8 +2064,6 @@ fn confirm_impl_candidate<'cx, 'tcx>(
20642064

20652065
// Get obligations corresponding to the predicates from the where-clause of the
20662066
// associated type itself.
2067-
// Note: `feature(generic_associated_types)` is required to write such
2068-
// predicates, even for non-generic associated types.
20692067
fn assoc_ty_own_obligations<'cx, 'tcx>(
20702068
selcx: &mut SelectionContext<'cx, 'tcx>,
20712069
obligation: &ProjectionTyObligation<'tcx>,

src/librustdoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#![feature(type_ascription)]
1717
#![feature(iter_intersperse)]
1818
#![feature(type_alias_impl_trait)]
19-
#![feature(generic_associated_types)]
19+
#![cfg_attr(bootstrap, feature(generic_associated_types))]
2020
#![recursion_limit = "256"]
2121
#![warn(rustc::internal)]
2222
#![allow(clippy::collapsible_if, clippy::collapsible_else_if)]

src/test/pretty/gat-bounds.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// pretty-compare-only
55

6-
#![feature(generic_associated_types)]
7-
86
trait X {
97
type Y<T>: Trait where Self: Sized;
108
}

src/test/rustdoc-json/generic-associated-types/gats.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ignore-tidy-linelength
22

33
#![no_core]
4-
#![feature(generic_associated_types, lang_items, no_core)]
4+
#![feature(lang_items, no_core)]
55

66
#[lang = "sized"]
77
pub trait Sized {}

src/test/rustdoc/generic-associated-types/gats.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![crate_name = "foo"]
2-
#![feature(generic_associated_types)]
32

43
// @has foo/trait.LendingIterator.html
54
pub trait LendingIterator {

src/test/rustdoc/generic-associated-types/issue-94683.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![crate_name = "foo"]
2-
#![feature(generic_associated_types)]
32

43
pub trait Trait {
54
type Gat<'a>;

src/test/rustdoc/where.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(generic_associated_types)]
21
#![crate_name = "foo"]
32

43
pub trait MyTrait { fn dummy(&self) { } }

src/test/ui/associated-type-bounds/binder-on-bound.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(generic_associated_types)]
2-
31
trait Trait {
42
type Bound<'a>;
53
}

src/test/ui/associated-type-bounds/binder-on-bound.stderr

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

src/test/ui/associated-type-bounds/issue-79949.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#![allow(incomplete_features)]
44
#![feature(associated_type_bounds)]
5-
#![feature(generic_associated_types)]
65

76
trait MP {
87
type T<'a>;

src/test/ui/deriving/issue-89188-gat-hrtb.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// check-pass
22

3-
#![feature(generic_associated_types)]
4-
53
trait CallWithShim: Sized {
64
type Shim<'s>
75
where

src/test/ui/feature-gates/feature-gate-generic_associated_types.rs

-31
This file was deleted.

src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr

-78
This file was deleted.

src/test/ui/feature-gates/feature-gate-generic_associated_types_extended.rs

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

src/test/ui/feature-gates/feature-gate-generic_associated_types_extended.stderr

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

src/test/ui/generic-associated-types/anonymize-bound-vars.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// check-pass
22
//
33
// regression test for #98702
4-
#![feature(generic_associated_types)]
54

65
trait Foo {
76
type Assoc<T>;

src/test/ui/generic-associated-types/auxiliary/foo_defn.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(generic_associated_types)]
2-
31
use std::{future::Future, pin::Pin};
42

53
pub trait Foo {

src/test/ui/generic-associated-types/bugs/issue-80626.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// This should pass, but it requires `Sized` to be coinductive.
55

6-
#![feature(generic_associated_types)]
7-
86
trait Allocator {
97
type Allocated<T>;
108
}

src/test/ui/generic-associated-types/bugs/issue-80626.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0275]: overflow evaluating the requirement `LinkedList<A>: Sized`
2-
--> $DIR/issue-80626.rs:14:10
2+
--> $DIR/issue-80626.rs:12:10
33
|
44
LL | Next(A::Allocated<Self>)
55
| ^^^^^^^^^^^^^^^^^^
66
|
77
note: required by a bound in `Allocator::Allocated`
8-
--> $DIR/issue-80626.rs:9:20
8+
--> $DIR/issue-80626.rs:7:20
99
|
1010
LL | type Allocated<T>;
1111
| ^ required by this bound in `Allocator::Allocated`

src/test/ui/generic-associated-types/bugs/issue-86218.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
// This should pass, but seems to run into a TAIT issue.
55

6-
#![feature(generic_associated_types)]
76
#![feature(type_alias_impl_trait)]
87

98
pub trait Stream {

src/test/ui/generic-associated-types/bugs/issue-86218.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0477]: the type `<() as Yay<&'a ()>>::InnerStream<'s>` does not fulfill the required lifetime
2-
--> $DIR/issue-86218.rs:23:28
2+
--> $DIR/issue-86218.rs:22:28
33
|
44
LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
note: type must outlive the lifetime `'s` as defined here as required by this binding
8-
--> $DIR/issue-86218.rs:23:22
8+
--> $DIR/issue-86218.rs:22:22
99
|
1010
LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
1111
| ^^
1212

1313
error: unconstrained opaque type
14-
--> $DIR/issue-86218.rs:23:28
14+
--> $DIR/issue-86218.rs:22:28
1515
|
1616
LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/generic-associated-types/bugs/issue-87735.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// This should pass, but we need an extension of implied bounds (probably).
55

6-
#![feature(generic_associated_types)]
7-
86
pub trait AsRef2 {
97
type Output<'a> where Self: 'a;
108

src/test/ui/generic-associated-types/bugs/issue-87735.stderr

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

src/test/ui/generic-associated-types/bugs/issue-87755.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
// This should pass.
55

6-
#![feature(generic_associated_types)]
7-
86
use std::fmt::Debug;
97

108
trait Foo {

src/test/ui/generic-associated-types/bugs/issue-87755.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0275]: overflow evaluating the requirement `<Bar as Foo>::Ass == _`
2-
--> $DIR/issue-87755.rs:18:16
2+
--> $DIR/issue-87755.rs:16:16
33
|
44
LL | type Ass = Bar;
55
| ^^^

0 commit comments

Comments
 (0)