-
Notifications
You must be signed in to change notification settings - Fork 13k
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
impl Trait return value causes an over-restricted lifetime requirement #51069
Comments
I've also just run into this. Alternate example:
This tells me the lifetime of |
@andrewhickman I think that's a valid error, in the call to Notice in @cuviper's example that the |
Is there no way to express that the output type is independent of the input type? |
There will be with named existential types, you should even be able to have a generic existential type that depends on only some of the input type parameters, here's a playground #![feature(existential_type)]
trait Future {}
impl Future for () {}
existential type CacheFuture: Future + 'static;
fn cache<I>(_: I) -> CacheFuture
where
I: IntoIterator<Item = ()>,
{
()
}
pub fn cache_slice<'a>(glyphs: &[()]) -> impl Future + 'static {
cache(glyphs.iter().cloned())
} |
In my example, that would include If that's the case, it still feels like a bug, but I'm not sure of the rules here. |
Duplicate of #42940 |
Reduced from an example given on the users forum.
This code (playground) fails to compile:
It seems the
'n
lifetime is getting tied into the return type somehow.It works if you make
find
return an explicit type:It also works if you instead remove the
S
parameter:The text was updated successfully, but these errors were encountered: