Skip to content

Commit

Permalink
Auto merge of rust-lang#84623 - jackh726:gats-incomplete, r=nikomatsakis
Browse files Browse the repository at this point in the history
Make GATs no longer an incomplete feature

Blocked on ~rust-lang#84622~, ~rust-lang#82272~, ~rust-lang#76826~

r? `@nikomatsakis`
  • Loading branch information
bors committed Jul 16, 2021
2 parents 2119976 + f1ab6f9 commit c49895d
Show file tree
Hide file tree
Showing 138 changed files with 197 additions and 587 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ declare_features! (
(active, in_band_lifetimes, "1.23.0", Some(44524), None),

/// Allows associated types to be generic, e.g., `type Foo<T>;` (RFC 1598).
(incomplete, generic_associated_types, "1.23.0", Some(44265), None),
(active, generic_associated_types, "1.23.0", Some(44265), None),

/// Allows defining `trait X = A + B;` alias items.
(active, trait_alias, "1.24.0", Some(41517), None),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2315,7 +2315,7 @@ declare_lint! {
/// ### Example
///
/// ```rust
/// #![feature(generic_associated_types)]
/// #![feature(const_generics)]
/// ```
///
/// {{produces}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(incomplete_features)]
#![feature(generic_associated_types)]
#![feature(associated_type_defaults)]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/collections-project-default.rs:60:5
--> $DIR/collections-project-default.rs:59: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
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/generic-associated-types/collections.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(incomplete_features)]
#![feature(generic_associated_types)]
#![feature(associated_type_defaults)]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
#![feature(generic_associated_types)]
#![allow(incomplete_features)]

// This test unsures that with_opt_const_param returns the
// def_id of the N param in the Foo::Assoc GAT.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
#![feature(generic_associated_types)]
#![allow(incomplete_features)]

// This test unsures that with_opt_const_param returns the
// def_id of the N param in the Foo::Assoc GAT.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
#![feature(generic_associated_types)]
#![allow(incomplete_features)]

// This test unsures that with_opt_const_param returns the
// def_id of the N param in the Bar::Assoc GAT.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Test that correct syntax is used in suggestion to constrain associated type

#![feature(generic_associated_types)]
//~^ WARNING the feature `generic_associated_types` is incomplete

trait X {
type Y<T>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/constraint-assoc-type-suggestion.rs:3:12
|
LL | #![feature(generic_associated_types)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information

error[E0308]: mismatched types
--> $DIR/constraint-assoc-type-suggestion.rs:13:23
--> $DIR/constraint-assoc-type-suggestion.rs:12:23
|
LL | let b: Vec<i32> = a;
| -------- ^ expected struct `Vec`, found associated type
Expand All @@ -22,6 +13,6 @@ help: consider constraining the associated type `<T as X>::Y<i32>` to `Vec<i32>`
LL | fn f<T: X<Y<i32> = Vec<i32>>>(a: T::Y<i32>) {
| ^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error; 1 warning emitted
error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(incomplete_features)]
#![feature(generic_associated_types)]

// check-pass
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/generic-associated-types/empty_generics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(incomplete_features)]
#![feature(generic_associated_types)]

trait Foo {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/generic-associated-types/empty_generics.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `,`
--> $DIR/empty_generics.rs:5:14
--> $DIR/empty_generics.rs:4:14
|
LL | trait Foo {
| - while parsing this item list starting here
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(generic_associated_types)]
//~^ WARNING: the feature `generic_associated_types` is incomplete

trait X {
type Y<'x>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:1:12
|
LL | #![feature(generic_associated_types)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information

error[E0261]: use of undeclared lifetime name `'x`
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:9:35
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:8:35
|
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
| - ^^ undeclared lifetime
Expand All @@ -18,12 +9,12 @@ LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

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:9:33
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:8:33
|
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
| ^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors; 1 warning emitted
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0261, E0582.
For more information about an error, try `rustc --explain E0261`.
1 change: 0 additions & 1 deletion src/test/ui/generic-associated-types/gat-in-trait-path.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(generic_associated_types)]
//~^ WARNING: the feature `generic_associated_types` is incomplete
#![feature(associated_type_defaults)]

trait Foo {
Expand Down
15 changes: 3 additions & 12 deletions src/test/ui/generic-associated-types/gat-in-trait-path.stderr
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/gat-in-trait-path.rs:1:12
|
LL | #![feature(generic_associated_types)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information

error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/gat-in-trait-path.rs:22:13
--> $DIR/gat-in-trait-path.rs:21:13
|
LL | fn f(_arg : Box<dyn for<'a> Foo<A<'a> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
= help: consider moving `A` to another trait
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:6:10
--> $DIR/gat-in-trait-path.rs:5:10
|
LL | trait Foo {
| --- this trait cannot be made into an object...
LL | type A<'a> where Self: 'a;
| ^ ...because it contains the generic associated type `A`

error: aborting due to previous error; 1 warning emitted
error: aborting due to previous error

For more information about this error, try `rustc --explain E0038`.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass

#![feature(generic_associated_types)]
//~^ WARNING the feature `generic_associated_types` is incomplete

fn main() {}
11 changes: 0 additions & 11 deletions src/test/ui/generic-associated-types/gat-incomplete-warning.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(generic_associated_types)]
//~^ WARNING: the feature `generic_associated_types` is incomplete

trait Foo {
type F<'a>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
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:10:12
|
LL | impl <T, T1> Foo for T {
| -- first use of `T1`
LL | type F<T1> = &[u8];
| ^^ already used

warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/gat-trait-path-generic-type-arg.rs:1:12
|
LL | #![feature(generic_associated_types)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information

error[E0106]: missing lifetime specifier
--> $DIR/gat-trait-path-generic-type-arg.rs:11:18
--> $DIR/gat-trait-path-generic-type-arg.rs:10:18
|
LL | type F<T1> = &[u8];
| ^ expected named lifetime parameter
Expand All @@ -26,7 +17,7 @@ help: consider introducing a named lifetime parameter
LL | type F<'a, T1> = &'a [u8];
| ^^^ ^^^

error: aborting due to 2 previous errors; 1 warning emitted
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0106, E0403.
For more information about an error, try `rustc --explain E0106`.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(generic_associated_types)]
//~^ WARNING: the feature `generic_associated_types` is incomplete

trait X {
type Y<'a>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/gat-trait-path-missing-lifetime.rs:1:12
|
LL | #![feature(generic_associated_types)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information

error[E0107]: missing generics for associated type `X::Y`
--> $DIR/gat-trait-path-missing-lifetime.rs:11:20
--> $DIR/gat-trait-path-missing-lifetime.rs:10: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:5:8
--> $DIR/gat-trait-path-missing-lifetime.rs:4:8
|
LL | type Y<'a>;
| ^ --
Expand All @@ -24,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:11:20
--> $DIR/gat-trait-path-missing-lifetime.rs:10: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:5:8
--> $DIR/gat-trait-path-missing-lifetime.rs:4:8
|
LL | type Y<'a>;
| ^ --
Expand All @@ -39,6 +30,6 @@ help: add missing lifetime argument
LL | fn foo<'a, T1: X<Y<'a> = T1>>(t : T1) -> T1::Y<'a> {
| ^^^^^

error: aborting due to 2 previous errors; 1 warning emitted
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0107`.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(generic_associated_types)]
//~^ WARNING: the feature `generic_associated_types` is incomplete

trait X {
type Y<'a>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
error: lifetime in trait object type must be followed by `+`
--> $DIR/gat-trait-path-parenthesised-args.rs:8:29
--> $DIR/gat-trait-path-parenthesised-args.rs:7: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:8:27
--> $DIR/gat-trait-path-parenthesised-args.rs:7:27
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^^^^^

warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/gat-trait-path-parenthesised-args.rs:1:12
|
LL | #![feature(generic_associated_types)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information

warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/gat-trait-path-parenthesised-args.rs:8:29
--> $DIR/gat-trait-path-parenthesised-args.rs:7:29
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^^ help: use `dyn`: `dyn 'a`
Expand All @@ -30,13 +21,13 @@ LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>

error[E0107]: this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
--> $DIR/gat-trait-path-parenthesised-args.rs:8:27
--> $DIR/gat-trait-path-parenthesised-args.rs:7: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:5:8
--> $DIR/gat-trait-path-parenthesised-args.rs:4:8
|
LL | type Y<'a>;
| ^ --
Expand All @@ -46,19 +37,19 @@ 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:8:27
--> $DIR/gat-trait-path-parenthesised-args.rs:7:27
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^---- help: remove these generics
| |
| expected 0 generic arguments
|
note: associated type defined here, with 0 generic parameters
--> $DIR/gat-trait-path-parenthesised-args.rs:5:8
--> $DIR/gat-trait-path-parenthesised-args.rs:4:8
|
LL | type Y<'a>;
| ^

error: aborting due to 4 previous errors; 2 warnings emitted
error: aborting due to 4 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0107`.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass

#![allow(incomplete_features)]
#![feature(generic_associated_types)]

pub trait X {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(incomplete_features)]
#![feature(generic_associated_types)]

// Checking the interaction with this other feature
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0277]: `T` doesn't implement `std::fmt::Display`
--> $DIR/generic-associated-types-where.rs:21:5
--> $DIR/generic-associated-types-where.rs:20:5
|
LL | type Assoc2<T> = Vec<T>;
| ^^^^^^^^^^^^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter
Expand All @@ -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:23:5
--> $DIR/generic-associated-types-where.rs:22:5
|
LL | type Assoc3<T>;
| --------------- definition of `Assoc3` from trait
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(incomplete_features)]
#![feature(generic_associated_types)]

use std::ops::Deref;
Expand Down
Loading

0 comments on commit c49895d

Please sign in to comment.