Skip to content

Commit 7205474

Browse files
committed
Make GATs no longer incomplete
1 parent 857cb4d commit 7205474

File tree

128 files changed

+181
-548
lines changed

Some content is hidden

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

128 files changed

+181
-548
lines changed

compiler/rustc_feature/src/active.rs

-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,6 @@ declare_features! (
666666
pub const INCOMPLETE_FEATURES: &[Symbol] = &[
667667
sym::if_let_guard,
668668
sym::impl_trait_in_bindings,
669-
sym::generic_associated_types,
670669
sym::const_generics,
671670
sym::let_chains,
672671
sym::raw_dylib,

compiler/rustc_lint/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2268,7 +2268,7 @@ declare_lint! {
22682268
/// ### Example
22692269
///
22702270
/// ```rust
2271-
/// #![feature(generic_associated_types)]
2271+
/// #![feature(const_generics)]
22722272
/// ```
22732273
///
22742274
/// {{produces}}

src/test/ui/generic-associated-types/collections-project-default.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(incomplete_features)]
21
#![feature(generic_associated_types)]
32
#![feature(associated_type_defaults)]
43

src/test/ui/generic-associated-types/collections-project-default.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/collections-project-default.rs:60:5
2+
--> $DIR/collections-project-default.rs:59:5
33
|
44
LL | fn floatify_sibling<C>(ints: &C) -> <C as Collection<i32>>::Sibling<f32>
55
| ------------------------------------ expected `<C as Collection<i32>>::Sibling<f32>` because of return type

src/test/ui/generic-associated-types/collections.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(incomplete_features)]
21
#![feature(generic_associated_types)]
32
#![feature(associated_type_defaults)]
43

src/test/ui/generic-associated-types/const-generics-gat-in-trait-return-type-1.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22
#![feature(generic_associated_types)]
3-
#![allow(incomplete_features)]
43

54
// This test unsures that with_opt_const_param returns the
65
// def_id of the N param in the Foo::Assoc GAT.

src/test/ui/generic-associated-types/const-generics-gat-in-trait-return-type-2.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22
#![feature(generic_associated_types)]
3-
#![allow(incomplete_features)]
43

54
// This test unsures that with_opt_const_param returns the
65
// def_id of the N param in the Foo::Assoc GAT.

src/test/ui/generic-associated-types/const-generics-gat-in-trait-return-type-3.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22
#![feature(generic_associated_types)]
3-
#![allow(incomplete_features)]
43

54
// This test unsures that with_opt_const_param returns the
65
// def_id of the N param in the Bar::Assoc GAT.

src/test/ui/generic-associated-types/constraint-assoc-type-suggestion.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Test that correct syntax is used in suggestion to constrain associated type
22

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

65
trait X {
76
type Y<T>;
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/constraint-assoc-type-suggestion.rs:3:12
3-
|
4-
LL | #![feature(generic_associated_types)]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^
6-
|
7-
= note: `#[warn(incomplete_features)]` on by default
8-
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
9-
101
error[E0308]: mismatched types
11-
--> $DIR/constraint-assoc-type-suggestion.rs:13:23
2+
--> $DIR/constraint-assoc-type-suggestion.rs:12:23
123
|
134
LL | let b: Vec<i32> = a;
145
| -------- ^ expected struct `Vec`, found associated type
@@ -22,6 +13,6 @@ help: consider constraining the associated type `<T as X>::Y<i32>` to `Vec<i32>`
2213
LL | fn f<T: X<Y<i32> = Vec<i32>>>(a: T::Y<i32>) {
2314
| ^^^^^^^^^^^^^^^^^^^
2415

25-
error: aborting due to previous error; 1 warning emitted
16+
error: aborting due to previous error
2617

2718
For more information about this error, try `rustc --explain E0308`.

src/test/ui/generic-associated-types/construct_with_other_type.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(incomplete_features)]
21
#![feature(generic_associated_types)]
32

43
// check-pass

src/test/ui/generic-associated-types/empty_generics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(incomplete_features)]
21
#![feature(generic_associated_types)]
32

43
trait Foo {

src/test/ui/generic-associated-types/empty_generics.stderr

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

src/test/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.rs

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

43
trait X {
54
type Y<'x>;
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:1:12
3-
|
4-
LL | #![feature(generic_associated_types)]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^
6-
|
7-
= note: `#[warn(incomplete_features)]` on by default
8-
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
9-
101
error[E0261]: use of undeclared lifetime name `'x`
11-
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:9:35
2+
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:8:35
123
|
134
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
145
| - ^^ undeclared lifetime
@@ -18,12 +9,12 @@ LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
189
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
1910

2011
error[E0582]: binding for associated type `Y` references lifetime `'a`, which does not appear in the trait input types
21-
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:9:33
12+
--> $DIR/gat-in-trait-path-undeclared-lifetime.rs:8:33
2213
|
2314
LL | fn _f(arg : Box<dyn for<'a> X<Y<'x> = &'a [u32]>>) {}
2415
| ^^^^^^^^^^^^^^^^^
2516

26-
error: aborting due to 2 previous errors; 1 warning emitted
17+
error: aborting due to 2 previous errors
2718

2819
Some errors have detailed explanations: E0261, E0582.
2920
For more information about an error, try `rustc --explain E0261`.

src/test/ui/generic-associated-types/gat-in-trait-path.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(generic_associated_types)]
2-
//~^ WARNING: the feature `generic_associated_types` is incomplete
32
#![feature(associated_type_defaults)]
43

54
trait Foo {
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
1-
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/gat-in-trait-path.rs:1:12
3-
|
4-
LL | #![feature(generic_associated_types)]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^
6-
|
7-
= note: `#[warn(incomplete_features)]` on by default
8-
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
9-
101
error[E0038]: the trait `Foo` cannot be made into an object
11-
--> $DIR/gat-in-trait-path.rs:22:13
2+
--> $DIR/gat-in-trait-path.rs:21:13
123
|
134
LL | fn f(_arg : Box<dyn for<'a> Foo<A<'a> = &'a ()>>) {}
145
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
156
|
167
= help: consider moving `A` to another trait
178
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>
18-
--> $DIR/gat-in-trait-path.rs:6:10
9+
--> $DIR/gat-in-trait-path.rs:5:10
1910
|
2011
LL | trait Foo {
2112
| --- this trait cannot be made into an object...
2213
LL | type A<'a> where Self: 'a;
2314
| ^ ...because it contains the generic associated type `A`
2415

25-
error: aborting due to previous error; 1 warning emitted
16+
error: aborting due to previous error
2617

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

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

65
fn main() {}

src/test/ui/generic-associated-types/gat-incomplete-warning.stderr

-11
This file was deleted.

src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs

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

43
trait Foo {
54
type F<'a>;
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
error[E0403]: the name `T1` is already used for a generic parameter in this item's generic parameters
2-
--> $DIR/gat-trait-path-generic-type-arg.rs:11:12
2+
--> $DIR/gat-trait-path-generic-type-arg.rs:10:12
33
|
44
LL | impl <T, T1> Foo for T {
55
| -- first use of `T1`
66
LL | type F<T1> = &[u8];
77
| ^^ already used
88

9-
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
10-
--> $DIR/gat-trait-path-generic-type-arg.rs:1:12
11-
|
12-
LL | #![feature(generic_associated_types)]
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^
14-
|
15-
= note: `#[warn(incomplete_features)]` on by default
16-
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
17-
189
error[E0106]: missing lifetime specifier
19-
--> $DIR/gat-trait-path-generic-type-arg.rs:11:18
10+
--> $DIR/gat-trait-path-generic-type-arg.rs:10:18
2011
|
2112
LL | type F<T1> = &[u8];
2213
| ^ expected named lifetime parameter
@@ -26,7 +17,7 @@ help: consider introducing a named lifetime parameter
2617
LL | type F<'a, T1> = &'a [u8];
2718
| ^^^ ^^^
2819

29-
error: aborting due to 2 previous errors; 1 warning emitted
20+
error: aborting due to 2 previous errors
3021

3122
Some errors have detailed explanations: E0106, E0403.
3223
For more information about an error, try `rustc --explain E0106`.

src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.rs

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

43
trait X {
54
type Y<'a>;
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/gat-trait-path-missing-lifetime.rs:1:12
3-
|
4-
LL | #![feature(generic_associated_types)]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^
6-
|
7-
= note: `#[warn(incomplete_features)]` on by default
8-
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
9-
101
error[E0107]: missing generics for associated type `X::Y`
11-
--> $DIR/gat-trait-path-missing-lifetime.rs:5:8
2+
--> $DIR/gat-trait-path-missing-lifetime.rs:4:8
123
|
134
LL | type Y<'a>;
145
| ^ expected 1 lifetime argument
156
|
167
note: associated type defined here, with 1 lifetime parameter: `'a`
17-
--> $DIR/gat-trait-path-missing-lifetime.rs:5:8
8+
--> $DIR/gat-trait-path-missing-lifetime.rs:4:8
189
|
1910
LL | type Y<'a>;
2011
| ^ --
@@ -24,13 +15,13 @@ LL | type Y<'a><'a>;
2415
| ^^^^
2516

2617
error[E0107]: missing generics for associated type `X::Y`
27-
--> $DIR/gat-trait-path-missing-lifetime.rs:5:8
18+
--> $DIR/gat-trait-path-missing-lifetime.rs:4:8
2819
|
2920
LL | type Y<'a>;
3021
| ^ expected 1 lifetime argument
3122
|
3223
note: associated type defined here, with 1 lifetime parameter: `'a`
33-
--> $DIR/gat-trait-path-missing-lifetime.rs:5:8
24+
--> $DIR/gat-trait-path-missing-lifetime.rs:4:8
3425
|
3526
LL | type Y<'a>;
3627
| ^ --
@@ -39,6 +30,6 @@ help: use angle brackets to add missing lifetime argument
3930
LL | type Y<'a><'a>;
4031
| ^^^^
4132

42-
error: aborting due to 2 previous errors; 1 warning emitted
33+
error: aborting due to 2 previous errors
4334

4435
For more information about this error, try `rustc --explain E0107`.

src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.rs

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

43
trait X {
54
type Y<'a>;
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,31 @@
11
error: lifetime in trait object type must be followed by `+`
2-
--> $DIR/gat-trait-path-parenthesised-args.rs:10:29
2+
--> $DIR/gat-trait-path-parenthesised-args.rs:9:29
33
|
44
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
55
| ^^
66

77
error: parenthesized generic arguments cannot be used in associated type constraints
8-
--> $DIR/gat-trait-path-parenthesised-args.rs:10:27
8+
--> $DIR/gat-trait-path-parenthesised-args.rs:9:27
99
|
1010
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
1111
| ^^^^^
1212

13-
warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
14-
--> $DIR/gat-trait-path-parenthesised-args.rs:1:12
15-
|
16-
LL | #![feature(generic_associated_types)]
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^
18-
|
19-
= note: `#[warn(incomplete_features)]` on by default
20-
= note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
21-
2213
warning: trait objects without an explicit `dyn` are deprecated
23-
--> $DIR/gat-trait-path-parenthesised-args.rs:10:29
14+
--> $DIR/gat-trait-path-parenthesised-args.rs:9:29
2415
|
2516
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
2617
| ^^ help: use `dyn`: `dyn 'a`
2718
|
2819
= note: `#[warn(bare_trait_objects)]` on by default
2920

3021
error[E0107]: this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
31-
--> $DIR/gat-trait-path-parenthesised-args.rs:5:8
22+
--> $DIR/gat-trait-path-parenthesised-args.rs:4:8
3223
|
3324
LL | type Y<'a>;
3425
| ^ expected 1 lifetime argument
3526
|
3627
note: associated type defined here, with 1 lifetime parameter: `'a`
37-
--> $DIR/gat-trait-path-parenthesised-args.rs:5:8
28+
--> $DIR/gat-trait-path-parenthesised-args.rs:4:8
3829
|
3930
LL | type Y<'a>;
4031
| ^ --
@@ -44,7 +35,7 @@ LL | fn foo<'a>(arg: Box<dyn X<Y('a'a) = &'a ()>>) {}
4435
| ^^
4536

4637
error[E0107]: this associated type takes 0 type arguments but 1 type argument was supplied
47-
--> $DIR/gat-trait-path-parenthesised-args.rs:5:8
38+
--> $DIR/gat-trait-path-parenthesised-args.rs:4:8
4839
|
4940
LL | type Y<'a>;
5041
| ________^-
@@ -58,11 +49,11 @@ LL | | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
5849
| |_________________________________________- help: remove these generics
5950
|
6051
note: associated type defined here, with 0 type parameters
61-
--> $DIR/gat-trait-path-parenthesised-args.rs:5:8
52+
--> $DIR/gat-trait-path-parenthesised-args.rs:4:8
6253
|
6354
LL | type Y<'a>;
6455
| ^
6556

66-
error: aborting due to 4 previous errors; 2 warnings emitted
57+
error: aborting due to 4 previous errors; 1 warning emitted
6758

6859
For more information about this error, try `rustc --explain E0107`.

src/test/ui/generic-associated-types/generic-associated-type-bounds.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22

3-
#![allow(incomplete_features)]
43
#![feature(generic_associated_types)]
54

65
pub trait X {

src/test/ui/generic-associated-types/generic-associated-types-where.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(incomplete_features)]
21
#![feature(generic_associated_types)]
32

43
// Checking the interaction with this other feature

src/test/ui/generic-associated-types/generic-associated-types-where.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: `T` doesn't implement `std::fmt::Display`
2-
--> $DIR/generic-associated-types-where.rs:21:5
2+
--> $DIR/generic-associated-types-where.rs:20:5
33
|
44
LL | type Assoc2<T> = Vec<T>;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter
@@ -11,7 +11,7 @@ LL | type Assoc2<T: std::fmt::Display> = Vec<T>;
1111
| ^^^^^^^^^^^^^^^^^^^
1212

1313
error[E0276]: impl has stricter requirements than trait
14-
--> $DIR/generic-associated-types-where.rs:23:5
14+
--> $DIR/generic-associated-types-where.rs:22:5
1515
|
1616
LL | type Assoc3<T>;
1717
| --------------- definition of `Assoc3` from trait

src/test/ui/generic-associated-types/generic_associated_type_undeclared_lifetimes.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(incomplete_features)]
21
#![feature(generic_associated_types)]
32

43
use std::ops::Deref;

0 commit comments

Comments
 (0)