-
-
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.
tests: Add ui tests about negative_impls for !Unpin and UnsafeUnpin o…
…ptions
- Loading branch information
Showing
4 changed files
with
58 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,20 @@ | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// https://github.com/taiki-e/pin-project/issues/340#issuecomment-2428002670 | ||
|
||
#[pin_project::pin_project(!Unpin)] | ||
struct Foo<Pinned, Unpinned> { | ||
#[pin] | ||
pinned: Pinned, | ||
unpinned: Unpinned, | ||
} | ||
|
||
struct MyPhantomPinned(::core::marker::PhantomPinned); | ||
impl Unpin for MyPhantomPinned where for<'cursed> str: Sized {} | ||
impl Unpin for Foo<MyPhantomPinned, ()> {} | ||
|
||
fn is_unpin<T: Unpin>() {} | ||
|
||
fn main() { | ||
is_unpin::<Foo<MyPhantomPinned, ()>>() | ||
} |
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,8 @@ | ||
error[E0119]: conflicting implementations of trait `Unpin` for type `Foo<MyPhantomPinned, ()>` | ||
--> tests/ui/not_unpin/negative_impls_stable.rs:5:28 | ||
| | ||
5 | #[pin_project::pin_project(!Unpin)] | ||
| ^^^^^^ conflicting implementation for `Foo<MyPhantomPinned, ()>` | ||
... | ||
14 | impl Unpin for Foo<MyPhantomPinned, ()> {} | ||
| --------------------------------------- first implementation here |
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,22 @@ | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// https://github.com/taiki-e/pin-project/issues/340#issuecomment-2428002670 | ||
|
||
#[pin_project::pin_project(UnsafeUnpin)] | ||
struct Foo<Pinned, Unpinned> { | ||
#[pin] | ||
pinned: Pinned, | ||
unpinned: Unpinned, | ||
} | ||
|
||
unsafe impl<Pinned: Unpin, Unpinned> pin_project::UnsafeUnpin for Foo<Pinned, Unpinned> {} | ||
|
||
struct MyPhantomPinned(::core::marker::PhantomPinned); | ||
impl Unpin for MyPhantomPinned where for<'cursed> str: Sized {} | ||
impl Unpin for Foo<MyPhantomPinned, ()> {} | ||
|
||
fn is_unpin<T: Unpin>() {} | ||
|
||
fn main() { | ||
is_unpin::<Foo<MyPhantomPinned, ()>>() | ||
} |
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,8 @@ | ||
error[E0119]: conflicting implementations of trait `Unpin` for type `Foo<MyPhantomPinned, ()>` | ||
--> tests/ui/unsafe_unpin/negative_impls_stable.rs:5:28 | ||
| | ||
5 | #[pin_project::pin_project(UnsafeUnpin)] | ||
| ^^^^^^^^^^^ conflicting implementation for `Foo<MyPhantomPinned, ()>` | ||
... | ||
16 | impl Unpin for Foo<MyPhantomPinned, ()> {} | ||
| --------------------------------------- first implementation here |