diff --git a/tests/ui/not_unpin/negative_impls_stable.rs b/tests/ui/not_unpin/negative_impls_stable.rs new file mode 100644 index 00000000..1a5b4258 --- /dev/null +++ b/tests/ui/not_unpin/negative_impls_stable.rs @@ -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 { + #[pin] + pinned: Pinned, + unpinned: Unpinned, +} + +struct MyPhantomPinned(::core::marker::PhantomPinned); +impl Unpin for MyPhantomPinned where for<'cursed> str: Sized {} +impl Unpin for Foo {} + +fn is_unpin() {} + +fn main() { + is_unpin::>() +} diff --git a/tests/ui/not_unpin/negative_impls_stable.stderr b/tests/ui/not_unpin/negative_impls_stable.stderr new file mode 100644 index 00000000..79e75fe1 --- /dev/null +++ b/tests/ui/not_unpin/negative_impls_stable.stderr @@ -0,0 +1,8 @@ +error[E0119]: conflicting implementations of trait `Unpin` for type `Foo` + --> tests/ui/not_unpin/negative_impls_stable.rs:5:28 + | +5 | #[pin_project::pin_project(!Unpin)] + | ^^^^^^ conflicting implementation for `Foo` +... +14 | impl Unpin for Foo {} + | --------------------------------------- first implementation here diff --git a/tests/ui/unsafe_unpin/negative_impls_stable.rs b/tests/ui/unsafe_unpin/negative_impls_stable.rs new file mode 100644 index 00000000..88faacc0 --- /dev/null +++ b/tests/ui/unsafe_unpin/negative_impls_stable.rs @@ -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 { + #[pin] + pinned: Pinned, + unpinned: Unpinned, +} + +unsafe impl pin_project::UnsafeUnpin for Foo {} + +struct MyPhantomPinned(::core::marker::PhantomPinned); +impl Unpin for MyPhantomPinned where for<'cursed> str: Sized {} +impl Unpin for Foo {} + +fn is_unpin() {} + +fn main() { + is_unpin::>() +} diff --git a/tests/ui/unsafe_unpin/negative_impls_stable.stderr b/tests/ui/unsafe_unpin/negative_impls_stable.stderr new file mode 100644 index 00000000..ac81ad64 --- /dev/null +++ b/tests/ui/unsafe_unpin/negative_impls_stable.stderr @@ -0,0 +1,8 @@ +error[E0119]: conflicting implementations of trait `Unpin` for type `Foo` + --> tests/ui/unsafe_unpin/negative_impls_stable.rs:5:28 + | +5 | #[pin_project::pin_project(UnsafeUnpin)] + | ^^^^^^^^^^^ conflicting implementation for `Foo` +... +16 | impl Unpin for Foo {} + | --------------------------------------- first implementation here