-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
188: Add `OriginalType<A, B>: 'pin` bound to projected type r=taiki-e a=Aaron1011 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 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. Co-authored-by: Aaron Hill <aa1ronham@gmail.com>
- Loading branch information
Showing
3 changed files
with
63 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use pin_project::{pin_project, project}; | ||
|
||
trait Bar<X> { | ||
type Y; | ||
} | ||
|
||
struct Example<A>(A); | ||
|
||
impl<X, T> Bar<X> for Example<T> { | ||
type Y = Option<T>; | ||
} | ||
|
||
#[pin_project] | ||
struct Foo<A, B> { | ||
_x: <Example<A> as Bar<B>>::Y, | ||
} | ||
|
||
#[project] | ||
impl<A, B> Foo<A, B> {} |