-
-
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.
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// compile-fail | ||
|
||
use pin_project::pin_project; | ||
use std::{marker::PhantomPinned, pin::Pin}; | ||
|
||
#[pin_project] | ||
struct Foo<T> { | ||
#[cfg(any())] | ||
#[pin] | ||
inner: T, | ||
#[cfg(not(any()))] | ||
inner: T, | ||
} | ||
|
||
#[pin_project] | ||
struct Bar<T> { | ||
#[cfg(any())] | ||
inner: T, | ||
#[cfg(not(any()))] | ||
#[pin] | ||
inner: T, | ||
} | ||
|
||
fn is_unpin<T: Unpin>() {} | ||
|
||
fn baz<T, U>() { | ||
is_unpin::<Foo<PhantomPinned>>(); // Ok | ||
is_unpin::<Bar<PhantomPinned>>(); //~ ERROR E0277 | ||
} | ||
|
||
fn main() {} |
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,17 @@ | ||
error[E0277]: the trait bound `std::marker::PhantomPinned: std::marker::Unpin` is not satisfied in `UnpinStructBar<std::marker::PhantomPinned>` | ||
--> $DIR/proper_unpin.rs:28:5 | ||
| | ||
24 | fn is_unpin<T: Unpin>() {} | ||
| ----------------------- required by `is_unpin` | ||
... | ||
28 | is_unpin::<Bar<PhantomPinned>>(); //~ ERROR E0277 | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `UnpinStructBar<std::marker::PhantomPinned>`, 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 it appears within the type `UnpinStructBar<std::marker::PhantomPinned>` | ||
= note: required because of the requirements on the impl of `std::marker::Unpin` for `Bar<std::marker::PhantomPinned>` | ||
|
||
error: aborting due to previous error | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// compile-fail | ||
|
||
use pin_project::{pin_project, UnsafeUnpin}; | ||
use std::{marker::PhantomPinned, pin::Pin}; | ||
|
||
#[pin_project(UnsafeUnpin)] | ||
struct Foo<T, U> { | ||
#[pin] | ||
inner: T, | ||
other: U, | ||
} | ||
|
||
unsafe impl<T: Unpin, U> UnsafeUnpin for Foo<T, U> {} | ||
|
||
fn is_unpin<T: Unpin>() {} | ||
|
||
fn bar<T, U>() { | ||
is_unpin::<Foo<PhantomPinned, U>>(); //~ ERROR E0277 | ||
} | ||
|
||
fn main() {} |
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,18 @@ | ||
error[E0277]: the trait bound `std::marker::PhantomPinned: std::marker::Unpin` is not satisfied | ||
--> $DIR/proper_unpin.rs:18:5 | ||
| | ||
15 | fn is_unpin<T: Unpin>() {} | ||
| ----------------------- required by `is_unpin` | ||
... | ||
18 | is_unpin::<Foo<PhantomPinned, U>>(); //~ 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, U>` | ||
= note: required because of the requirements on the impl of `pin_project::UnsafeUnpin` for `pin_project::__private::Wrapper<Foo<std::marker::PhantomPinned, U>>` | ||
= note: required because of the requirements on the impl of `std::marker::Unpin` for `Foo<std::marker::PhantomPinned, U>` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |