diff options
| author | bors <bors@rust-lang.org> | 2021-08-24 14:55:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-08-24 14:55:48 +0000 |
| commit | b5fe3bc0650279e4283a0511670c0668fc0f2217 (patch) | |
| tree | e0b783aca25d0bc2ef154ba5ac82063fd580c9c5 /src/test | |
| parent | 47ab5f7ce27397310bd8359b8db1504fbf8a9b59 (diff) | |
| parent | b0170779f5c6e9705658cda1b02cf1fd1a925205 (diff) | |
| download | rust-b5fe3bc0650279e4283a0511670c0668fc0f2217.tar.gz rust-b5fe3bc0650279e4283a0511670c0668fc0f2217.zip | |
Auto merge of #87900 - jackh726:issue-87429, r=nikomatsakis
Use bound vars for GAT params in param_env in check_type_bounds Fixes #87429
Diffstat (limited to 'src/test')
6 files changed, 120 insertions, 0 deletions
diff --git a/src/test/ui/generic-associated-types/issue-87429-2.rs b/src/test/ui/generic-associated-types/issue-87429-2.rs new file mode 100644 index 00000000000..d35bb098abd --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-87429-2.rs @@ -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() {} 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<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() {} 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..01cb0bfc72c --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-87429-associated-type-default.stderr @@ -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`. 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<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() {} 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..87bd35f5878 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-87429-specialization.stderr @@ -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`. diff --git a/src/test/ui/generic-associated-types/issue-87429.rs b/src/test/ui/generic-associated-types/issue-87429.rs new file mode 100644 index 00000000000..f905348ae32 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-87429.rs @@ -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() {} |
