-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Asssociated type declared in where
clause is not enforced in type parameter
#116864
Comments
With
With
|
minimized 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 fn does_not_work<T, F>(mut cb: F)
where
T: Baz<Param = i32>,
F: FnMutFut<T::Param, ()>,
{} which is a duplicate of #41118, the overflow error with |
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 fn does_not_work<T, F>(mut cb: F)
where
T: Baz<Param = i32>,
F: FnMutFut<T::Param, ()>,
{
cb(1)
} this results in overflow in the new solver during further 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 |
@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 |
…dtwco Add test for recently fixed issue Adds a test for issue rust-lang#116864.
…dtwco Add test for recently fixed issue Adds a test for issue rust-lang#116864.
Rollup merge of rust-lang#120928 - c410-f3r:tests-tests-tests, r=davidtwco Add test for recently fixed issue Adds a test for issue rust-lang#116864.
For some reason
FnMutFut<&'any BAZ::Param, ()>
is not being inferred asFnMutFut<&'any i32, ()>
, which results in an unsatisfied trait bound error.Perhaps something involving the generic implementation of
FnMutFut
? Perhaps something involvingimpl trait
?The text was updated successfully, but these errors were encountered: