Skip to content

Commit bd3ba12

Browse files
committed
Auto merge of #49368 - matthewjasper:feature-gate-where-clause, r=<try>
Feature gate where clauses on associated types Fixes #49365. Requires crater: these have been usable since 1.24.
2 parents 934902a + d9cd6c6 commit bd3ba12

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

src/libsyntax/feature_gate.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1723,8 +1723,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
17231723
}
17241724
}
17251725
ast::TraitItemKind::Type(_, ref default) => {
1726-
// We use two if statements instead of something like match guards so that both
1727-
// of these errors can be emitted if both cases apply.
1726+
// We use three if statements instead of something like match guards so that all
1727+
// of these errors can be emitted if all cases apply.
17281728
if default.is_some() {
17291729
gate_feature_post!(&self, associated_type_defaults, ti.span,
17301730
"associated type defaults are unstable");
@@ -1733,6 +1733,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
17331733
gate_feature_post!(&self, generic_associated_types, ti.span,
17341734
"generic associated types are unstable");
17351735
}
1736+
if !ti.generics.where_clause.predicates.is_empty() {
1737+
gate_feature_post!(&self, generic_associated_types, ti.span,
1738+
"where clauses on associated types are unstable");
1739+
}
17361740
}
17371741
_ => {}
17381742
}

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

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ trait PointerFamily<U> {
1515
//~^ ERROR generic associated types are unstable
1616
type Pointer2<T>: Deref<Target = T> where T: Clone, U: Clone;
1717
//~^ ERROR generic associated types are unstable
18+
//~| ERROR where clauses on associated types are unstable
1819
}
1920

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

29+
trait Bar {
30+
type Assoc where Self: Sized;
31+
//~^ ERROR where clauses on associated types are unstable
32+
}
33+
34+
2835
fn main() {}

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

+19-3
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,38 @@ LL | type Pointer2<T>: Deref<Target = T> where T: Clone, U: Clone;
1414
|
1515
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
1616

17+
error[E0658]: where clauses on associated types are unstable (see issue #44265)
18+
--> $DIR/feature-gate-generic_associated_types.rs:16:5
19+
|
20+
LL | type Pointer2<T>: Deref<Target = T> where T: Clone, U: Clone;
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22+
|
23+
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
24+
1725
error[E0658]: generic associated types are unstable (see issue #44265)
18-
--> $DIR/feature-gate-generic_associated_types.rs:22:5
26+
--> $DIR/feature-gate-generic_associated_types.rs:23:5
1927
|
2028
LL | type Pointer<usize> = Box<usize>;
2129
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2230
|
2331
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
2432

2533
error[E0658]: generic associated types are unstable (see issue #44265)
26-
--> $DIR/feature-gate-generic_associated_types.rs:24:5
34+
--> $DIR/feature-gate-generic_associated_types.rs:25:5
2735
|
2836
LL | type Pointer2<u32> = Box<u32>;
2937
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3038
|
3139
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
3240

33-
error: aborting due to 4 previous errors
41+
error[E0658]: where clauses on associated types are unstable (see issue #44265)
42+
--> $DIR/feature-gate-generic_associated_types.rs:30:5
43+
|
44+
LL | type Assoc where Self: Sized;
45+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46+
|
47+
= help: add #![feature(generic_associated_types)] to the crate attributes to enable
48+
49+
error: aborting due to 6 previous errors
3450

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

0 commit comments

Comments
 (0)