error on any use of trait alias
This commit is contained in:
parent
63f1c24d8a
commit
4029a01984
5 changed files with 49 additions and 9 deletions
|
@ -442,9 +442,8 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
|
||||||
tcx.predicates_of(def_id);
|
tcx.predicates_of(def_id);
|
||||||
},
|
},
|
||||||
hir::ItemTraitAlias(..) => {
|
hir::ItemTraitAlias(..) => {
|
||||||
tcx.generics_of(def_id);
|
span_err!(tcx.sess, it.span, E0645,
|
||||||
tcx.trait_def(def_id);
|
"trait aliases are not yet implemented (see issue #41517)");
|
||||||
tcx.predicates_of(def_id);
|
|
||||||
},
|
},
|
||||||
hir::ItemStruct(ref struct_def, _) |
|
hir::ItemStruct(ref struct_def, _) |
|
||||||
hir::ItemUnion(ref struct_def, _) => {
|
hir::ItemUnion(ref struct_def, _) => {
|
||||||
|
|
|
@ -4721,4 +4721,5 @@ register_diagnostics! {
|
||||||
E0632, // cannot provide explicit type parameters when `impl Trait` is used in
|
E0632, // cannot provide explicit type parameters when `impl Trait` is used in
|
||||||
// argument position.
|
// argument position.
|
||||||
E0641, // cannot cast to/from a pointer with an unknown kind
|
E0641, // cannot cast to/from a pointer with an unknown kind
|
||||||
|
E0645, // trait aliases not finished
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,11 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
trait Alias1<T> = Default where T: Clone; // ok
|
trait Alias1<T> = Default where T: Clone; // ok
|
||||||
|
//~^ERROR trait aliases are not yet implemented
|
||||||
trait Alias2<T: Clone = ()> = Default;
|
trait Alias2<T: Clone = ()> = Default;
|
||||||
//~^ERROR type parameters on the left side of a trait alias cannot be bounded
|
//~^ERROR type parameters on the left side of a trait alias cannot be bounded
|
||||||
//~^^ERROR type parameters on the left side of a trait alias cannot have defaults
|
//~^^ERROR type parameters on the left side of a trait alias cannot have defaults
|
||||||
|
//~^^^ERROR trait aliases are not yet implemented
|
||||||
|
|
||||||
impl Alias1 { //~ERROR expected type, found trait alias
|
impl Alias1 { //~ERROR expected type, found trait alias
|
||||||
fn foo() {}
|
fn foo() {}
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
trait SimpleAlias = Default;
|
trait SimpleAlias = Default; //~ERROR E0645
|
||||||
trait GenericAlias<T> = Iterator<Item=T>;
|
trait GenericAlias<T> = Iterator<Item=T>; //~ERROR E0645
|
||||||
trait Partial<T> = IntoIterator<Item=T>;
|
trait Partial<T> = IntoIterator<Item=T>; //~ERROR E0645
|
||||||
|
|
||||||
trait Things<T> {}
|
trait Things<T> {}
|
||||||
trait Romeo {}
|
trait Romeo {}
|
||||||
|
@ -19,10 +19,10 @@ struct Fore<T>(T);
|
||||||
impl<T, U> Things<T> for The<U> {}
|
impl<T, U> Things<T> for The<U> {}
|
||||||
impl<T> Romeo for Fore<T> {}
|
impl<T> Romeo for Fore<T> {}
|
||||||
|
|
||||||
trait WithWhere<Art, Thou> = Romeo + Romeo where Fore<(Art, Thou)>: Romeo;
|
trait WithWhere<Art, Thou> = Romeo + Romeo where Fore<(Art, Thou)>: Romeo; //~ERROR E0645
|
||||||
trait BareWhere<Wild, Are> = where The<Wild>: Things<Are>;
|
trait BareWhere<Wild, Are> = where The<Wild>: Things<Are>; //~ERROR E0645
|
||||||
|
|
||||||
trait CD = Clone + Default;
|
trait CD = Clone + Default; //~ERROR E0645
|
||||||
|
|
||||||
fn foo<T: CD>() -> (T, T) {
|
fn foo<T: CD>() -> (T, T) {
|
||||||
let one = T::default();
|
let one = T::default();
|
38
src/test/ui/trait-alias.stderr
Normal file
38
src/test/ui/trait-alias.stderr
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
error[E0645]: trait aliases are not yet implemented (see issue #41517)
|
||||||
|
--> $DIR/trait-alias.rs:11:1
|
||||||
|
|
|
||||||
|
11 | trait SimpleAlias = Default; //~ERROR E0645
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0645]: trait aliases are not yet implemented (see issue #41517)
|
||||||
|
--> $DIR/trait-alias.rs:12:1
|
||||||
|
|
|
||||||
|
12 | trait GenericAlias<T> = Iterator<Item=T>; //~ERROR E0645
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0645]: trait aliases are not yet implemented (see issue #41517)
|
||||||
|
--> $DIR/trait-alias.rs:13:1
|
||||||
|
|
|
||||||
|
13 | trait Partial<T> = IntoIterator<Item=T>; //~ERROR E0645
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0645]: trait aliases are not yet implemented (see issue #41517)
|
||||||
|
--> $DIR/trait-alias.rs:22:1
|
||||||
|
|
|
||||||
|
22 | trait WithWhere<Art, Thou> = Romeo + Romeo where Fore<(Art, Thou)>: Romeo; //~ERROR E0645
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0645]: trait aliases are not yet implemented (see issue #41517)
|
||||||
|
--> $DIR/trait-alias.rs:23:1
|
||||||
|
|
|
||||||
|
23 | trait BareWhere<Wild, Are> = where The<Wild>: Things<Are>; //~ERROR E0645
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0645]: trait aliases are not yet implemented (see issue #41517)
|
||||||
|
--> $DIR/trait-alias.rs:25:1
|
||||||
|
|
|
||||||
|
25 | trait CD = Clone + Default; //~ERROR E0645
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 6 previous errors
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue