Skip to content
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

Wrong lifetime is inferred in the argument of closure when given more specific type. #51616

oxalica opened this issue Jun 18, 2018 · 0 comments


Copy link

@oxalica oxalica commented Jun 18, 2018

I have lifetime bounds to a closure through a trait like this.

trait Closure<'t> {}
impl<'t, F: Fn(&'t ())> Closure<'t> for F {}

fn restrict_trait(_: impl Closure<'static>) {}

When I call restrict_trait(|r| ...), I'll get r: &'static () inside the closure. But when using restrict_trait(|r: &_| ...), the lifetime of r inferred is not 'static anymore.

Here is the detailed example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants