-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-trait-systemArea: Trait systemArea: Trait system
Description
Spawned off of #84937 (comment)
Code example
trait MiniYokeable<'a> {
type Output;
}
struct MiniYoke<Y: for<'a> MiniYokeable<'a>> {
pub yokeable: Y,
}
fn map_project_broken<Y, P>(
source: MiniYoke<Y>,
f: impl for<'a> FnOnce(
<Y as MiniYokeable<'a>>::Output,
core::marker::PhantomData<&'a ()>,
) -> <P as MiniYokeable<'a>>::Output,
) -> MiniYoke<P>
where
Y: for<'a> MiniYokeable<'a>,
P: for<'a> MiniYokeable<'a>
{
unimplemented!()
}
struct Bar<'a> {
string_1: &'a str,
string_2: &'a str,
}
impl<'a> MiniYokeable<'a> for Bar<'static> {
type Output = Bar<'a>;
}
impl<'a> MiniYokeable<'a> for &'static str {
type Output = &'a str;
}
fn demo_broken(bar: MiniYoke<Bar<'static>>) -> MiniYoke<&'static str> {
map_project_broken(bar, |bar, _| bar.string_1)
}
(playpen)
throws an error of
51 | map_project_broken(bar, |bar, _| bar.string_1)
| ^^^^^^^^^^^^^^^^^^ --------------------- found signature of `for<'r> fn(Bar<'r>, PhantomData<&'r ()>) -> _`
| |
| expected signature of `for<'a> fn(<Bar<'_> as MiniYokeable<'a>>::Output, PhantomData<&'a ()>) -> _`
This error is incorrect: <Bar<'_> as MiniYokeable<'a>>::Output
is the same thing as Bar<'a>
.
Metadata
Metadata
Assignees
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-trait-systemArea: Trait systemArea: Trait system