Skip to content

Commit

Permalink
Add a couple more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jackh726 committed Aug 23, 2021
1 parent d9242ff commit 6df6eb8
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// check-fail

#![feature(associated_type_defaults)]
#![feature(generic_associated_types)]

trait Family {
// Fine, i32: PartialEq<i32>
type Member<'a>: for<'b> PartialEq<Self::Member<'b>> = i32;
}

struct Foo;
trait Family2 {
// Not fine, not Foo: PartialEq<Foo>
type Member<'a>: for<'b> PartialEq<Self::Member<'b>> = Foo;
//~^ ERROR can't compare
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -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<Self::Member<'b>> = 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`.
25 changes: 25 additions & 0 deletions src/test/ui/generic-associated-types/issue-87429-specialization.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// check-fail

#![feature(specialization)]
//~^ WARN incomplete
#![feature(generic_associated_types)]

trait Family {
type Member<'a>: for<'b> PartialEq<Self::Member<'b>>;
}

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() {}
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/rust-lang/rust/issues/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<Self::Member<'b>>;
| ----------------------------------- 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`.

0 comments on commit 6df6eb8

Please sign in to comment.