forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#87900 - jackh726:issue-87429, r=nikomatsakis
Use bound vars for GAT params in param_env in check_type_bounds Fixes rust-lang#87429
- Loading branch information
Showing
8 changed files
with
215 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Derived from `issue-87429`. A test that ensures that using bound vars in the | ||
// predicates in the param env when checking that an associated type satisfies | ||
// its bounds does not cause us to not be able to use the bounds on the parameters. | ||
|
||
// check-pass | ||
|
||
#![feature(generic_associated_types)] | ||
|
||
trait Family { | ||
type Member<'a, C: Eq>: for<'b> MyBound<'b, C>; | ||
} | ||
|
||
trait MyBound<'a, C> { } | ||
impl<'a, C: Eq> MyBound<'a, C> for i32 { } | ||
|
||
impl Family for () { | ||
type Member<'a, C: Eq> = i32; | ||
} | ||
|
||
fn main() {} |
18 changes: 18 additions & 0 deletions
18
src/test/ui/generic-associated-types/issue-87429-associated-type-default.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
16 changes: 16 additions & 0 deletions
16
src/test/ui/generic-associated-types/issue-87429-associated-type-default.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
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; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Foo == Foo` | ||
| | ||
= help: the trait `PartialEq` is not implemented for `Foo` | ||
note: required by a bound in `Family2::Member` | ||
--> $DIR/issue-87429-associated-type-default.rs:14:22 | ||
| | ||
LL | type Member<'a>: for<'b> PartialEq<Self::Member<'b>> = Foo; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Family2::Member` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
25 changes: 25 additions & 0 deletions
25
src/test/ui/generic-associated-types/issue-87429-specialization.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
26 changes: 26 additions & 0 deletions
26
src/test/ui/generic-associated-types/issue-87429-specialization.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
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 | default type Member<'a> = Foo; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Foo == Foo` | ||
| | ||
= help: the trait `PartialEq` is not implemented for `Foo` | ||
note: required by a bound in `Family::Member` | ||
--> $DIR/issue-87429-specialization.rs:8:22 | ||
| | ||
LL | type Member<'a>: for<'b> PartialEq<Self::Member<'b>>; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Family::Member` | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// check-pass | ||
|
||
#![feature(generic_associated_types)] | ||
|
||
trait Family { | ||
type Member<'a>: for<'b> PartialEq<Self::Member<'b>>; | ||
} | ||
|
||
struct I32; | ||
|
||
impl Family for I32 { | ||
type Member<'a> = i32; | ||
} | ||
|
||
fn main() {} |