Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature gate where clauses on associated type impls #53235

Merged
merged 1 commit into from
Aug 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
_ => {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ trait PointerFamily<U> {
}

struct Foo;

impl PointerFamily<u32> for Foo {
type Pointer<usize> = Box<usize>;
//~^ ERROR generic associated types are unstable
Expand All @@ -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() {}
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,37 @@ LL | type Pointer2<T>: Deref<Target = T> 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<usize> = Box<usize>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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<u32> = Box<u32>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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: abo