Skip to content

Commit 4029a01

Browse files
committed
error on any use of trait alias
1 parent 63f1c24 commit 4029a01

File tree

5 files changed

+49
-9
lines changed

5 files changed

+49
-9
lines changed

src/librustc_typeck/collect.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,8 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
442442
tcx.predicates_of(def_id);
443443
},
444444
hir::ItemTraitAlias(..) => {
445-
tcx.generics_of(def_id);
446-
tcx.trait_def(def_id);
447-
tcx.predicates_of(def_id);
445+
span_err!(tcx.sess, it.span, E0645,
446+
"trait aliases are not yet implemented (see issue #41517)");
448447
},
449448
hir::ItemStruct(ref struct_def, _) |
450449
hir::ItemUnion(ref struct_def, _) => {

src/librustc_typeck/diagnostics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4721,4 +4721,5 @@ register_diagnostics! {
47214721
E0632, // cannot provide explicit type parameters when `impl Trait` is used in
47224722
// argument position.
47234723
E0641, // cannot cast to/from a pointer with an unknown kind
4724+
E0645, // trait aliases not finished
47244725
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
// except according to those terms.
1010

1111
trait Alias1<T> = Default where T: Clone; // ok
12+
//~^ERROR trait aliases are not yet implemented
1213
trait Alias2<T: Clone = ()> = Default;
1314
//~^ERROR type parameters on the left side of a trait alias cannot be bounded
1415
//~^^ERROR type parameters on the left side of a trait alias cannot have defaults
16+
//~^^^ERROR trait aliases are not yet implemented
1517

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

src/test/run-pass/trait-alias.rs renamed to src/test/ui/trait-alias.rs

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

11-
trait SimpleAlias = Default;
12-
trait GenericAlias<T> = Iterator<Item=T>;
13-
trait Partial<T> = IntoIterator<Item=T>;
11+
trait SimpleAlias = Default; //~ERROR E0645
12+
trait GenericAlias<T> = Iterator<Item=T>; //~ERROR E0645
13+
trait Partial<T> = IntoIterator<Item=T>; //~ERROR E0645
1414

1515
trait Things<T> {}
1616
trait Romeo {}
@@ -19,10 +19,10 @@ struct Fore<T>(T);
1919
impl<T, U> Things<T> for The<U> {}
2020
impl<T> Romeo for Fore<T> {}
2121

22-
trait WithWhere<Art, Thou> = Romeo + Romeo where Fore<(Art, Thou)>: Romeo;
23-
trait BareWhere<Wild, Are> = where The<Wild>: Things<Are>;
22+
trait WithWhere<Art, Thou> = Romeo + Romeo where Fore<(Art, Thou)>: Romeo; //~ERROR E0645
23+
trait BareWhere<Wild, Are> = where The<Wild>: Things<Are>; //~ERROR E0645
2424

25-
trait CD = Clone + Default;
25+
trait CD = Clone + Default; //~ERROR E0645
2626

2727
fn foo<T: CD>() -> (T, T) {
2828
let one = T::default();

src/test/ui/trait-alias.stderr

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
error[E0645]: trait aliases are not yet implemented (see issue #41517)
2+
--> $DIR/trait-alias.rs:11:1
3+
|
4+
11 | trait SimpleAlias = Default; //~ERROR E0645
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error[E0645]: trait aliases are not yet implemented (see issue #41517)
8+
--> $DIR/trait-alias.rs:12:1
9+
|
10+
12 | trait GenericAlias<T> = Iterator<Item=T>; //~ERROR E0645
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error[E0645]: trait aliases are not yet implemented (see issue #41517)
14+
--> $DIR/trait-alias.rs:13:1
15+
|
16+
13 | trait Partial<T> = IntoIterator<Item=T>; //~ERROR E0645
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
19+
error[E0645]: trait aliases are not yet implemented (see issue #41517)
20+
--> $DIR/trait-alias.rs:22:1
21+
|
22+
22 | trait WithWhere<Art, Thou> = Romeo + Romeo where Fore<(Art, Thou)>: Romeo; //~ERROR E0645
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24+
25+
error[E0645]: trait aliases are not yet implemented (see issue #41517)
26+
--> $DIR/trait-alias.rs:23:1
27+
|
28+
23 | trait BareWhere<Wild, Are> = where The<Wild>: Things<Are>; //~ERROR E0645
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30+
31+
error[E0645]: trait aliases are not yet implemented (see issue #41517)
32+
--> $DIR/trait-alias.rs:25:1
33+
|
34+
25 | trait CD = Clone + Default; //~ERROR E0645
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
36+
37+
error: aborting due to 6 previous errors
38+

0 commit comments

Comments
 (0)