From 83d5a60cf64bbda77debdc8e91ba5486b2522880 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 9 Aug 2018 20:58:43 +0100 Subject: [PATCH] Feature gate where clauses on associated type impls --- src/libsyntax/feature_gate.rs | 13 +++++++++---- .../feature-gate-generic_associated_types.rs | 5 +++++ .../feature-gate-generic_associated_types.stderr | 16 ++++++++++++---- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 56e69b9df9e04..3cbb391420156 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1869,10 +1869,15 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { "existential types are unstable" ); } - - ast::ImplItemKind::Type(_) if !ii.generics.params.is_empty() => { - gate_feature_post!(&self, generic_associated_types, ii.span, - "generic associated types are unstable"); + ast::ImplItemKind::Type(_) => { + if !ii.generics.params.is_empty() { + gate_feature_post!(&self, generic_associated_types, ii.span, + "generic associated types are unstable"); + } + if !ii.generics.where_clause.predicates.is_empty() { + gate_feature_post!(&self, generic_associated_types, ii.span, + "where clauses on associated types are unstable"); + } } _ => {} } diff --git a/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs b/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs index 3470662686643..bbaae1ef449fc 100644 --- a/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs +++ b/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs @@ -19,6 +19,7 @@ trait PointerFamily { } struct Foo; + impl PointerFamily for Foo { type Pointer = Box; //~^ ERROR generic associated types are unstable @@ -31,5 +32,9 @@ trait Bar { //~^ ERROR where clauses on associated types are unstable } +impl Bar for Foo { + type Assoc where Self: Sized = Foo; + //~^ ERROR where clauses on associated types are unstable +} fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr b/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr index d7891f13c6b4d..f12cbe727fbed 100644 --- a/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr +++ b/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr @@ -23,7 +23,7 @@ LL | type Pointer2: Deref where T: Clone, U: Clone; = help: add #![feature(generic_associated_types)] to the crate attributes to enable error[E0658]: generic associated types are unstable (see issue #44265) - --> $DIR/feature-gate-generic_associated_types.rs:23:5 + --> $DIR/feature-gate-generic_associated_types.rs:24:5 | LL | type Pointer = Box; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | type Pointer = Box; = help: add #![feature(generic_associated_types)] to the crate attributes to enable error[E0658]: generic associated types are unstable (see issue #44265) - --> $DIR/feature-gate-generic_associated_types.rs:25:5 + --> $DIR/feature-gate-generic_associated_types.rs:26:5 | LL | type Pointer2 = Box; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,13 +39,21 @@ LL | type Pointer2 = Box; = help: add #![feature(generic_associated_types)] to the crate attributes to enable error[E0658]: where clauses on associated types are unstable (see issue #44265) - --> $DIR/feature-gate-generic_associated_types.rs:30:5 + --> $DIR/feature-gate-generic_associated_types.rs:31:5 | LL | type Assoc where Self: Sized; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(generic_associated_types)] to the crate attributes to enable -error: aborting due to 6 previous errors +error[E0658]: where clauses on associated types are unstable (see issue #44265) + --> $DIR/feature-gate-generic_associated_types.rs:36:5 + | +LL | type Assoc where Self: Sized = Foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(generic_associated_types)] to the crate attributes to enable + +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0658`.