Closed
Description
For some reason FnMutFut<&'any BAZ::Param, ()>
is not being inferred as FnMutFut<&'any i32, ()>
, which results in an unsatisfied trait bound error.
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, ()>)
where
BAZ: Baz<Param = i32>,
{
cb(&1i32).await;
}
Perhaps something involving the generic implementation of FnMutFut
? Perhaps something involving impl trait
?
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
fmease commentedon Oct 17, 2023
With
-Ztrait-solver=classic
:With
-Ztrait-solver=next
:c410-f3r commentedon Oct 17, 2023
Thank you @fmease!
Since you are here, would you mind taking a look at #116749? :)
lcnr commentedon Nov 13, 2023
minimized
which is a duplicate of #41118, the overflow error with
-Ztrait-solver=next
in the original example is interesting however. See the next commentlcnr commentedon Nov 13, 2023
this results in overflow in the new solver during
typeck
https://rust.godbolt.org/z/GGWeh597Mfurther minimized this issue in rust-lang/trait-system-refactor-initiative#76. Therefore closing this issue as a duplicate. Thank you for discovering a new issue in the new solver 🎉 we've been unsure about rust-lang/trait-system-refactor-initiative#12 for quite a while and this is really useful
c410-f3r commentedon Nov 13, 2023
@lcnr Thank you very much for investigating this use-case!
For further context, the code was based on a suggestion provided by @danielhenrymantilla to simulate
fn fun(_: for<'a> impl Fn(&'a Foo) -> impl Bar + 'a)
.3 remaining items