From 6df6eb8ae8358ebab76fcfa35ac7cc41e18a2560 Mon Sep 17 00:00:00 2001 From: jackh726 Date: Mon, 16 Aug 2021 10:49:36 -0400 Subject: [PATCH] Add a couple more tests --- .../issue-87429-associated-type-default.rs | 18 +++++++++++++ ...issue-87429-associated-type-default.stderr | 14 +++++++++++ .../issue-87429-specialization.rs | 25 +++++++++++++++++++ .../issue-87429-specialization.stderr | 24 ++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 src/test/ui/generic-associated-types/issue-87429-associated-type-default.rs create mode 100644 src/test/ui/generic-associated-types/issue-87429-associated-type-default.stderr create mode 100644 src/test/ui/generic-associated-types/issue-87429-specialization.rs create mode 100644 src/test/ui/generic-associated-types/issue-87429-specialization.stderr diff --git a/src/test/ui/generic-associated-types/issue-87429-associated-type-default.rs b/src/test/ui/generic-associated-types/issue-87429-associated-type-default.rs new file mode 100644 index 00000000000..9ee07c2f1e1 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-87429-associated-type-default.rs @@ -0,0 +1,18 @@ +// check-fail + +#![feature(associated_type_defaults)] +#![feature(generic_associated_types)] + +trait Family { + // Fine, i32: PartialEq + type Member<'a>: for<'b> PartialEq> = i32; +} + +struct Foo; +trait Family2 { + // Not fine, not Foo: PartialEq + type Member<'a>: for<'b> PartialEq> = Foo; + //~^ ERROR can't compare +} + +fn main() {} diff --git a/src/test/ui/generic-associated-types/issue-87429-associated-type-default.stderr b/src/test/ui/generic-associated-types/issue-87429-associated-type-default.stderr new file mode 100644 index 00000000000..8f031c76183 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-87429-associated-type-default.stderr @@ -0,0 +1,14 @@ +error[E0277]: can't compare `Foo` with `Foo` + --> $DIR/issue-87429-associated-type-default.rs:14:5 + | +LL | type Member<'a>: for<'b> PartialEq> = Foo; + | ^^^^^^^^^^^^^^^^^-----------------------------------^^^^^^^ + | | | + | | required by this bound in `Family2::Member` + | no implementation for `Foo == Foo` + | + = help: the trait `PartialEq` is not implemented for `Foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/generic-associated-types/issue-87429-specialization.rs b/src/test/ui/generic-associated-types/issue-87429-specialization.rs new file mode 100644 index 00000000000..b365e07feb2 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-87429-specialization.rs @@ -0,0 +1,25 @@ +// check-fail + +#![feature(specialization)] +//~^ WARN incomplete +#![feature(generic_associated_types)] + +trait Family { + type Member<'a>: for<'b> PartialEq>; +} + +struct I32Family; + +impl Family for I32Family { + default type Member<'a> = i32; +} + +struct Foo; +struct FooFamily; + +impl Family for FooFamily { + default type Member<'a> = Foo; + //~^ ERROR can't compare +} + +fn main() {} diff --git a/src/test/ui/generic-associated-types/issue-87429-specialization.stderr b/src/test/ui/generic-associated-types/issue-87429-specialization.stderr new file mode 100644 index 00000000000..05d40f9e7cc --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-87429-specialization.stderr @@ -0,0 +1,24 @@ +warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/issue-87429-specialization.rs:3:12 + | +LL | #![feature(specialization)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #31844 for more information + = help: consider using `min_specialization` instead, which is more stable and complete + +error[E0277]: can't compare `Foo` with `Foo` + --> $DIR/issue-87429-specialization.rs:21:5 + | +LL | type Member<'a>: for<'b> PartialEq>; + | ----------------------------------- required by this bound in `Family::Member` +... +LL | default type Member<'a> = Foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Foo == Foo` + | + = help: the trait `PartialEq` is not implemented for `Foo` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. -- 2.44.0