-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Trouble unifying function types involving HRTB #84937
Comments
This might be related to #84937 |
I was literally talking to @eddyb about this problem the other day, so your timing and cc's are perfect. My understanding is that we need to be able to express |
You definitely want to cc @nikomatsakis on this btw - I remember discussing my ideas around For |
Type/const HRTB is not being worked on as part of GATs; I'm not sure if there's any implementation for them at all. |
That said, the work we're doing @jackh726 on normalizing under binders is pretty relevant to this. |
I have been working on something in the I am trying to apply the same workaround as @Manishearth, but with a slightly different trait setup (I need to use a trait to be able to bind the closure's input lifetime to a generic type that the caller can choose, but gets to borrow from the input) and its not working, @Manishearth do you know more about this fn pointer workaround? |
No idea |
This is fixed now, presumably by #85499. |
@jackh726 do you think it would be productive to add a regression test, or should we just close this issue? |
Yeah, I think we can probably just close it. There are a bunch of tests added in/after #85499 that probably cover this case. |
Not quite fixed. Slightly more complicated case (playground): 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)
} Error message:
Note that the error is incorrect because CC @Manishearth Should this be a new issue? |
cc @jackh726 thoughts? |
Please file a new issue and tag me |
(playpen)
throws up the following error, both when using
deserialize
anddeserialize2
in `attachThis is a reduced version of my full testcase here.
The types are indeed the same, in the case of
deserialize()
they've literally been written out to be exactly the same, yet the compiler seems to have trouble. If I write out an actual meaningful body fordeserialize()
the body compiles just fine -- rustc is able to unify it there, but not when comparingFn
typesEven more confusing, I get a similar error when I swap out
deserialize
with|data| { unimplemented!() }
, which is mystifying since the closure passed does not have a knownOutput
type and yet the error is talking about unifyingCow<'_, [u8]>
with the associated type. I feel like there's a bug involved here somewhere.cc @eddyb @tmandry
The text was updated successfully, but these errors were encountered: