-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Fn trait associated type (return type) considered unconstrained #86934
Comments
@rustbot claim |
This seems to not be a bug, but an intentional error, see #25041 |
@rustbot release-assignment |
Maybe to summarize why this is an error. The rules for constrained parameters are in this rfc:
Since the lifetime parameter |
Okay, that's what I suspected. I guess I really want a more powerful |
Closing this, as it's intentional as per #86934 (comment) |
I tried this code:
I expected to see this happen:
G
should be considered a constrained type.Instead, this happened:
Note that if you use
'_
as the lifetime instead of'a
, it works. It also works if there is no lifetime on the input parameter (e.g. if it's not a reference). However I want to constrainG
to the same lifetime (eventually) so that's not an option. Is this an issue due to some lifetime assumptions about the return type from Fn traits, specifically that havingG: 'a
makes it unconstrained as it can't reason about that?This is identical for
FnOnce
andFnMut
as well.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: