Skip to content

Add two tests #117792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions tests/ui/associated-types/issue-116749.current.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
error[E0277]: the trait bound `T: Foo<()>` is not satisfied
--> $DIR/issue-116749.rs:21:5
|
LL | / fn send<T>()
LL | |
LL | |
LL | |
... |
LL | |
LL | | T::FooAssociatedTy: Send,
| |_________________________________^ the trait `Foo<()>` is not implemented for `T`
|
help: consider further restricting this bound
|
LL | T: Foo<Self::BarAssociatedTy> + Foo<()>,
| +++++++++

error[E0277]: the trait bound `T: Foo<()>` is not satisfied
--> $DIR/issue-116749.rs:21:8
|
LL | fn send<T>()
| ^^^^ the trait `Foo<()>` is not implemented for `T`
|
help: consider further restricting this bound
|
LL | T: Foo<Self::BarAssociatedTy> + Foo<()>,
| +++++++++

error[E0277]: the trait bound `T: Foo<()>` is not satisfied
--> $DIR/issue-116749.rs:21:5
|
LL | / fn send<T>()
LL | |
LL | |
LL | |
... |
LL | |
LL | | T::FooAssociatedTy: Send,
| |_________________________________^ the trait `Foo<()>` is not implemented for `T`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: consider further restricting this bound
|
LL | T: Foo<Self::BarAssociatedTy> + Foo<()>,
| +++++++++

error[E0276]: impl has stricter requirements than trait
--> $DIR/issue-116749.rs:26:12
|
LL | / fn send<T>()
LL | | where
LL | | T: Foo<Self::BarAssociatedTy>,
LL | | T::FooAssociatedTy: Send;
| |_________________________________- definition of `send` from trait
...
LL | T: Foo<Self::BarAssociatedTy>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: Foo<()>`

error[E0277]: the trait bound `T: Foo<()>` is not satisfied
--> $DIR/issue-116749.rs:36:5
|
LL | / fn send<T>()
LL | |
LL | | where
LL | | T: Foo<()>,
LL | |
LL | | T::FooAssociatedTy: Send,
| |_________________________________^ the trait `Foo<()>` is not implemented for `T`
|
help: consider further restricting this bound
|
LL | T: Foo<()> + Foo<()>,
| +++++++++

error[E0276]: impl has stricter requirements than trait
--> $DIR/issue-116749.rs:39:12
|
LL | / fn send<T>()
LL | | where
LL | | T: Foo<Self::BarAssociatedTy>,
LL | | T::FooAssociatedTy: Send;
| |_________________________________- definition of `send` from trait
...
LL | T: Foo<()>,
| ^^^^^^^ impl has extra requirement `T: Foo<()>`

error: aborting due to 6 previous errors

Some errors have detailed explanations: E0276, E0277.
For more information about an error, try `rustc --explain E0276`.
47 changes: 47 additions & 0 deletions tests/ui/associated-types/issue-116749.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// revisions: current next
//[next] check-pass
//[next] compile-flags: -Ztrait-solver=next

pub trait Foo<TY> {
type FooAssociatedTy;
}

pub trait Bar {
type BarAssociatedTy;

fn send<T>()
where
T: Foo<Self::BarAssociatedTy>,
T::FooAssociatedTy: Send;
}

impl Bar for () {
type BarAssociatedTy = ();

fn send<T>()
//[current]~^ ERROR the trait bound `T: Foo<()>` is not
//[current]~| ERROR the trait bound `T: Foo<()>` is not
//[current]~| ERROR the trait bound `T: Foo<()>` is not
where
T: Foo<Self::BarAssociatedTy>,
//[current]~^ ERROR impl has stricter requirements than tra
T::FooAssociatedTy: Send,
{
}
}

impl Bar for i32 {
type BarAssociatedTy = ();

fn send<T>()
//[current]~^ ERROR the trait bound `T: Foo<()>` is not
where
T: Foo<()>,
//[current]~^ ERROR impl has stricter requirements than tra
T::FooAssociatedTy: Send,
{
}
}

fn main() {
}
86 changes: 86 additions & 0 deletions tests/ui/associated-types/issue-116864.current.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
error[E0277]: expected a `FnMut(&'any i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>`
--> $DIR/issue-116864.rs:25:1
|
LL | / pub async fn does_not_work<BAZ>(_: BAZ, mut cb: impl for<'any> FnMutFut<&'any BAZ::Param, ()>)
LL | |
LL | | where
LL | | BAZ: Baz<Param = i32>,
| |__________________________^ expected an `FnMut(&'any i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>`
|
= note: expected a closure with arguments `(&<BAZ as Baz>::Param,)`
found a closure with arguments `(&'any i32,)`
note: required for `impl for<'any> FnMutFut<&'any BAZ::Param, ()>` to implement `for<'any> FnMutFut<&'any i32, ()>`
--> $DIR/issue-116864.rs:17:20
|
LL | impl<P, F, FUT, R> FnMutFut<P, R> for F
| ^^^^^^^^^^^^^^ ^
LL | where
LL | F: FnMut(P) -> FUT,
| --------------- unsatisfied trait bound introduced here

error[E0277]: expected a `FnMut(&i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>`
--> $DIR/issue-116864.rs:31:5
|
LL | cb(&1i32).await;
| ^^^^^^^^^ expected an `FnMut(&i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>`
|
= note: expected a closure with arguments `(&<BAZ as Baz>::Param,)`
found a closure with arguments `(&i32,)`
note: required for `impl for<'any> FnMutFut<&'any BAZ::Param, ()>` to implement `FnMutFut<&i32, ()>`
--> $DIR/issue-116864.rs:17:20
|
LL | impl<P, F, FUT, R> FnMutFut<P, R> for F
| ^^^^^^^^^^^^^^ ^
LL | where
LL | F: FnMut(P) -> FUT,
| --------------- unsatisfied trait bound introduced here

error[E0277]: expected a `FnMut(&'any i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>`
--> $DIR/issue-116864.rs:29:1
|
LL | / {
LL | |
LL | | cb(&1i32).await;
LL | |
LL | |
LL | |
LL | | }
| |_^ expected an `FnMut(&'any i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>`
|
= note: expected a closure with arguments `(&<BAZ as Baz>::Param,)`
found a closure with arguments `(&'any i32,)`
note: required for `impl for<'any> FnMutFut<&'any BAZ::Param, ()>` to implement `for<'any> FnMutFut<&'any i32, ()>`
--> $DIR/issue-116864.rs:17:20
|
LL | impl<P, F, FUT, R> FnMutFut<P, R> for F
| ^^^^^^^^^^^^^^ ^
LL | where
LL | F: FnMut(P) -> FUT,
| --------------- unsatisfied trait bound introduced here

error[E0308]: mismatched types
--> $DIR/issue-116864.rs:31:8
|
LL | cb(&1i32).await;
| -- ^^^^^ expected `&<BAZ as Baz>::Param`, found `&i32`
| |
| arguments to this function are incorrect
|
= note: expected reference `&<BAZ as Baz>::Param`
found reference `&i32`
= help: consider constraining the associated type `<BAZ as Baz>::Param` to `i32`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
note: type parameter defined here
--> $DIR/issue-116864.rs:25:49
|
LL | pub async fn does_not_work<BAZ>(_: BAZ, mut cb: impl for<'any> FnMutFut<&'any BAZ::Param, ()>)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: call `Into::into` on this expression to convert `&i32` into `&<BAZ as Baz>::Param`
|
LL | cb((&1i32).into()).await;
| + ++++++++

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
14 changes: 14 additions & 0 deletions tests/ui/associated-types/issue-116864.next.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0282]: type annotations needed
--> $DIR/issue-116864.rs:31:5
|
LL | cb(&1i32).await;
| ^^^^^^^^^^^^^^^ cannot infer type

error[E0275]: overflow evaluating the requirement `<impl for<'any> FnMutFut<&'any BAZ::Param, ()> as FnMutFut<&<BAZ as Baz>::Param, ()>>::Future`
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_116864`)

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0275, E0282.
For more information about an error, try `rustc --explain E0275`.
38 changes: 38 additions & 0 deletions tests/ui/associated-types/issue-116864.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// edition:2021
// revisions: current next
//[next] compile-flags: -Ztrait-solver=next

//[next]~^^^^ ERROR overflow evaluating the requirement

use std::future::Future;

pub trait Baz {
type Param;
}

pub trait FnMutFut<P, R>: FnMut(P) -> Self::Future {
type Future: Future<Output = R>;
}

impl<P, F, FUT, R> FnMutFut<P, R> for F
where
F: FnMut(P) -> FUT,
FUT: Future<Output = R>,
{
type Future = FUT;
}

pub async fn does_not_work<BAZ>(_: BAZ, mut cb: impl for<'any> FnMutFut<&'any BAZ::Param, ()>)
//[current]~^ ERROR expected a `FnMut(&'any i32)` closure, found `imp
where
BAZ: Baz<Param = i32>,
{
//[current]~^ ERROR expected a `FnMut(&'any i32)` closure, found
cb(&1i32).await;
//[current]~^ ERROR expected a `FnMut(&i32)` closure, found `impl for<'any> FnMutFut<&'
//[current]~| ERROR mismatched types
//[next]~^^^ ERROR type annotations needed
}

fn main() {
}