-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
107: Add a dummy lifetime to Wrapper r=taiki-e a=taiki-e If we know that `Self` doesn't implement `Unpin` and `Self` doesn't contain any generics or lifetimes, we get an error `E0277`. To avoid this, add a dummy lifetime to the `Wrapper`. This allows `Wrapper<Self>` to always compile regardless of whether `Self` implements `UnsafeUnpin`. As the `Wrapper` implements `UnsafeUnpin` regardless of a lifetime, this should not change the actual bounds of the `Unpin` implementation. This allows workaround of #102 that "using `pin_project(UnsafeUnpin)` and not providing a manual `UnsafeUnpin` implementation" to work. Closes #102 cc @Aaron1011 @ogoffart Co-authored-by: Taiki Endo <[email protected]>
- Loading branch information
Showing
12 changed files
with
170 additions
and
53 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
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
2 changes: 0 additions & 2 deletions
2
.../unsafe_unpin/forget-unsafe-unpin-impl.rs → ...nsafe_unpin/not-implement-unsafe-unpin.rs
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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
// compile-fail | ||
|
||
// FIXME? | ||
|
||
use pin_project::pin_project; | ||
|
||
#[pin_project(UnsafeUnpin)] | ||
|
8 changes: 4 additions & 4 deletions
8
...afe_unpin/forget-unsafe-unpin-impl.stderr → ...e_unpin/not-implement-unsafe-unpin.stderr
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 |
---|---|---|
@@ -1,18 +1,75 @@ | ||
error[E0277]: the trait bound `std::marker::PhantomPinned: std::marker::Unpin` is not satisfied | ||
--> $DIR/proper_unpin.rs:18:5 | ||
--> $DIR/proper_unpin.rs:37:5 | ||
| | ||
15 | fn is_unpin<T: Unpin>() {} | ||
6 | fn is_unpin<T: Unpin>() {} | ||
| -------- ----- required by this bound in `is_unpin` | ||
... | ||
18 | is_unpin::<Foo<PhantomPinned, PhantomPinned>>(); //~ ERROR E0277 | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned` | ||
37 | is_unpin::<Blah<PhantomPinned, ()>>(); //~ ERROR E0277 | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned` | ||
| | ||
= help: the following implementations were found: | ||
<std::marker::PhantomPinned as std::marker::Unpin> | ||
= note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `Foo<std::marker::PhantomPinned, std::marker::PhantomPinned>` | ||
= note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<Foo<std::marker::PhantomPinned, std::marker::PhantomPinned>>` | ||
= note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo<std::marker::PhantomPinned, std::marker::PhantomPinned>` | ||
= note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `Blah<std::marker::PhantomPinned, ()>` | ||
= note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, Blah<std::marker::PhantomPinned, ()>>` | ||
= note: required because of the requirements on the impl of `std::marker::Unpin` for `Blah<std::marker::PhantomPinned, ()>` | ||
|
||
error: aborting due to previous error | ||
error[E0277]: the trait bound `std::marker::PhantomPinned: std::marker::Unpin` is not satisfied | ||
--> $DIR/proper_unpin.rs:38:5 | ||
| | ||
6 | fn is_unpin<T: Unpin>() {} | ||
| -------- ----- required by this bound in `is_unpin` | ||
... | ||
38 | is_unpin::<Blah<PhantomPinned, PhantomPinned>>(); //~ ERROR E0277 | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned` | ||
| | ||
= help: the following implementations were found: | ||
<std::marker::PhantomPinned as std::marker::Unpin> | ||
= note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `Blah<std::marker::PhantomPinned, std::marker::PhantomPinned>` | ||
= note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, Blah<std::marker::PhantomPinned, std::marker::PhantomPinned>>` | ||
= note: required because of the requirements on the impl of `std::marker::Unpin` for `Blah<std::marker::PhantomPinned, std::marker::PhantomPinned>` | ||
|
||
error[E0277]: the trait bound `NotImplementUnsafUnpin: pin_project::UnsafeUnpin` is not satisfied | ||
--> $DIR/proper_unpin.rs:39:16 | ||
| | ||
6 | fn is_unpin<T: Unpin>() {} | ||
| -------- ----- required by this bound in `is_unpin` | ||
... | ||
39 | is_unpin::<NotImplementUnsafUnpin>(); //~ ERROR E0277 | ||
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `pin_project::UnsafeUnpin` is not implemented for `NotImplementUnsafUnpin` | ||
| | ||
= note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, NotImplementUnsafUnpin>` | ||
= note: required because of the requirements on the impl of `std::marker::Unpin` for `NotImplementUnsafUnpin` | ||
|
||
error[E0277]: the trait bound `std::marker::PhantomPinned: std::marker::Unpin` is not satisfied | ||
--> $DIR/proper_unpin.rs:40:5 | ||
| | ||
6 | fn is_unpin<T: Unpin>() {} | ||
| -------- ----- required by this bound in `is_unpin` | ||
... | ||
40 | is_unpin::<OverlappingLifetimeNames<'_, PhantomPinned, ()>>(); //~ ERROR E0277 | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned` | ||
| | ||
= help: the following implementations were found: | ||
<std::marker::PhantomPinned as std::marker::Unpin> | ||
= note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `OverlappingLifetimeNames<'_, std::marker::PhantomPinned, ()>` | ||
= note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, OverlappingLifetimeNames<'_, std::marker::PhantomPinned, ()>>` | ||
= note: required because of the requirements on the impl of `std::marker::Unpin` for `OverlappingLifetimeNames<'_, std::marker::PhantomPinned, ()>` | ||
|
||
error[E0277]: the trait bound `std::marker::PhantomPinned: std::marker::Unpin` is not satisfied | ||
--> $DIR/proper_unpin.rs:41:5 | ||
| | ||
6 | fn is_unpin<T: Unpin>() {} | ||
| -------- ----- required by this bound in `is_unpin` | ||
... | ||
41 | is_unpin::<OverlappingLifetimeNames<'_, (), PhantomPinned>>(); //~ ERROR E0277 | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `std::marker::PhantomPinned` | ||
| | ||
= help: the following implementations were found: | ||
<std::marker::PhantomPinned as std::marker::Unpin> | ||
= note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `OverlappingLifetimeNames<'_, (), std::marker::PhantomPinned>` | ||
= note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<'_, OverlappingLifetimeNames<'_, (), std::marker::PhantomPinned>>` | ||
= note: required because of the requirements on the impl of `std::marker::Unpin` for `OverlappingLifetimeNames<'_, (), std::marker::PhantomPinned>` | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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
10 changes: 5 additions & 5 deletions
10
tests/ui/unstable-features/trivial_bounds-feature-gate.stderr
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