Skip to content

Commit 6df6eb8

Browse files
committed
Add a couple more tests
1 parent d9242ff commit 6df6eb8

4 files changed

+81
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// check-fail
2+
3+
#![feature(associated_type_defaults)]
4+
#![feature(generic_associated_types)]
5+
6+
trait Family {
7+
// Fine, i32: PartialEq<i32>
8+
type Member<'a>: for<'b> PartialEq<Self::Member<'b>> = i32;
9+
}
10+
11+
struct Foo;
12+
trait Family2 {
13+
// Not fine, not Foo: PartialEq<Foo>
14+
type Member<'a>: for<'b> PartialEq<Self::Member<'b>> = Foo;
15+
//~^ ERROR can't compare
16+
}
17+
18+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0277]: can't compare `Foo` with `Foo`
2+
--> $DIR/issue-87429-associated-type-default.rs:14:5
3+
|
4+
LL | type Member<'a>: for<'b> PartialEq<Self::Member<'b>> = Foo;
5+
| ^^^^^^^^^^^^^^^^^-----------------------------------^^^^^^^
6+
| | |
7+
| | required by this bound in `Family2::Member`
8+
| no implementation for `Foo == Foo`
9+
|
10+
= help: the trait `PartialEq` is not implemented for `Foo`
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// check-fail
2+
3+
#![feature(specialization)]
4+
//~^ WARN incomplete
5+
#![feature(generic_associated_types)]
6+
7+
trait Family {
8+
type Member<'a>: for<'b> PartialEq<Self::Member<'b>>;
9+
}
10+
11+
struct I32Family;
12+
13+
impl Family for I32Family {
14+
default type Member<'a> = i32;
15+
}
16+
17+
struct Foo;
18+
struct FooFamily;
19+
20+
impl Family for FooFamily {
21+
default type Member<'a> = Foo;
22+
//~^ ERROR can't compare
23+
}
24+
25+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/issue-87429-specialization.rs:3:12
3+
|
4+
LL | #![feature(specialization)]
5+
| ^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+
= note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
9+
= help: consider using `min_specialization` instead, which is more stable and complete
10+
11+
error[E0277]: can't compare `Foo` with `Foo`
12+
--> $DIR/issue-87429-specialization.rs:21:5
13+
|
14+
LL | type Member<'a>: for<'b> PartialEq<Self::Member<'b>>;
15+
| ----------------------------------- required by this bound in `Family::Member`
16+
...
17+
LL | default type Member<'a> = Foo;
18+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Foo == Foo`
19+
|
20+
= help: the trait `PartialEq` is not implemented for `Foo`
21+
22+
error: aborting due to previous error; 1 warning emitted
23+
24+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)