Skip to content

Commit 4f0b4f2

Browse files
committed
feature gate trait aliases
1 parent 4029a01 commit 4f0b4f2

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

src/libsyntax/feature_gate.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ declare_features! (
368368
// Generators
369369
(active, generators, "1.21.0", None),
370370

371+
// Trait aliases
372+
(active, trait_alias, "1.24.0", Some(41517)),
371373

372374
// global allocators and their internals
373375
(active, global_allocator, "1.20.0", None),
@@ -1406,6 +1408,12 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
14061408
}
14071409
}
14081410

1411+
ast::ItemKind::TraitAlias(..) => {
1412+
gate_feature_post!(&self, trait_alias,
1413+
i.span,
1414+
"trait aliases are not yet fully implemented");
1415+
}
1416+
14091417
ast::ItemKind::AutoImpl(..) => {
14101418
gate_feature_post!(&self, optin_builtin_traits,
14111419
i.span,

src/test/compile-fail/trait-alias.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// gate-test-trait_alias
12+
1113
trait Alias1<T> = Default where T: Clone; // ok
12-
//~^ERROR trait aliases are not yet implemented
14+
//~^ERROR trait aliases are not yet fully implemented
1315
trait Alias2<T: Clone = ()> = Default;
1416
//~^ERROR type parameters on the left side of a trait alias cannot be bounded
1517
//~^^ERROR type parameters on the left side of a trait alias cannot have defaults
16-
//~^^^ERROR trait aliases are not yet implemented
18+
//~^^^ERROR trait aliases are not yet fully implemented
1719

1820
impl Alias1 { //~ERROR expected type, found trait alias
1921
fn foo() {}

src/test/ui/trait-alias.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(trait_alias)]
12+
1113
trait SimpleAlias = Default; //~ERROR E0645
1214
trait GenericAlias<T> = Iterator<Item=T>; //~ERROR E0645
1315
trait Partial<T> = IntoIterator<Item=T>; //~ERROR E0645

src/test/ui/trait-alias.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
error[E0645]: trait aliases are not yet implemented (see issue #41517)
2-
--> $DIR/trait-alias.rs:11:1
2+
--> $DIR/trait-alias.rs:13:1
33
|
4-
11 | trait SimpleAlias = Default; //~ERROR E0645
4+
13 | trait SimpleAlias = Default; //~ERROR E0645
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error[E0645]: trait aliases are not yet implemented (see issue #41517)
8-
--> $DIR/trait-alias.rs:12:1
8+
--> $DIR/trait-alias.rs:14:1
99
|
10-
12 | trait GenericAlias<T> = Iterator<Item=T>; //~ERROR E0645
10+
14 | trait GenericAlias<T> = Iterator<Item=T>; //~ERROR E0645
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error[E0645]: trait aliases are not yet implemented (see issue #41517)
14-
--> $DIR/trait-alias.rs:13:1
14+
--> $DIR/trait-alias.rs:15:1
1515
|
16-
13 | trait Partial<T> = IntoIterator<Item=T>; //~ERROR E0645
16+
15 | trait Partial<T> = IntoIterator<Item=T>; //~ERROR E0645
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1818

1919
error[E0645]: trait aliases are not yet implemented (see issue #41517)
20-
--> $DIR/trait-alias.rs:22:1
20+
--> $DIR/trait-alias.rs:24:1
2121
|
22-
22 | trait WithWhere<Art, Thou> = Romeo + Romeo where Fore<(Art, Thou)>: Romeo; //~ERROR E0645
22+
24 | trait WithWhere<Art, Thou> = Romeo + Romeo where Fore<(Art, Thou)>: Romeo; //~ERROR E0645
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2424

2525
error[E0645]: trait aliases are not yet implemented (see issue #41517)
26-
--> $DIR/trait-alias.rs:23:1
26+
--> $DIR/trait-alias.rs:25:1
2727
|
28-
23 | trait BareWhere<Wild, Are> = where The<Wild>: Things<Are>; //~ERROR E0645
28+
25 | trait BareWhere<Wild, Are> = where The<Wild>: Things<Are>; //~ERROR E0645
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3030

3131
error[E0645]: trait aliases are not yet implemented (see issue #41517)
32-
--> $DIR/trait-alias.rs:25:1
32+
--> $DIR/trait-alias.rs:27:1
3333
|
34-
25 | trait CD = Clone + Default; //~ERROR E0645
34+
27 | trait CD = Clone + Default; //~ERROR E0645
3535
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
3636

3737
error: aborting due to 6 previous errors

0 commit comments

Comments
 (0)