-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add OriginalType<A, B>: 'pin
bound to projected type
#188
Conversation
7fb8b7f
to
689c40a
Compare
The UI test output seems to have changes on Nightly (the span is slightly different). I'm not sure how best to deal with this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the investigation and the patch! I believe we can fix this without breaking changes.
@Aaron1011 |
Fixes taiki-e#185 Usually, Rust will automatically add lifetime bounds of the form `T: 'lifetime` when required (e.g. when a struct contains `&'a T`). However, the compiler will not normalize associated types before performing this analysis, which can require users to manually add `T: 'lifetime` bounds themselves. When this happens with a generated projection struct, the user has no ability to add such a bound, since they cannot name the 'pin lifetime. This PR adds a bound of the form `OriginalType<A, B>: 'pin` to the `where` clause of the generated projection types. This ensures that any type parameters which need to outlive 'pin will do so, without unnecessarily constraining other type parameters. The generated bound does not need to be added to the `where` clause of any impls for the generated projection types. For more details, see https://github.com/rust-lang/rfcs/blob/d89de6a5857597cca9f6e1c7ebb70476f31a9159/text/2093-infer-outlives.md#background-outlives-requirements-today
689c40a
to
9e3dc88
Compare
Looks good, Thanks! bors r+ |
Fixes #185
Usually, Rust will automatically add lifetime bounds of the form
T: 'lifetime
when required (e.g. when a struct contains&'a T
).However, the compiler will not normalize associated types before
performing this analysis, which can require users to manually add
T: 'lifetime
bounds themselves. When this happens with a generatedprojection struct, the user has no ability to add such a bound, since
they cannot name the 'pin lifetime.
This PR adds a bound of the form
OriginalType<A, B>: 'pin
to thewhere
clause of the generated projection types. This ensures thatany type parameters which need to outlive 'pin will do so, without
unnecessarily constraining other type parameters.