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 types #49368

Merged
merged 1 commit into from
Apr 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
8 changes: 6 additions & 2 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1734,8 +1734,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
}
}
ast::TraitItemKind::Type(_, ref default) => {
// We use two if statements instead of something like match guards so that both
// of these errors can be emitted if both cases apply.
// We use three if statements instead of something like match guards so that all
// of these errors can be emitted if all cases apply.
if default.is_some() {
gate_feature_post!(&self, associated_type_defaults, ti.span,
"associated type defaults are unstable");
Expand All @@ -1744,6 +1744,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
gate_feature_post!(&self, generic_associated_types, ti.span,
"generic associated types are unstable");
}
if !ti.generics.where_clause.predicates.is_empty() {
gate_feature_post!(&self, generic_associated_types, ti.span,
"where clauses on associated types are unstable");
}
}
_ => {}
}
Expand Down
7 changes: 7 additions & 0 deletions src/test/ui/feature-gate-generic_associated_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ trait PointerFamily<U> {
//~^ ERROR generic associated types are unstable
type Pointer2<T>: Deref<Target = T> where T: Clone, U: Clone;
//~^ ERROR generic associated types are unstable
//~| ERROR where clauses on associated types are unstable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er, d'oh.

}

struct Foo;
Expand All @@ -25,4 +26,10 @@ impl PointerFamily<u32> for Foo {
//~^ ERROR generic associated types are unstable
}

trait Bar {
type Assoc where Self: Sized;
//~^ ERROR where clauses on associated types are unstable
}


fn main() {}
22 changes: 19 additions & 3 deletions src/test/ui/feature-gate-generic_associated_types.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,38 @@ 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]: where clauses on associated types are unstable (see issue #44265)
--> $DIR/feature-gate-generic_associated_types.rs:16:5
|
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:22:5
--> $DIR/feature-gate-generic_associated_types.rs:23: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:24:5
--> $DIR/feature-gate-generic_associated_types.rs:25:5
|
LL | type Pointer2<u32> = Box<u32>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add #![feature(generic_associated_types)] to the crate attributes to enable

error: aborting due to 4 previous errors
error[E0658]: where clauses on associated types are unstable (see issue #44265)
--> $DIR/feature-gate-generic_associated_types.rs:30: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

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