Skip to content

Commit c648b0b

Browse files
committed
Auto merge of #53235 - varkor:gat_impl_where, r=estebank
Feature gate where clauses on associated type impls Fixes #52913. This doesn't address the core problem, which is tracked by #47206. However, it fixes the stable-to-stable regression: you now have to enable `#![feature(generic_associated_types)]` to trigger the weird behaviour.
2 parents e73077e + 83d5a60 commit c648b0b

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

src/libsyntax/feature_gate.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -1871,10 +1871,15 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
18711871
"existential types are unstable"
18721872
);
18731873
}
1874-
1875-
ast::ImplItemKind::Type(_) if !ii.generics.params.is_empty() => {
1876-
gate_feature_post!(&self, generic_associated_types, ii.span,
1877-
"generic associated types are unstable");
1874+
ast::ImplItemKind::Type(_) => {
1875+
if !ii.generics.params.is_empty() {
1876+
gate_feature_post!(&self, generic_associated_types, ii.span,
1877+
"generic associated types are unstable");
1878+
}
1879+
if !ii.generics.where_clause.predicates.is_empty() {
1880+
gate_feature_post!(&self, generic_associated_types, ii.span,
1881+
"where clauses on associated types are unstable");
1882+
}
18781883
}
18791884
_ => {}
18801885
}

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

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ trait PointerFamily<U> {
1919
}
2020

2121
struct Foo;
22+
2223
impl PointerFamily<u32> for Foo {
2324
type Pointer<usize> = Box<usize>;
2425
//~^ ERROR generic associated types are unstable
@@ -31,5 +32,9 @@ trait Bar {
3132
//~^ ERROR where clauses on associated types are unstable
3233
}
3334

35+
impl Bar for Foo {
36+
type Assoc where Self: Sized = Foo;
37+
//~^ ERROR where clauses on associated types are unstable
38+
}
3439

3540
fn main() {}

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

+12-4
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,37 @@ LL | type Pointer2<T>: Deref<Target = T> where T: Clone, U: Clone;
2323
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
2424

2525
error[E0658]: generic associated types are unstable (see issue #44265)
26-
--> $DIR/feature-gate-generic_associated_types.rs:23:5
26+
--> $DIR/feature-gate-generic_associated_types.rs:24:5
2727
|
2828
LL | type Pointer<usize> = Box<usize>;
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3030
|
3131
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
3232

3333
error[E0658]: generic associated types are unstable (see issue #44265)
34-
--> $DIR/feature-gate-generic_associated_types.rs:25:5
34+
--> $DIR/feature-gate-generic_associated_types.rs:26:5
3535
|
3636
LL | type Pointer2<u32> = Box<u32>;
3737
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3838
|
3939
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
4040

4141
error[E0658]: where clauses on associated types are unstable (see issue #44265)
42-
--> $DIR/feature-gate-generic_associated_types.rs:30:5
42+
--> $DIR/feature-gate-generic_associated_types.rs:31:5
4343
|
4444
LL | type Assoc where Self: Sized;
4545
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4646
|
4747
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
4848

49-
error: aborting due to 6 previous errors
49+
error[E0658]: where clauses on associated types are unstable (see issue #44265)
50+
--> $DIR/feature-gate-generic_associated_types.rs:36:5
51+
|
52+
LL | type Assoc where Self: Sized = Foo;
53+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54+
|
55+
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
56+
57+
error: aborting due to 7 previous errors
5058

5159
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)