更新libclamav库1.0.0版本

This commit is contained in:
2023-01-14 18:28:39 +08:00
parent b879ee0b2e
commit 45fe15f472
8531 changed files with 1222046 additions and 177272 deletions

View File

@@ -0,0 +1,44 @@
# Tests
To run all tests, run the following command:
```sh
cargo +nightly test --all
```
## UI tests (`ui`, `compiletest.rs`)
This checks errors detected by the macro or the Rust compiler in the resulting
expanded code.
To run this test, run the following command:
```sh
cargo +nightly test --test compiletest
```
Locally, this test updates the files in the `ui` directory if there are
changes to the generated code. If there are any changes to the files in the
`ui` directory after running the test, please commit them.
See also [`trybuild` documentation](https://docs.rs/trybuild).
## Expansion tests (`expand`, `expandtest.rs`)
Similar to ui tests, but instead of checking the compiler output, this checks
the code generated by macros.
See [examples](../examples/README.md) for descriptions of what the generated
code does, and why it needs to be generated.
To run this test, run the following command:
```sh
cargo +nightly test --test expandtest
```
Locally, this test updates the files in the `expand` directory if there are
changes to the generated code. If there are any changes to the files in the
`expand` directory after running the test, please commit them.
See also [`macrotest` documentation](https://docs.rs/macrotest).

View File

@@ -0,0 +1,12 @@
#![allow(dead_code, unused_macros)]
macro_rules! assert_unpin {
($ty:ty) => {
static_assertions::assert_impl_all!($ty: Unpin);
};
}
macro_rules! assert_not_unpin {
($ty:ty) => {
static_assertions::assert_not_impl_all!($ty: Unpin);
};
}

View File

@@ -0,0 +1,184 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
#![allow(dead_code)]
// Refs: https://doc.rust-lang.org/reference/attributes.html
#[macro_use]
mod auxiliary;
use std::{marker::PhantomPinned, pin::Pin};
use pin_project::pin_project;
struct Always;
// Use this type to check that `cfg(any())` is working properly.
struct Never(PhantomPinned);
#[test]
fn cfg() {
// structs
#[pin_project(project_replace)]
struct SameName {
#[cfg(not(any()))]
#[pin]
inner: Always,
#[cfg(any())]
#[pin]
inner: Never,
}
assert_unpin!(SameName);
let _ = SameName { inner: Always };
#[pin_project(project_replace)]
struct DifferentName {
#[cfg(not(any()))]
#[pin]
a: Always,
#[cfg(any())]
#[pin]
n: Never,
}
assert_unpin!(DifferentName);
let _ = DifferentName { a: Always };
#[pin_project(project_replace)]
struct TupleStruct(
#[cfg(not(any()))]
#[pin]
Always,
#[cfg(any())]
#[pin]
Never,
);
assert_unpin!(TupleStruct);
let _ = TupleStruct(Always);
// enums
#[pin_project(
project = VariantProj,
project_ref = VariantProjRef,
project_replace = VariantProjOwn,
)]
enum Variant {
#[cfg(not(any()))]
Inner(#[pin] Always),
#[cfg(any())]
Inner(#[pin] Never),
#[cfg(not(any()))]
A(#[pin] Always),
#[cfg(any())]
N(#[pin] Never),
}
assert_unpin!(Variant);
let _ = Variant::Inner(Always);
let _ = Variant::A(Always);
#[pin_project(
project = FieldProj,
project_ref = FieldProjRef,
project_replace = FieldProjOwn,
)]
enum Field {
SameName {
#[cfg(not(any()))]
#[pin]
inner: Always,
#[cfg(any())]
#[pin]
inner: Never,
},
DifferentName {
#[cfg(not(any()))]
#[pin]
a: Always,
#[cfg(any())]
#[pin]
n: Never,
},
TupleVariant(
#[cfg(not(any()))]
#[pin]
Always,
#[cfg(any())]
#[pin]
Never,
),
}
assert_unpin!(Field);
let _ = Field::SameName { inner: Always };
let _ = Field::DifferentName { a: Always };
let _ = Field::TupleVariant(Always);
}
#[test]
fn cfg_attr() {
#[pin_project(project_replace)]
struct SameCfg {
#[cfg(not(any()))]
#[cfg_attr(not(any()), pin)]
inner: Always,
#[cfg(any())]
#[cfg_attr(any(), pin)]
inner: Never,
}
assert_unpin!(SameCfg);
let mut x = SameCfg { inner: Always };
let x = Pin::new(&mut x).project();
let _: Pin<&mut Always> = x.inner;
#[pin_project(project_replace)]
struct DifferentCfg {
#[cfg(not(any()))]
#[cfg_attr(any(), pin)]
inner: Always,
#[cfg(any())]
#[cfg_attr(not(any()), pin)]
inner: Never,
}
assert_unpin!(DifferentCfg);
let mut x = DifferentCfg { inner: Always };
let x = Pin::new(&mut x).project();
let _: &mut Always = x.inner;
#[cfg_attr(not(any()), pin_project)]
struct Foo<T> {
#[cfg_attr(not(any()), pin)]
inner: T,
}
assert_unpin!(Foo<()>);
assert_not_unpin!(Foo<PhantomPinned>);
let mut x = Foo { inner: 0_u8 };
let x = Pin::new(&mut x).project();
let _: Pin<&mut u8> = x.inner;
}
#[test]
fn cfg_attr_any_packed() {
// Since `cfg(any())` can never be true, it is okay for this to pass.
#[pin_project(project_replace)]
#[cfg_attr(any(), repr(packed))]
struct Struct {
#[pin]
f: u32,
}
}

View File

@@ -0,0 +1,16 @@
#![cfg(not(miri))]
#![warn(rust_2018_idioms, single_use_lifetimes)]
use std::env;
#[rustversion::attr(not(nightly), ignore)]
#[test]
fn ui() {
if env::var_os("CI").is_none() {
env::set_var("TRYBUILD", "overwrite");
}
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/**/*.rs");
t.pass("tests/run-pass/**/*.rs");
}

View File

@@ -0,0 +1,162 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
// Refs: https://doc.rust-lang.org/reference/destructors.html
use std::{cell::Cell, pin::Pin, thread};
use pin_project::pin_project;
struct D<'a>(&'a Cell<usize>, usize);
impl Drop for D<'_> {
fn drop(&mut self) {
if !thread::panicking() {
let old = self.0.replace(self.1);
assert_eq!(old, self.1 - 1);
}
}
}
#[pin_project(project_replace)]
struct StructPinned<'a> {
#[pin]
f1: D<'a>,
#[pin]
f2: D<'a>,
}
#[pin_project(project_replace)]
struct StructUnpinned<'a> {
f1: D<'a>,
f2: D<'a>,
}
#[pin_project(project_replace)]
struct TuplePinned<'a>(#[pin] D<'a>, #[pin] D<'a>);
#[pin_project(project_replace)]
struct TupleUnpinned<'a>(D<'a>, D<'a>);
#[pin_project(project_replace = EnumProj)]
enum Enum<'a> {
#[allow(dead_code)] // false positive that fixed in Rust 1.38
StructPinned {
#[pin]
f1: D<'a>,
#[pin]
f2: D<'a>,
},
#[allow(dead_code)] // false positive that fixed in Rust 1.38
StructUnpinned {
f1: D<'a>,
f2: D<'a>,
},
TuplePinned(#[pin] D<'a>, #[pin] D<'a>),
TupleUnpinned(D<'a>, D<'a>),
}
#[test]
fn struct_pinned() {
{
let c = Cell::new(0);
let _x = StructPinned { f1: D(&c, 1), f2: D(&c, 2) };
}
{
let c = Cell::new(0);
let mut x = StructPinned { f1: D(&c, 1), f2: D(&c, 2) };
let y = Pin::new(&mut x);
let _z = y.project_replace(StructPinned { f1: D(&c, 3), f2: D(&c, 4) });
}
}
#[test]
fn struct_unpinned() {
{
let c = Cell::new(0);
let _x = StructUnpinned { f1: D(&c, 1), f2: D(&c, 2) };
}
{
let c = Cell::new(0);
let mut x = StructUnpinned { f1: D(&c, 1), f2: D(&c, 2) };
let y = Pin::new(&mut x);
let _z = y.project_replace(StructUnpinned { f1: D(&c, 3), f2: D(&c, 4) });
}
}
#[test]
fn tuple_pinned() {
{
let c = Cell::new(0);
let _x = TuplePinned(D(&c, 1), D(&c, 2));
}
{
let c = Cell::new(0);
let mut x = TuplePinned(D(&c, 1), D(&c, 2));
let y = Pin::new(&mut x);
let _z = y.project_replace(TuplePinned(D(&c, 3), D(&c, 4)));
}
}
#[test]
fn tuple_unpinned() {
{
let c = Cell::new(0);
let _x = TupleUnpinned(D(&c, 1), D(&c, 2));
}
{
let c = Cell::new(0);
let mut x = TupleUnpinned(D(&c, 1), D(&c, 2));
let y = Pin::new(&mut x);
let _z = y.project_replace(TupleUnpinned(D(&c, 3), D(&c, 4)));
}
}
#[test]
fn enum_struct() {
{
let c = Cell::new(0);
let _x = Enum::StructPinned { f1: D(&c, 1), f2: D(&c, 2) };
}
{
let c = Cell::new(0);
let mut x = Enum::StructPinned { f1: D(&c, 1), f2: D(&c, 2) };
let y = Pin::new(&mut x);
let _z = y.project_replace(Enum::StructPinned { f1: D(&c, 3), f2: D(&c, 4) });
}
{
let c = Cell::new(0);
let _x = Enum::StructUnpinned { f1: D(&c, 1), f2: D(&c, 2) };
}
{
let c = Cell::new(0);
let mut x = Enum::StructUnpinned { f1: D(&c, 1), f2: D(&c, 2) };
let y = Pin::new(&mut x);
let _z = y.project_replace(Enum::StructUnpinned { f1: D(&c, 3), f2: D(&c, 4) });
}
}
#[test]
fn enum_tuple() {
{
let c = Cell::new(0);
let _x = Enum::TuplePinned(D(&c, 1), D(&c, 2));
}
{
let c = Cell::new(0);
let mut x = Enum::TuplePinned(D(&c, 1), D(&c, 2));
let y = Pin::new(&mut x);
let _z = y.project_replace(Enum::TuplePinned(D(&c, 3), D(&c, 4)));
}
{
let c = Cell::new(0);
let _x = Enum::TupleUnpinned(D(&c, 1), D(&c, 2));
}
{
let c = Cell::new(0);
let mut x = Enum::TupleUnpinned(D(&c, 1), D(&c, 2));
let y = Pin::new(&mut x);
let _z = y.project_replace(Enum::TupleUnpinned(D(&c, 3), D(&c, 4)));
}
}

View File

@@ -0,0 +1,145 @@
use pin_project::pin_project;
#[pin(__private(project = EnumProj, project_ref = EnumProjRef))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
enum EnumProj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
},
Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
enum EnumProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> EnumProj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Struct { pinned, unpinned } => {
EnumProj::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProj::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProj::Unit,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> EnumProjRef<'pin, T, U> {
unsafe {
match self.get_ref() {
Self::Struct { pinned, unpinned } => {
EnumProjRef::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProjRef::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProjRef::Unit,
}
}
}
}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project(project = EnumProj, project_ref = EnumProjRef)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,104 @@
use pin_project::pin_project;
#[pin(__private())]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,98 @@
use pin_project::pin_project;
#[pin(__private())]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project]
struct TupleStruct<T, U>(#[pin] T, U);
fn main() {}

View File

@@ -0,0 +1,268 @@
use pin_project::pin_project;
#[pin(
__private(
project = EnumProj,
project_ref = EnumProjRef,
project_replace = EnumProjOwn
)
)]
enum Enum<T, U> {
Struct { #[pin] pinned1: T, #[pin] pinned2: T, unpinned1: U, unpinned2: U },
Tuple(#[pin] T, #[pin] T, U, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
enum EnumProj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned1: ::pin_project::__private::Pin<&'pin mut (T)>,
pinned2: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned1: &'pin mut (U),
unpinned2: &'pin mut (U),
},
Tuple(
::pin_project::__private::Pin<&'pin mut (T)>,
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
&'pin mut (U),
),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
enum EnumProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned1: ::pin_project::__private::Pin<&'pin (T)>,
pinned2: ::pin_project::__private::Pin<&'pin (T)>,
unpinned1: &'pin (U),
unpinned2: &'pin (U),
},
Tuple(
::pin_project::__private::Pin<&'pin (T)>,
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
&'pin (U),
),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(variant_size_differences)]
#[allow(clippy::large_enum_variant)]
enum EnumProjOwn<T, U> {
Struct {
pinned1: ::pin_project::__private::PhantomData<T>,
pinned2: ::pin_project::__private::PhantomData<T>,
unpinned1: U,
unpinned2: U,
},
Tuple(
::pin_project::__private::PhantomData<T>,
::pin_project::__private::PhantomData<T>,
U,
U,
),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> EnumProj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Struct { pinned1, pinned2, unpinned1, unpinned2 } => {
EnumProj::Struct {
pinned1: _pin_project::__private::Pin::new_unchecked(
pinned1,
),
pinned2: _pin_project::__private::Pin::new_unchecked(
pinned2,
),
unpinned1,
unpinned2,
}
}
Self::Tuple(_0, _1, _2, _3) => {
EnumProj::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_pin_project::__private::Pin::new_unchecked(_1),
_2,
_3,
)
}
Self::Unit => EnumProj::Unit,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> EnumProjRef<'pin, T, U> {
unsafe {
match self.get_ref() {
Self::Struct { pinned1, pinned2, unpinned1, unpinned2 } => {
EnumProjRef::Struct {
pinned1: _pin_project::__private::Pin::new_unchecked(
pinned1,
),
pinned2: _pin_project::__private::Pin::new_unchecked(
pinned2,
),
unpinned1,
unpinned2,
}
}
Self::Tuple(_0, _1, _2, _3) => {
EnumProjRef::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_pin_project::__private::Pin::new_unchecked(_1),
_2,
_3,
)
}
Self::Unit => EnumProjRef::Unit,
}
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> EnumProjOwn<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
match &mut *__self_ptr {
Self::Struct { pinned1, pinned2, unpinned1, unpinned2 } => {
let __result = EnumProjOwn::Struct {
pinned1: _pin_project::__private::PhantomData,
pinned2: _pin_project::__private::PhantomData,
unpinned1: _pin_project::__private::ptr::read(unpinned1),
unpinned2: _pin_project::__private::ptr::read(unpinned2),
};
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned2,
);
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned1,
);
}
__result
}
Self::Tuple(_0, _1, _2, _3) => {
let __result = EnumProjOwn::Tuple(
_pin_project::__private::PhantomData,
_pin_project::__private::PhantomData,
_pin_project::__private::ptr::read(_2),
_pin_project::__private::ptr::read(_3),
);
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_1,
);
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_0,
);
}
__result
}
Self::Unit => {
let __result = EnumProjOwn::Unit;
{}
__result
}
}
}
}
}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
__field2: T,
__field3: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,17 @@
use pin_project::pin_project;
#[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
enum Enum<T, U> {
Struct {
#[pin]
pinned1: T,
#[pin]
pinned2: T,
unpinned1: U,
unpinned2: U,
},
Tuple(#[pin] T, #[pin] T, U, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,155 @@
use pin_project::pin_project;
#[pin(__private(project_replace))]
struct Struct<T, U> {
#[pin]
pinned1: T,
#[pin]
pinned2: T,
unpinned1: U,
unpinned2: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned1: ::pin_project::__private::Pin<&'pin mut (T)>,
pinned2: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned1: &'pin mut (U),
unpinned2: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned1: ::pin_project::__private::Pin<&'pin (T)>,
pinned2: ::pin_project::__private::Pin<&'pin (T)>,
unpinned1: &'pin (U),
unpinned2: &'pin (U),
}
#[allow(dead_code)]
struct __StructProjectionOwned<T, U> {
pinned1: ::pin_project::__private::PhantomData<T>,
pinned2: ::pin_project::__private::PhantomData<T>,
unpinned1: U,
unpinned2: U,
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned1, pinned2, unpinned1, unpinned2 } = self
.get_unchecked_mut();
__StructProjection {
pinned1: _pin_project::__private::Pin::new_unchecked(pinned1),
pinned2: _pin_project::__private::Pin::new_unchecked(pinned2),
unpinned1,
unpinned2,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned1, pinned2, unpinned1, unpinned2 } = self.get_ref();
__StructProjectionRef {
pinned1: _pin_project::__private::Pin::new_unchecked(pinned1),
pinned2: _pin_project::__private::Pin::new_unchecked(pinned2),
unpinned1,
unpinned2,
}
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> __StructProjectionOwned<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
let Self { pinned1, pinned2, unpinned1, unpinned2 } = &mut *__self_ptr;
let __result = __StructProjectionOwned {
pinned1: _pin_project::__private::PhantomData,
pinned2: _pin_project::__private::PhantomData,
unpinned1: _pin_project::__private::ptr::read(unpinned1),
unpinned2: _pin_project::__private::ptr::read(unpinned2),
};
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned2,
);
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned1,
);
}
__result
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned1;
let _ = &this.pinned2;
let _ = &this.unpinned1;
let _ = &this.unpinned2;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,13 @@
use pin_project::pin_project;
#[pin_project(project_replace)]
struct Struct<T, U> {
#[pin]
pinned1: T,
#[pin]
pinned2: T,
unpinned1: U,
unpinned2: U,
}
fn main() {}

View File

@@ -0,0 +1,145 @@
use pin_project::pin_project;
#[pin(__private(project_replace))]
struct TupleStruct<T, U>(#[pin] T, #[pin] T, U, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
struct __TupleStructProjectionOwned<T, U>(
::pin_project::__private::PhantomData<T>,
::pin_project::__private::PhantomData<T>,
U,
U,
);
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1, _2, _3) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_pin_project::__private::Pin::new_unchecked(_1),
_2,
_3,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1, _2, _3) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_pin_project::__private::Pin::new_unchecked(_1),
_2,
_3,
)
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> __TupleStructProjectionOwned<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
let Self(_0, _1, _2, _3) = &mut *__self_ptr;
let __result = __TupleStructProjectionOwned(
_pin_project::__private::PhantomData,
_pin_project::__private::PhantomData,
_pin_project::__private::ptr::read(_2),
_pin_project::__private::ptr::read(_3),
);
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_1,
);
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_0,
);
}
__result
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
let _ = &this.2;
let _ = &this.3;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project(project_replace)]
struct TupleStruct<T, U>(#[pin] T, #[pin] T, U, U);
fn main() {}

View File

@@ -0,0 +1,204 @@
use pin_project::pin_project;
#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
enum Proj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
},
Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
enum ProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(variant_size_differences)]
#[allow(clippy::large_enum_variant)]
enum ProjOwn<T, U> {
Struct { pinned: ::pin_project::__private::PhantomData<T>, unpinned: U },
Tuple(::pin_project::__private::PhantomData<T>, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> Proj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Struct { pinned, unpinned } => {
Proj::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
Proj::Tuple(_pin_project::__private::Pin::new_unchecked(_0), _1)
}
Self::Unit => Proj::Unit,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> ProjRef<'pin, T, U> {
unsafe {
match self.get_ref() {
Self::Struct { pinned, unpinned } => {
ProjRef::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
ProjRef::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => ProjRef::Unit,
}
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> ProjOwn<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
match &mut *__self_ptr {
Self::Struct { pinned, unpinned } => {
let __result = ProjOwn::Struct {
pinned: _pin_project::__private::PhantomData,
unpinned: _pin_project::__private::ptr::read(unpinned),
};
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned,
);
}
__result
}
Self::Tuple(_0, _1) => {
let __result = ProjOwn::Tuple(
_pin_project::__private::PhantomData,
_pin_project::__private::ptr::read(_1),
);
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_0,
);
}
__result
}
Self::Unit => {
let __result = ProjOwn::Unit;
{}
__result
}
}
}
}
}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project(project = Proj, project_ref = ProjRef, project_replace = ProjOwn)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,99 @@
use pin_project::pin_project;
#[pin(__private(project = Proj))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
enum Proj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
},
Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> Proj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Struct { pinned, unpinned } => {
Proj::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
Proj::Tuple(_pin_project::__private::Pin::new_unchecked(_0), _1)
}
Self::Unit => Proj::Unit,
}
}
}
}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project(project = Proj)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,56 @@
use pin_project::pin_project;
#[pin(__private())]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,119 @@
use pin_project::pin_project;
#[pin(__private(project_replace = ProjOwn))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(variant_size_differences)]
#[allow(clippy::large_enum_variant)]
enum ProjOwn<T, U> {
Struct { pinned: ::pin_project::__private::PhantomData<T>, unpinned: U },
Tuple(::pin_project::__private::PhantomData<T>, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> ProjOwn<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
match &mut *__self_ptr {
Self::Struct { pinned, unpinned } => {
let __result = ProjOwn::Struct {
pinned: _pin_project::__private::PhantomData,
unpinned: _pin_project::__private::ptr::read(unpinned),
};
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned,
);
}
__result
}
Self::Tuple(_0, _1) => {
let __result = ProjOwn::Tuple(
_pin_project::__private::PhantomData,
_pin_project::__private::ptr::read(_1),
);
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_0,
);
}
__result
}
Self::Unit => {
let __result = ProjOwn::Unit;
{}
__result
}
}
}
}
}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project(project_replace = ProjOwn)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,100 @@
use pin_project::pin_project;
#[pin(__private(project_ref = ProjRef))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
enum ProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> ProjRef<'pin, T, U> {
unsafe {
match self.get_ref() {
Self::Struct { pinned, unpinned } => {
ProjRef::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
ProjRef::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => ProjRef::Unit,
}
}
}
}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project(project_ref = ProjRef)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,163 @@
use pin_project::pin_project;
#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct Proj<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct ProjRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
struct ProjOwn<T, U> {
pinned: ::pin_project::__private::PhantomData<T>,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> Proj<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
Proj {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> ProjRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
ProjRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> ProjOwn<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
let Self { pinned, unpinned } = &mut *__self_ptr;
let __result = ProjOwn {
pinned: _pin_project::__private::PhantomData,
unpinned: _pin_project::__private::ptr::read(unpinned),
};
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned,
);
}
__result
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project(project = Proj, project_ref = ProjRef, project_replace = ProjOwn)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,114 @@
use pin_project::pin_project;
#[pin(__private(project = Proj))]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct Proj<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> Proj<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
Proj {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project(project = Proj)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,104 @@
use pin_project::pin_project;
#[pin(__private())]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,143 @@
use pin_project::pin_project;
#[pin(__private(project_replace = ProjOwn))]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
struct ProjOwn<T, U> {
pinned: ::pin_project::__private::PhantomData<T>,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> ProjOwn<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
let Self { pinned, unpinned } = &mut *__self_ptr;
let __result = ProjOwn {
pinned: _pin_project::__private::PhantomData,
unpinned: _pin_project::__private::ptr::read(unpinned),
};
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned,
);
}
__result
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project(project_replace = ProjOwn)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,114 @@
use pin_project::pin_project;
#[pin(__private(project_ref = ProjRef))]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct ProjRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> ProjRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
ProjRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project(project_ref = ProjRef)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,148 @@
use pin_project::pin_project;
#[pin(__private(project = Proj, project_ref = ProjRef, project_replace = ProjOwn))]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct Proj<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct ProjRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
struct ProjOwn<T, U>(::pin_project::__private::PhantomData<T>, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> Proj<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
Proj(_pin_project::__private::Pin::new_unchecked(_0), _1)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> ProjRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
ProjRef(_pin_project::__private::Pin::new_unchecked(_0), _1)
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> ProjOwn<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
let Self(_0, _1) = &mut *__self_ptr;
let __result = ProjOwn(
_pin_project::__private::PhantomData,
_pin_project::__private::ptr::read(_1),
);
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_0,
);
}
__result
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project(project = Proj, project_ref = ProjRef, project_replace = ProjOwn)]
struct TupleStruct<T, U>(#[pin] T, U);
fn main() {}

View File

@@ -0,0 +1,105 @@
use pin_project::pin_project;
#[pin(__private(project = Proj))]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct Proj<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> Proj<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
Proj(_pin_project::__private::Pin::new_unchecked(_0), _1)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project(project = Proj)]
struct TupleStruct<T, U>(#[pin] T, U);
fn main() {}

View File

@@ -0,0 +1,98 @@
use pin_project::pin_project;
#[pin(__private())]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project]
struct TupleStruct<T, U>(#[pin] T, U);
fn main() {}

View File

@@ -0,0 +1,134 @@
use pin_project::pin_project;
#[pin(__private(project_replace = ProjOwn))]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
struct ProjOwn<T, U>(::pin_project::__private::PhantomData<T>, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> ProjOwn<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
let Self(_0, _1) = &mut *__self_ptr;
let __result = ProjOwn(
_pin_project::__private::PhantomData,
_pin_project::__private::ptr::read(_1),
);
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_0,
);
}
__result
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project(project_replace = ProjOwn)]
struct TupleStruct<T, U>(#[pin] T, U);
fn main() {}

View File

@@ -0,0 +1,105 @@
use pin_project::pin_project;
#[pin(__private(project_ref = ProjRef))]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct ProjRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> ProjRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
ProjRef(_pin_project::__private::Pin::new_unchecked(_0), _1)
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project(project_ref = ProjRef)]
struct TupleStruct<T, U>(#[pin] T, U);
fn main() {}

View File

@@ -0,0 +1,139 @@
use pin_project::pin_project;
#[pin(__private(!Unpin, project = EnumProj, project_ref = EnumProjRef))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
enum EnumProj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
},
Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
enum EnumProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> EnumProj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Struct { pinned, unpinned } => {
EnumProj::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProj::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProj::Unit,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> EnumProjRef<'pin, T, U> {
unsafe {
match self.get_ref() {
Self::Struct { pinned, unpinned } => {
EnumProjRef::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProjRef::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProjRef::Unit,
}
}
}
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
_pin_project::__private::Wrapper<
'pin,
_pin_project::__private::PhantomPinned,
>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
_pin_project::__private::Wrapper<
'pin,
_pin_project::__private::PhantomPinned,
>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project(!Unpin, project = EnumProj, project_ref = EnumProjRef)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,99 @@
use pin_project::pin_project;
#[pin(__private(!Unpin))]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
_pin_project::__private::Wrapper<
'pin,
_pin_project::__private::PhantomPinned,
>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
_pin_project::__private::Wrapper<
'pin,
_pin_project::__private::PhantomPinned,
>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project(!Unpin)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,93 @@
use pin_project::pin_project;
#[pin(__private(!Unpin))]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
_pin_project::__private::Wrapper<
'pin,
_pin_project::__private::PhantomPinned,
>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
_pin_project::__private::Wrapper<
'pin,
_pin_project::__private::PhantomPinned,
>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project(!Unpin)]
struct TupleStruct<T, U>(#[pin] T, U);
fn main() {}

View File

@@ -0,0 +1,157 @@
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin(__private(PinnedDrop, project = EnumProj, project_ref = EnumProjRef))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
enum EnumProj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
},
Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
enum EnumProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> EnumProj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Struct { pinned, unpinned } => {
EnumProj::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProj::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProj::Unit,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> EnumProjRef<'pin, T, U> {
unsafe {
match self.get_ref() {
Self::Struct { pinned, unpinned } => {
EnumProjRef::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProjRef::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProjRef::Unit,
}
}
}
}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
impl<T, U> _pin_project::__private::Drop for Enum<T, U> {
fn drop(&mut self) {
unsafe {
let __pinned_self = _pin_project::__private::Pin::new_unchecked(self);
_pin_project::__private::PinnedDrop::drop(__pinned_self);
}
}
}
};
#[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: Pin<&mut Self>) {
#[allow(clippy::needless_pass_by_value)]
fn __drop_inner<T, U>(__self: Pin<&mut Enum<T, U>>) {
fn __drop_inner() {}
let _ = __self;
}
__drop_inner(self);
}
}
fn main() {}

View File

@@ -0,0 +1,23 @@
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop, project = EnumProj, project_ref = EnumProjRef)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
#[pinned_drop]
impl<T, U> PinnedDrop for Enum<T, U> {
fn drop(self: Pin<&mut Self>) {
let _ = self;
}
}
fn main() {}

View File

@@ -0,0 +1,116 @@
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin(__private(PinnedDrop))]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
impl<T, U> _pin_project::__private::Drop for Struct<T, U> {
fn drop(&mut self) {
unsafe {
let __pinned_self = _pin_project::__private::Pin::new_unchecked(self);
_pin_project::__private::PinnedDrop::drop(__pinned_self);
}
}
}
};
#[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: Pin<&mut Self>) {
#[allow(clippy::needless_pass_by_value)]
fn __drop_inner<T, U>(__self: Pin<&mut Struct<T, U>>) {
fn __drop_inner() {}
let _ = __self;
}
__drop_inner(self);
}
}
fn main() {}

View File

@@ -0,0 +1,19 @@
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[pinned_drop]
impl<T, U> PinnedDrop for Struct<T, U> {
fn drop(self: Pin<&mut Self>) {
let _ = self;
}
}
fn main() {}

View File

@@ -0,0 +1,110 @@
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin(__private(PinnedDrop))]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
impl<T, U> _pin_project::__private::Drop for TupleStruct<T, U> {
fn drop(&mut self) {
unsafe {
let __pinned_self = _pin_project::__private::Pin::new_unchecked(self);
_pin_project::__private::PinnedDrop::drop(__pinned_self);
}
}
}
};
#[doc(hidden)]
impl<T, U> ::pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: Pin<&mut Self>) {
#[allow(clippy::needless_pass_by_value)]
fn __drop_inner<T, U>(__self: Pin<&mut TupleStruct<T, U>>) {
fn __drop_inner() {}
let _ = __self;
}
__drop_inner(self);
}
}
fn main() {}

View File

@@ -0,0 +1,15 @@
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[pin_project(PinnedDrop)]
struct TupleStruct<T, U>(#[pin] T, U);
#[pinned_drop]
impl<T, U> PinnedDrop for TupleStruct<T, U> {
fn drop(self: Pin<&mut Self>) {
let _ = self;
}
}
fn main() {}

View File

@@ -0,0 +1,119 @@
use pin_project::pin_project;
#[pin(__private(project_replace = EnumProjOwn))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(variant_size_differences)]
#[allow(clippy::large_enum_variant)]
enum EnumProjOwn<T, U> {
Struct { pinned: ::pin_project::__private::PhantomData<T>, unpinned: U },
Tuple(::pin_project::__private::PhantomData<T>, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> EnumProjOwn<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
match &mut *__self_ptr {
Self::Struct { pinned, unpinned } => {
let __result = EnumProjOwn::Struct {
pinned: _pin_project::__private::PhantomData,
unpinned: _pin_project::__private::ptr::read(unpinned),
};
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned,
);
}
__result
}
Self::Tuple(_0, _1) => {
let __result = EnumProjOwn::Tuple(
_pin_project::__private::PhantomData,
_pin_project::__private::ptr::read(_1),
);
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_0,
);
}
__result
}
Self::Unit => {
let __result = EnumProjOwn::Unit;
{}
__result
}
}
}
}
}
#[allow(missing_debug_implementations)]
struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project(project_replace = EnumProjOwn)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,133 @@
use pin_project::pin_project;
#[pin(__private(project_replace))]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
#[allow(dead_code)]
struct __StructProjectionOwned<T, U> {
pinned: ::pin_project::__private::PhantomData<T>,
unpinned: U,
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> __StructProjectionOwned<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
let Self { pinned, unpinned } = &mut *__self_ptr;
let __result = __StructProjectionOwned {
pinned: _pin_project::__private::PhantomData,
unpinned: _pin_project::__private::ptr::read(unpinned),
};
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
pinned,
);
}
__result
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project(project_replace)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,127 @@
use pin_project::pin_project;
#[pin(__private(project_replace))]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
struct __TupleStructProjectionOwned<T, U>(
::pin_project::__private::PhantomData<T>,
U,
);
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
fn project_replace(
self: _pin_project::__private::Pin<&mut Self>,
__replacement: Self,
) -> __TupleStructProjectionOwned<T, U> {
unsafe {
let __self_ptr: *mut Self = self.get_unchecked_mut();
let __guard = _pin_project::__private::UnsafeOverwriteGuard::new(
__self_ptr,
__replacement,
);
let Self(_0, _1) = &mut *__self_ptr;
let __result = __TupleStructProjectionOwned(
_pin_project::__private::PhantomData,
_pin_project::__private::ptr::read(_1),
);
{
let __guard = _pin_project::__private::UnsafeDropInPlaceGuard::new(
_0,
);
}
__result
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project(project_replace)]
struct TupleStruct<T, U>(#[pin] T, U);
fn main() {}

View File

@@ -0,0 +1,145 @@
use pin_project::pin_project;
#[pin(__private(project = EnumProj, project_ref = EnumProjRef))]
pub enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
pub(crate) enum EnumProj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
},
Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
pub(crate) enum EnumProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
pub(crate) fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> EnumProj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Struct { pinned, unpinned } => {
EnumProj::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProj::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProj::Unit,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
pub(crate) fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> EnumProjRef<'pin, T, U> {
unsafe {
match self.get_ref() {
Self::Struct { pinned, unpinned } => {
EnumProjRef::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProjRef::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProjRef::Unit,
}
}
}
}
#[allow(missing_debug_implementations)]
pub struct __Enum<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
__field1: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Enum<T, U>
where
__Enum<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,14 @@
use pin_project::pin_project;
#[pin_project(project = EnumProj, project_ref = EnumProjRef)]
pub enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
fn main() {}

View File

@@ -0,0 +1,104 @@
use pin_project::pin_project;
#[pin(__private())]
pub struct Struct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
pub(crate) struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pub pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
pub unpinned: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
pub(crate) struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pub pinned: ::pin_project::__private::Pin<&'pin (T)>,
pub unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
pub(crate) fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
pub(crate) fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
#[allow(missing_debug_implementations)]
pub struct __Struct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for Struct<T, U>
where
__Struct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,10 @@
use pin_project::pin_project;
#[pin_project]
pub struct Struct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
fn main() {}

View File

@@ -0,0 +1,98 @@
use pin_project::pin_project;
#[pin(__private())]
pub struct TupleStruct<T, U>(#[pin] pub T, pub U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
pub(crate) struct __TupleStructProjection<'pin, T, U>(
pub ::pin_project::__private::Pin<&'pin mut (T)>,
pub &'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
pub(crate) struct __TupleStructProjectionRef<'pin, T, U>(
pub ::pin_project::__private::Pin<&'pin (T)>,
pub &'pin (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
pub(crate) fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
pub(crate) fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
#[allow(missing_debug_implementations)]
pub struct __TupleStruct<'pin, T, U> {
__pin_project_use_generics: _pin_project::__private::AlwaysUnpin<
'pin,
(
_pin_project::__private::PhantomData<T>,
_pin_project::__private::PhantomData<U>,
),
>,
__field0: T,
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
#[doc(hidden)]
unsafe impl<'pin, T, U> _pin_project::UnsafeUnpin for TupleStruct<T, U>
where
__TupleStruct<'pin, T, U>: _pin_project::__private::Unpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
fn main() {}

View File

@@ -0,0 +1,6 @@
use pin_project::pin_project;
#[pin_project]
pub struct TupleStruct<T, U>(#[pin] pub T, pub U);
fn main() {}

View File

@@ -0,0 +1,129 @@
use pin_project::{pin_project, UnsafeUnpin};
#[pin(__private(UnsafeUnpin, project = EnumProj, project_ref = EnumProjRef))]
enum Enum<T, U> {
Struct { #[pin] pinned: T, unpinned: U },
Tuple(#[pin] T, U),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
enum EnumProj<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct {
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
},
Tuple(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
enum EnumProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
{
Struct { pinned: ::pin_project::__private::Pin<&'pin (T)>, unpinned: &'pin (U) },
Tuple(::pin_project::__private::Pin<&'pin (T)>, &'pin (U)),
Unit,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
impl<T, U> Enum<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> EnumProj<'pin, T, U> {
unsafe {
match self.get_unchecked_mut() {
Self::Struct { pinned, unpinned } => {
EnumProj::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProj::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProj::Unit,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> EnumProjRef<'pin, T, U> {
unsafe {
match self.get_ref() {
Self::Struct { pinned, unpinned } => {
EnumProjRef::Struct {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
Self::Tuple(_0, _1) => {
EnumProjRef::Tuple(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
Self::Unit => EnumProjRef::Unit,
}
}
}
}
impl<'pin, T, U> _pin_project::__private::Unpin for Enum<T, U>
where
_pin_project::__private::Wrapper<'pin, Self>: _pin_project::UnsafeUnpin,
{}
trait EnumMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> EnumMustNotImplDrop for T {}
impl<T, U> EnumMustNotImplDrop for Enum<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Enum<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
unsafe impl<T: Unpin, U> UnsafeUnpin for Enum<T, U> {}
fn main() {}

View File

@@ -0,0 +1,16 @@
use pin_project::{pin_project, UnsafeUnpin};
#[pin_project(UnsafeUnpin, project = EnumProj, project_ref = EnumProjRef)]
enum Enum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
unsafe impl<T: Unpin, U> UnsafeUnpin for Enum<T, U> {}
fn main() {}

View File

@@ -0,0 +1,89 @@
use pin_project::{pin_project, UnsafeUnpin};
#[pin(__private(UnsafeUnpin))]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin mut (T)>,
unpinned: &'pin mut (U),
}
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
{
pinned: ::pin_project::__private::Pin<&'pin (T)>,
unpinned: &'pin (U),
}
impl<T, U> Struct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __StructProjection<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_unchecked_mut();
__StructProjection {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __StructProjectionRef<'pin, T, U> {
unsafe {
let Self { pinned, unpinned } = self.get_ref();
__StructProjectionRef {
pinned: _pin_project::__private::Pin::new_unchecked(pinned),
unpinned,
}
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
let _ = &this.pinned;
let _ = &this.unpinned;
}
impl<'pin, T, U> _pin_project::__private::Unpin for Struct<T, U>
where
_pin_project::__private::Wrapper<'pin, Self>: _pin_project::UnsafeUnpin,
{}
trait StructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> StructMustNotImplDrop for T {}
impl<T, U> StructMustNotImplDrop for Struct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for Struct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
fn main() {}

View File

@@ -0,0 +1,12 @@
use pin_project::{pin_project, UnsafeUnpin};
#[pin_project(UnsafeUnpin)]
struct Struct<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
fn main() {}

View File

@@ -0,0 +1,83 @@
use pin_project::{pin_project, UnsafeUnpin};
#[pin(__private(UnsafeUnpin))]
struct TupleStruct<T, U>(#[pin] T, U);
#[allow(box_pointers)]
#[allow(deprecated)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(unreachable_pub)]
#[allow(unused_tuple_struct_fields)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(unused_qualifications)]
#[allow(clippy::semicolon_if_nothing_returned)]
#[allow(clippy::use_self)]
#[allow(clippy::used_underscore_binding)]
const _: () = {
#[allow(unused_extern_crates)]
extern crate pin_project as _pin_project;
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
)
where
TupleStruct<T, U>: 'pin;
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
)
where
TupleStruct<T, U>: 'pin;
impl<T, U> TupleStruct<T, U> {
#[allow(dead_code)]
fn project<'pin>(
self: _pin_project::__private::Pin<&'pin mut Self>,
) -> __TupleStructProjection<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_unchecked_mut();
__TupleStructProjection(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
#[allow(dead_code)]
#[allow(clippy::missing_const_for_fn)]
fn project_ref<'pin>(
self: _pin_project::__private::Pin<&'pin Self>,
) -> __TupleStructProjectionRef<'pin, T, U> {
unsafe {
let Self(_0, _1) = self.get_ref();
__TupleStructProjectionRef(
_pin_project::__private::Pin::new_unchecked(_0),
_1,
)
}
}
}
#[forbid(unaligned_references, safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &TupleStruct<T, U>) {
let _ = &this.0;
let _ = &this.1;
}
impl<'pin, T, U> _pin_project::__private::Unpin for TupleStruct<T, U>
where
_pin_project::__private::Wrapper<'pin, Self>: _pin_project::UnsafeUnpin,
{}
trait TupleStructMustNotImplDrop {}
#[allow(clippy::drop_bounds, drop_bounds)]
impl<T: _pin_project::__private::Drop> TupleStructMustNotImplDrop for T {}
impl<T, U> TupleStructMustNotImplDrop for TupleStruct<T, U> {}
#[doc(hidden)]
impl<T, U> _pin_project::__private::PinnedDrop for TupleStruct<T, U> {
unsafe fn drop(self: _pin_project::__private::Pin<&mut Self>) {}
}
};
unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
fn main() {}

View File

@@ -0,0 +1,8 @@
use pin_project::{pin_project, UnsafeUnpin};
#[pin_project(UnsafeUnpin)]
struct TupleStruct<T, U>(#[pin] T, U);
unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
fn main() {}

View File

@@ -0,0 +1,43 @@
#![cfg(not(miri))]
#![warn(rust_2018_idioms, single_use_lifetimes)]
use std::{
env,
process::{Command, ExitStatus, Stdio},
};
const PATH: &str = "tests/expand/**/*.rs";
#[rustversion::attr(not(nightly), ignore)]
#[test]
fn expandtest() {
let is_ci = env::var_os("CI").is_some();
let cargo = &*env::var("CARGO").unwrap_or_else(|_| "cargo".into());
if !has_command(&[cargo, "expand"]) {
if is_ci {
panic!("expandtest requires cargo-expand");
}
return;
}
let args = &["--all-features"];
if is_ci {
macrotest::expand_without_refresh_args(PATH, args);
} else {
env::set_var("MACROTEST", "overwrite");
macrotest::expand_args(PATH, args);
}
}
fn has_command(command: &[&str]) -> bool {
Command::new(command[0])
.args(&command[1..])
.arg("--version")
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
.as_ref()
.map(ExitStatus::success)
.unwrap_or(false)
}

View File

@@ -0,0 +1,193 @@
// default #[pin_project], PinnedDrop, project_replace, !Unpin, and UnsafeUnpin without UnsafeUnpin impl are completely safe.
#[::pin_project::pin_project]
#[derive(Debug)]
pub struct DefaultStruct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
#[::pin_project::pin_project(
project = DefaultStructNamedProj,
project_ref = DefaultStructNamedProjRef,
)]
#[derive(Debug)]
pub struct DefaultStructNamed<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
#[::pin_project::pin_project]
#[derive(Debug)]
pub struct DefaultTupleStruct<T, U>(#[pin] pub T, pub U);
#[::pin_project::pin_project(
project = DefaultTupleStructNamedProj,
project_ref = DefaultTupleStructNamedProjRef,
)]
#[derive(Debug)]
pub struct DefaultTupleStructNamed<T, U>(#[pin] pub T, pub U);
#[::pin_project::pin_project(
project = DefaultEnumProj,
project_ref = DefaultEnumProjRef,
)]
#[derive(Debug)]
pub enum DefaultEnum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
#[::pin_project::pin_project(PinnedDrop)]
#[derive(Debug)]
pub struct PinnedDropStruct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
#[::pin_project::pinned_drop]
impl<T, U> PinnedDrop for PinnedDropStruct<T, U> {
fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[::pin_project::pin_project(PinnedDrop)]
#[derive(Debug)]
pub struct PinnedDropTupleStruct<T, U>(#[pin] pub T, pub U);
#[::pin_project::pinned_drop]
impl<T, U> PinnedDrop for PinnedDropTupleStruct<T, U> {
fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[::pin_project::pin_project(
PinnedDrop,
project = PinnedDropEnumProj,
project_ref = PinnedDropEnumProjRef,
)]
#[derive(Debug)]
pub enum PinnedDropEnum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
#[::pin_project::pinned_drop]
impl<T, U> PinnedDrop for PinnedDropEnum<T, U> {
fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}
#[::pin_project::pin_project(project_replace)]
#[derive(Debug)]
pub struct ReplaceStruct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
#[::pin_project::pin_project(
project = ReplaceStructNamedProj,
project_ref = ReplaceStructNamedProjRef,
project_replace = ReplaceStructNamedProjOwn,
)]
#[derive(Debug)]
pub struct ReplaceStructNamed<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
#[::pin_project::pin_project(project_replace)]
#[derive(Debug)]
pub struct ReplaceTupleStruct<T, U>(#[pin] pub T, pub U);
#[::pin_project::pin_project(
project = ReplaceTupleStructNamedProj,
project_ref = ReplaceTupleStructNamedProjRef,
project_replace = ReplaceTupleStructNamedProjOwn,
)]
#[derive(Debug)]
pub struct ReplaceTupleStructNamed<T, U>(#[pin] pub T, pub U);
#[::pin_project::pin_project(
project = ReplaceEnumProj,
project_ref = ReplaceEnumProjRef,
project_replace = ReplaceEnumProjOwn,
)]
#[derive(Debug)]
pub enum ReplaceEnum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
#[::pin_project::pin_project(UnsafeUnpin)]
#[derive(Debug)]
pub struct UnsafeUnpinStruct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
#[::pin_project::pin_project(UnsafeUnpin)]
#[derive(Debug)]
pub struct UnsafeUnpinTupleStruct<T, U>(#[pin] pub T, pub U);
#[::pin_project::pin_project(
UnsafeUnpin,
project = UnsafeUnpinEnumProj,
project_ref = UnsafeUnpinEnumProjRef,
)]
#[derive(Debug)]
pub enum UnsafeUnpinEnum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}
#[::pin_project::pin_project(!Unpin)]
#[derive(Debug)]
pub struct NotUnpinStruct<T, U> {
#[pin]
pub pinned: T,
pub unpinned: U,
}
#[::pin_project::pin_project(!Unpin)]
#[derive(Debug)]
pub struct NotUnpinTupleStruct<T, U>(#[pin] pub T, pub U);
#[::pin_project::pin_project(
!Unpin,
project = NotUnpinEnumProj,
project_ref = NotUnpinEnumProjRef,
)]
#[derive(Debug)]
pub enum NotUnpinEnum<T, U> {
Struct {
#[pin]
pinned: T,
unpinned: U,
},
Tuple(#[pin] T, U),
Unit,
}

View File

@@ -0,0 +1,17 @@
include!("basic-safe-part.rs");
#[allow(clippy::undocumented_unsafe_blocks)]
unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin>
::pin_project::UnsafeUnpin for UnsafeUnpinStruct<T, U>
{
}
#[allow(clippy::undocumented_unsafe_blocks)]
unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin>
::pin_project::UnsafeUnpin for UnsafeUnpinTupleStruct<T, U>
{
}
#[allow(clippy::undocumented_unsafe_blocks)]
unsafe impl<T: ::pin_project::__private::Unpin, U: ::pin_project::__private::Unpin>
::pin_project::UnsafeUnpin for UnsafeUnpinEnum<T, U>
{
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,887 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
#![allow(dead_code)]
#[macro_use]
mod auxiliary;
use std::{
marker::{PhantomData, PhantomPinned},
panic,
pin::Pin,
};
use pin_project::{pin_project, pinned_drop, UnsafeUnpin};
#[test]
fn projection() {
#[pin_project(
project = StructProj,
project_ref = StructProjRef,
project_replace = StructProjOwn,
)]
struct Struct<T, U> {
#[pin]
f1: T,
f2: U,
}
let mut s = Struct { f1: 1, f2: 2 };
let mut s_orig = Pin::new(&mut s);
let s = s_orig.as_mut().project();
let _: Pin<&mut i32> = s.f1;
assert_eq!(*s.f1, 1);
let _: &mut i32 = s.f2;
assert_eq!(*s.f2, 2);
assert_eq!(s_orig.as_ref().f1, 1);
assert_eq!(s_orig.as_ref().f2, 2);
let mut s = Struct { f1: 1, f2: 2 };
let mut s = Pin::new(&mut s);
{
let StructProj { f1, f2 } = s.as_mut().project();
let _: Pin<&mut i32> = f1;
let _: &mut i32 = f2;
}
{
let StructProjRef { f1, f2 } = s.as_ref().project_ref();
let _: Pin<&i32> = f1;
let _: &i32 = f2;
}
{
let StructProjOwn { f1, f2 } = s.as_mut().project_replace(Struct { f1: 3, f2: 4 });
let _: PhantomData<i32> = f1;
let _: i32 = f2;
assert_eq!(f2, 2);
assert_eq!(s.f1, 3);
assert_eq!(s.f2, 4);
}
#[pin_project(project_replace)]
struct TupleStruct<T, U>(#[pin] T, U);
let mut s = TupleStruct(1, 2);
let s = Pin::new(&mut s).project();
let _: Pin<&mut i32> = s.0;
assert_eq!(*s.0, 1);
let _: &mut i32 = s.1;
assert_eq!(*s.1, 2);
#[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
#[derive(Eq, PartialEq, Debug)]
enum Enum<A, B, C, D> {
Tuple(#[pin] A, B),
Struct {
#[pin]
f1: C,
f2: D,
},
Unit,
}
let mut e = Enum::Tuple(1, 2);
let mut e = Pin::new(&mut e);
match e.as_mut().project() {
EnumProj::Tuple(x, y) => {
let x: Pin<&mut i32> = x;
assert_eq!(*x, 1);
let y: &mut i32 = y;
assert_eq!(*y, 2);
}
EnumProj::Struct { f1, f2 } => {
let _: Pin<&mut i32> = f1;
let _: &mut i32 = f2;
unreachable!();
}
EnumProj::Unit => unreachable!(),
}
assert_eq!(&*e, &Enum::Tuple(1, 2));
let mut e = Enum::Struct { f1: 3, f2: 4 };
let mut e = Pin::new(&mut e);
match e.as_mut().project() {
EnumProj::Tuple(x, y) => {
let _: Pin<&mut i32> = x;
let _: &mut i32 = y;
unreachable!();
}
EnumProj::Struct { f1, f2 } => {
let _: Pin<&mut i32> = f1;
assert_eq!(*f1, 3);
let _: &mut i32 = f2;
assert_eq!(*f2, 4);
}
EnumProj::Unit => unreachable!(),
}
if let EnumProj::Struct { f1, f2 } = e.as_mut().project() {
let _: Pin<&mut i32> = f1;
assert_eq!(*f1, 3);
let _: &mut i32 = f2;
assert_eq!(*f2, 4);
}
}
#[test]
fn enum_project_set() {
#[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
#[derive(Eq, PartialEq, Debug)]
enum Enum {
V1(#[pin] u8),
V2(bool),
}
let mut e = Enum::V1(25);
let mut e_orig = Pin::new(&mut e);
let e_proj = e_orig.as_mut().project();
match e_proj {
EnumProj::V1(val) => {
let new_e = Enum::V2(val.as_ref().get_ref() == &25);
e_orig.set(new_e);
}
EnumProj::V2(_) => unreachable!(),
}
assert_eq!(e, Enum::V2(true));
}
#[test]
fn where_clause() {
#[pin_project]
struct Struct<T>
where
T: Copy,
{
f: T,
}
#[pin_project]
struct TupleStruct<T>(T)
where
T: Copy;
#[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
enum Enum<T>
where
T: Copy,
{
V(T),
}
}
#[test]
fn where_clause_and_associated_type_field() {
#[pin_project(project_replace)]
struct Struct1<I>
where
I: Iterator,
{
#[pin]
f1: I,
f2: I::Item,
}
#[pin_project(project_replace)]
struct Struct2<I, J>
where
I: Iterator<Item = J>,
{
#[pin]
f1: I,
f2: J,
}
#[pin_project(project_replace)]
struct Struct3<T>
where
T: 'static,
{
f: T,
}
trait Static: 'static {}
impl<T> Static for Struct3<T> {}
#[pin_project(project_replace)]
struct TupleStruct<I>(#[pin] I, I::Item)
where
I: Iterator;
#[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
enum Enum<I>
where
I: Iterator,
{
V1(#[pin] I),
V2(I::Item),
}
}
#[test]
fn derive_copy() {
#[pin_project(project_replace)]
#[derive(Clone, Copy)]
struct Struct<T> {
f: T,
}
fn is_copy<T: Copy>() {}
is_copy::<Struct<u8>>();
}
#[test]
fn move_out() {
struct NotCopy;
#[pin_project(project_replace)]
struct Struct {
f: NotCopy,
}
let x = Struct { f: NotCopy };
let _val: NotCopy = x.f;
#[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
enum Enum {
V(NotCopy),
}
let x = Enum::V(NotCopy);
#[allow(clippy::infallible_destructuring_match)]
let _val: NotCopy = match x {
Enum::V(val) => val,
};
}
#[test]
fn trait_bounds_on_type_generics() {
#[pin_project(project_replace)]
pub struct Struct1<'a, T: ?Sized> {
f: &'a mut T,
}
#[pin_project(project_replace)]
pub struct Struct2<'a, T: ::core::fmt::Debug> {
f: &'a mut T,
}
#[pin_project(project_replace)]
pub struct Struct3<'a, T: core::fmt::Debug> {
f: &'a mut T,
}
#[pin_project(project_replace)]
pub struct Struct4<'a, T: core::fmt::Debug + core::fmt::Display> {
f: &'a mut T,
}
#[pin_project(project_replace)]
pub struct Struct5<'a, T: core::fmt::Debug + ?Sized> {
f: &'a mut T,
}
#[pin_project(project_replace)]
pub struct Struct6<'a, T: core::fmt::Debug = [u8; 16]> {
f: &'a mut T,
}
let _: Struct6<'_> = Struct6 { f: &mut [0_u8; 16] };
#[pin_project(project_replace)]
pub struct Struct7<T: 'static> {
f: T,
}
trait Static: 'static {}
impl<T> Static for Struct7<T> {}
#[pin_project(project_replace)]
pub struct Struct8<'a, 'b: 'a> {
f1: &'a u8,
f2: &'b u8,
}
#[pin_project(project_replace)]
pub struct TupleStruct<'a, T: ?Sized>(&'a mut T);
#[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
enum Enum<'a, T: ?Sized> {
V(&'a mut T),
}
}
#[test]
fn overlapping_lifetime_names() {
#[pin_project(project_replace)]
pub struct Struct1<'pin, T> {
#[pin]
f: &'pin mut T,
}
#[pin_project(project_replace)]
pub struct Struct2<'pin, 'pin_, 'pin__> {
#[pin]
f: &'pin &'pin_ &'pin__ (),
}
pub trait Trait<'a> {}
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
#[pin_project(project_replace)]
pub struct Hrtb<'pin___, T>
where
for<'pin> &'pin T: Unpin,
T: for<'pin> Trait<'pin>,
for<'pin, 'pin_, 'pin__> &'pin &'pin_ &'pin__ T: Unpin,
{
#[pin]
f: &'pin___ mut T,
}
#[pin_project(PinnedDrop)]
pub struct PinnedDropStruct<'pin> {
#[pin]
f: &'pin (),
}
#[pinned_drop]
impl PinnedDrop for PinnedDropStruct<'_> {
fn drop(self: Pin<&mut Self>) {}
}
#[pin_project(UnsafeUnpin)]
pub struct UnsafeUnpinStruct<'pin> {
#[pin]
f: &'pin (),
}
unsafe impl UnsafeUnpin for UnsafeUnpinStruct<'_> {}
#[pin_project(!Unpin)]
pub struct NotUnpinStruct<'pin> {
#[pin]
f: &'pin (),
}
}
#[test]
fn combine() {
#[pin_project(PinnedDrop, UnsafeUnpin)]
pub struct PinnedDropWithUnsafeUnpin<T> {
#[pin]
f: T,
}
#[pinned_drop]
impl<T> PinnedDrop for PinnedDropWithUnsafeUnpin<T> {
fn drop(self: Pin<&mut Self>) {}
}
unsafe impl<T: Unpin> UnsafeUnpin for PinnedDropWithUnsafeUnpin<T> {}
#[pin_project(PinnedDrop, !Unpin)]
pub struct PinnedDropWithNotUnpin<T> {
#[pin]
f: T,
}
#[pinned_drop]
impl<T> PinnedDrop for PinnedDropWithNotUnpin<T> {
fn drop(self: Pin<&mut Self>) {}
}
#[pin_project(UnsafeUnpin, project_replace)]
pub struct UnsafeUnpinWithReplace<T> {
#[pin]
f: T,
}
unsafe impl<T: Unpin> UnsafeUnpin for UnsafeUnpinWithReplace<T> {}
#[pin_project(!Unpin, project_replace)]
pub struct NotUnpinWithReplace<T> {
#[pin]
f: T,
}
}
#[test]
fn private_type_in_public_type() {
#[pin_project(project_replace)]
pub struct PublicStruct<T> {
#[pin]
inner: PrivateStruct<T>,
}
struct PrivateStruct<T>(T);
}
#[allow(clippy::needless_lifetimes)]
#[test]
fn lifetime_project() {
#[pin_project(project_replace)]
struct Struct1<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
#[pin_project(project_replace)]
struct Struct2<'a, T, U> {
#[pin]
pinned: &'a T,
unpinned: U,
}
#[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
enum Enum<T, U> {
V {
#[pin]
pinned: T,
unpinned: U,
},
}
impl<T, U> Struct1<T, U> {
fn get_pin_ref<'a>(self: Pin<&'a Self>) -> Pin<&'a T> {
self.project_ref().pinned
}
fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut T> {
self.project().pinned
}
fn get_pin_ref_elided(self: Pin<&Self>) -> Pin<&T> {
self.project_ref().pinned
}
fn get_pin_mut_elided(self: Pin<&mut Self>) -> Pin<&mut T> {
self.project().pinned
}
}
impl<'b, T, U> Struct2<'b, T, U> {
fn get_pin_ref<'a>(self: Pin<&'a Self>) -> Pin<&'a &'b T> {
self.project_ref().pinned
}
fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut &'b T> {
self.project().pinned
}
fn get_pin_ref_elided(self: Pin<&Self>) -> Pin<&&'b T> {
self.project_ref().pinned
}
fn get_pin_mut_elided(self: Pin<&mut Self>) -> Pin<&mut &'b T> {
self.project().pinned
}
}
impl<T, U> Enum<T, U> {
fn get_pin_ref<'a>(self: Pin<&'a Self>) -> Pin<&'a T> {
match self.project_ref() {
EnumProjRef::V { pinned, .. } => pinned,
}
}
fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut T> {
match self.project() {
EnumProj::V { pinned, .. } => pinned,
}
}
fn get_pin_ref_elided(self: Pin<&Self>) -> Pin<&T> {
match self.project_ref() {
EnumProjRef::V { pinned, .. } => pinned,
}
}
fn get_pin_mut_elided(self: Pin<&mut Self>) -> Pin<&mut T> {
match self.project() {
EnumProj::V { pinned, .. } => pinned,
}
}
}
}
mod visibility {
use pin_project::pin_project;
#[pin_project(project_replace)]
pub(crate) struct S {
pub f: u8,
}
}
#[test]
fn visibility() {
let mut x = visibility::S { f: 0 };
let x = Pin::new(&mut x);
let y = x.as_ref().project_ref();
let _: &u8 = y.f;
let y = x.project();
let _: &mut u8 = y.f;
}
#[test]
fn trivial_bounds() {
#[pin_project(project_replace)]
pub struct NoGenerics {
#[pin]
f: PhantomPinned,
}
assert_not_unpin!(NoGenerics);
}
#[test]
fn dst() {
#[pin_project]
struct Struct1<T: ?Sized> {
f: T,
}
let mut x = Struct1 { f: 0_u8 };
let x: Pin<&mut Struct1<dyn core::fmt::Debug>> = Pin::new(&mut x as _);
let _: &mut (dyn core::fmt::Debug) = x.project().f;
#[pin_project]
struct Struct2<T: ?Sized> {
#[pin]
f: T,
}
let mut x = Struct2 { f: 0_u8 };
let x: Pin<&mut Struct2<dyn core::fmt::Debug + Unpin>> = Pin::new(&mut x as _);
let _: Pin<&mut (dyn core::fmt::Debug + Unpin)> = x.project().f;
#[allow(explicit_outlives_requirements)] // https://github.com/rust-lang/rust/issues/60993
#[pin_project]
struct Struct3<T>
where
T: ?Sized,
{
f: T,
}
#[allow(explicit_outlives_requirements)] // https://github.com/rust-lang/rust/issues/60993
#[pin_project]
struct Struct4<T>
where
T: ?Sized,
{
#[pin]
f: T,
}
#[pin_project(UnsafeUnpin)]
struct Struct5<T: ?Sized> {
f: T,
}
#[pin_project(UnsafeUnpin)]
struct Struct6<T: ?Sized> {
#[pin]
f: T,
}
#[pin_project(PinnedDrop)]
struct Struct7<T: ?Sized> {
f: T,
}
#[pinned_drop]
impl<T: ?Sized> PinnedDrop for Struct7<T> {
fn drop(self: Pin<&mut Self>) {}
}
#[pin_project(PinnedDrop)]
struct Struct8<T: ?Sized> {
#[pin]
f: T,
}
#[pinned_drop]
impl<T: ?Sized> PinnedDrop for Struct8<T> {
fn drop(self: Pin<&mut Self>) {}
}
#[pin_project(!Unpin)]
struct Struct9<T: ?Sized> {
f: T,
}
#[pin_project(!Unpin)]
struct Struct10<T: ?Sized> {
#[pin]
f: T,
}
#[pin_project]
struct Struct11<'a, T: ?Sized, U: ?Sized> {
f1: &'a mut T,
f2: U,
}
#[pin_project]
struct TupleStruct1<T: ?Sized>(T);
#[pin_project]
struct TupleStruct2<T: ?Sized>(#[pin] T);
#[allow(explicit_outlives_requirements)] // https://github.com/rust-lang/rust/issues/60993
#[pin_project]
struct TupleStruct3<T>(T)
where
T: ?Sized;
#[allow(explicit_outlives_requirements)] // https://github.com/rust-lang/rust/issues/60993
#[pin_project]
struct TupleStruct4<T>(#[pin] T)
where
T: ?Sized;
#[pin_project(UnsafeUnpin)]
struct TupleStruct5<T: ?Sized>(T);
#[pin_project(UnsafeUnpin)]
struct TupleStruct6<T: ?Sized>(#[pin] T);
#[pin_project(PinnedDrop)]
struct TupleStruct7<T: ?Sized>(T);
#[pinned_drop]
impl<T: ?Sized> PinnedDrop for TupleStruct7<T> {
fn drop(self: Pin<&mut Self>) {}
}
#[pin_project(PinnedDrop)]
struct TupleStruct8<T: ?Sized>(#[pin] T);
#[pinned_drop]
impl<T: ?Sized> PinnedDrop for TupleStruct8<T> {
fn drop(self: Pin<&mut Self>) {}
}
#[pin_project(!Unpin)]
struct TupleStruct9<T: ?Sized>(T);
#[pin_project(!Unpin)]
struct TupleStruct10<T: ?Sized>(#[pin] T);
#[pin_project]
struct TupleStruct11<'a, T: ?Sized, U: ?Sized>(&'a mut T, U);
}
#[test]
fn dyn_type() {
#[pin_project]
struct Struct1 {
f: dyn core::fmt::Debug,
}
#[pin_project]
struct Struct2 {
#[pin]
f: dyn core::fmt::Debug,
}
#[pin_project]
struct Struct3 {
f: dyn core::fmt::Debug + Send,
}
#[pin_project]
struct Struct4 {
#[pin]
f: dyn core::fmt::Debug + Send,
}
#[pin_project]
struct TupleStruct1(dyn core::fmt::Debug);
#[pin_project]
struct TupleStruct2(#[pin] dyn core::fmt::Debug);
#[pin_project]
struct TupleStruct3(dyn core::fmt::Debug + Send);
#[pin_project]
struct TupleStruct4(#[pin] dyn core::fmt::Debug + Send);
}
#[test]
fn parse_self() {
macro_rules! mac {
($($tt:tt)*) => {
$($tt)*
};
}
pub trait Trait {
type Assoc;
}
#[allow(clippy::type_repetition_in_bounds)]
#[pin_project(project_replace)]
pub struct Generics<T: Trait<Assoc = Self>>
where
Self: Trait<Assoc = Self>,
<Self as Trait>::Assoc: Sized,
mac!(Self): Trait<Assoc = mac!(Self)>,
{
_f: T,
}
impl<T: Trait<Assoc = Self>> Trait for Generics<T> {
type Assoc = Self;
}
#[pin_project(project_replace)]
pub struct Struct {
_f1: Box<Self>,
_f2: Box<<Self as Trait>::Assoc>,
_f3: Box<mac!(Self)>,
_f4: [(); Self::ASSOC],
_f5: [(); Self::assoc()],
_f6: [(); mac!(Self::assoc())],
}
impl Struct {
const ASSOC: usize = 1;
const fn assoc() -> usize {
0
}
}
impl Trait for Struct {
type Assoc = Self;
}
#[pin_project(project_replace)]
struct Tuple(
Box<Self>,
Box<<Self as Trait>::Assoc>,
Box<mac!(Self)>,
[(); Self::ASSOC],
[(); Self::assoc()],
[(); mac!(Self::assoc())],
);
impl Tuple {
const ASSOC: usize = 1;
const fn assoc() -> usize {
0
}
}
impl Trait for Tuple {
type Assoc = Self;
}
#[pin_project(project = EnumProj, project_ref = EnumProjRef, project_replace = EnumProjOwn)]
enum Enum {
Struct {
_f1: Box<Self>,
_f2: Box<<Self as Trait>::Assoc>,
_f3: Box<mac!(Self)>,
_f4: [(); Self::ASSOC],
_f5: [(); Self::assoc()],
_f6: [(); mac!(Self::assoc())],
},
Tuple(
Box<Self>,
Box<<Self as Trait>::Assoc>,
Box<mac!(Self)>,
[(); Self::ASSOC],
[(); Self::assoc()],
[(); mac!(Self::assoc())],
),
}
impl Enum {
const ASSOC: usize = 1;
const fn assoc() -> usize {
0
}
}
impl Trait for Enum {
type Assoc = Self;
}
}
#[test]
fn no_infer_outlives() {
trait Trait<X> {
type Y;
}
struct Struct1<A>(A);
impl<X, T> Trait<X> for Struct1<T> {
type Y = Option<T>;
}
#[pin_project(project_replace)]
struct Struct2<A, B> {
_f: <Struct1<A> as Trait<B>>::Y,
}
}
// https://github.com/rust-lang/rust/issues/47949
// https://github.com/taiki-e/pin-project/pull/194#discussion_r419098111
#[allow(clippy::many_single_char_names)]
#[test]
fn project_replace_panic() {
#[pin_project(project_replace)]
struct S<T, U> {
#[pin]
pinned: T,
unpinned: U,
}
struct D<'a>(&'a mut bool, bool);
impl Drop for D<'_> {
fn drop(&mut self) {
*self.0 = true;
if self.1 {
panic!();
}
}
}
let (mut a, mut b, mut c, mut d) = (false, false, false, false);
let res = panic::catch_unwind(panic::AssertUnwindSafe(|| {
let mut x = S { pinned: D(&mut a, true), unpinned: D(&mut b, false) };
let _y = Pin::new(&mut x)
.project_replace(S { pinned: D(&mut c, false), unpinned: D(&mut d, false) });
// Previous `x.pinned` was dropped and panicked when `project_replace` is
// called, so this is unreachable.
unreachable!();
}));
assert!(res.is_err());
assert!(a);
assert!(b);
assert!(c);
assert!(d);
let (mut a, mut b, mut c, mut d) = (false, false, false, false);
let res = panic::catch_unwind(panic::AssertUnwindSafe(|| {
let mut x = S { pinned: D(&mut a, false), unpinned: D(&mut b, true) };
{
let _y = Pin::new(&mut x)
.project_replace(S { pinned: D(&mut c, false), unpinned: D(&mut d, false) });
// `_y` (previous `x.unpinned`) live to the end of this scope, so
// this is not unreachable.
// unreachable!();
}
unreachable!();
}));
assert!(res.is_err());
assert!(a);
assert!(b);
assert!(c);
assert!(d);
}

View File

@@ -0,0 +1,284 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
use std::pin::Pin;
use pin_project::{pin_project, pinned_drop};
#[test]
fn safe_project() {
#[pin_project(PinnedDrop)]
pub struct Struct<'a> {
was_dropped: &'a mut bool,
#[pin]
field: u8,
}
#[pinned_drop]
impl PinnedDrop for Struct<'_> {
fn drop(self: Pin<&mut Self>) {
**self.project().was_dropped = true;
}
}
let mut was_dropped = false;
drop(Struct { was_dropped: &mut was_dropped, field: 42 });
assert!(was_dropped);
}
#[test]
fn self_call() {
#[pin_project(PinnedDrop)]
pub struct S<T>(T);
trait Trait {
fn self_ref(&self) {}
fn self_pin_ref(self: Pin<&Self>) {}
fn self_mut(&mut self) {}
fn self_pin_mut(self: Pin<&mut Self>) {}
fn assoc_fn(_this: Pin<&mut Self>) {}
}
impl<T> Trait for S<T> {}
#[pinned_drop]
impl<T> PinnedDrop for S<T> {
fn drop(mut self: Pin<&mut Self>) {
self.self_ref();
self.as_ref().self_pin_ref();
self.self_mut();
self.as_mut().self_pin_mut();
Self::assoc_fn(self.as_mut());
<Self>::assoc_fn(self.as_mut());
}
}
}
#[test]
fn self_ty() {
#[pin_project(PinnedDrop)]
pub struct Struct {
pub f: (),
}
#[pinned_drop]
impl PinnedDrop for Struct {
#[allow(irrefutable_let_patterns)]
#[allow(clippy::match_single_binding)]
fn drop(mut self: Pin<&mut Self>) {
// expr
let _: Self = Self { f: () };
// pat
match *self {
Self { f: () } => {}
}
if let Self { f: () } = *self {}
let Self { f: () } = *self;
}
}
#[pin_project(PinnedDrop)]
pub struct TupleStruct(());
#[pinned_drop]
impl PinnedDrop for TupleStruct {
#[allow(irrefutable_let_patterns)]
fn drop(mut self: Pin<&mut Self>) {
// expr
let _: Self = Self(());
// pat
match *self {
Self(_) => {}
}
if let Self(_) = *self {}
let Self(_) = *self;
}
}
#[pin_project(PinnedDrop, project = EnumProj, project_ref = EnumProjRef)]
pub enum Enum {
Struct { f: () },
Tuple(()),
Unit,
}
#[pinned_drop]
impl PinnedDrop for Enum {
fn drop(mut self: Pin<&mut Self>) {
// expr
let _: Self = Self::Struct { f: () };
let _: Self = Self::Tuple(());
let _: Self = Self::Unit;
// pat
match *self {
Self::Struct { f: () } => {}
Self::Tuple(_) => {}
Self::Unit => {}
}
if let Self::Struct { f: () } = *self {}
if let Self::Tuple(_) = *self {}
if let Self::Unit = *self {}
}
}
}
#[test]
fn self_inside_macro_containing_fn() {
macro_rules! mac {
($($tt:tt)*) => {
$($tt)*
};
}
#[pin_project(PinnedDrop)]
pub struct S(());
#[pinned_drop]
impl PinnedDrop for S {
fn drop(self: Pin<&mut Self>) {
mac!({
impl S {
pub fn _f(self) -> Self {
self
}
}
});
}
}
}
// See also `ui/pinned_drop/self.rs`.
#[rustversion::since(1.40)] // https://github.com/rust-lang/rust/pull/64690
#[test]
fn self_inside_macro_def() {
#[pin_project(PinnedDrop)]
pub struct S(());
#[pinned_drop]
impl PinnedDrop for S {
fn drop(self: Pin<&mut Self>) {
macro_rules! mac {
() => {{
let _ = self;
let _ = Self(());
}};
}
mac!();
}
}
}
#[test]
fn self_arg_inside_macro_call() {
#[pin_project(PinnedDrop)]
struct Struct {
f: (),
}
#[pinned_drop]
impl PinnedDrop for Struct {
fn drop(self: Pin<&mut Self>) {
let _: Vec<_> = vec![self.f];
}
}
}
#[test]
fn self_ty_inside_macro_call() {
macro_rules! mac {
($($tt:tt)*) => {
$($tt)*
};
}
#[pin_project(PinnedDrop)]
pub struct Struct<T: Send>
where
mac!(Self): Send,
{
_f: T,
}
impl<T: Send> Struct<T> {
const ASSOC1: usize = 1;
fn assoc1() {}
}
trait Trait {
type Assoc2;
const ASSOC2: usize;
fn assoc2();
}
impl<T: Send> Trait for Struct<T> {
type Assoc2 = u8;
const ASSOC2: usize = 2;
fn assoc2() {}
}
#[pinned_drop]
impl<T: Send> PinnedDrop for Struct<T>
where
mac!(Self): Send,
{
#[allow(path_statements)]
#[allow(clippy::no_effect)]
fn drop(self: Pin<&mut Self>) {
// inherent items
mac!(Self::ASSOC1;);
mac!(<Self>::ASSOC1;);
mac!(Self::assoc1(););
mac!(<Self>::assoc1(););
// trait items
mac!(let _: <Self as Trait>::Assoc2;);
mac!(Self::ASSOC2;);
mac!(<Self>::ASSOC2;);
mac!(<Self as Trait>::ASSOC2;);
mac!(Self::assoc2(););
mac!(<Self>::assoc2(););
mac!(<Self as Trait>::assoc2(););
}
}
}
#[test]
fn inside_macro() {
#[pin_project(PinnedDrop)]
struct S(());
macro_rules! mac {
($expr:expr) => {
#[pinned_drop]
impl PinnedDrop for S {
fn drop(self: Pin<&mut Self>) {
let _ = $expr;
}
}
};
}
mac!(1);
}
pub mod self_path {
use super::*;
#[pin_project(PinnedDrop)]
pub struct S<T: Unpin>(T);
fn f() {}
#[pinned_drop]
impl<T: Unpin> PinnedDrop for self::S<T> {
fn drop(mut self: Pin<&mut Self>) {
self::f();
let _: self::S<()> = self::S(());
let _: self::S<Pin<&mut Self>> = self::S(self.as_mut());
let self::S(()) = self::S(());
let self::S(&mut Self(_)) = self::S(&mut *self);
}
}
}

View File

@@ -0,0 +1,153 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
#![allow(dead_code)]
#[macro_use]
mod auxiliary;
pub mod default {
use std::marker::PhantomPinned;
use pin_project::pin_project;
struct Inner<T> {
f: T,
}
assert_unpin!(Inner<()>);
assert_not_unpin!(Inner<PhantomPinned>);
#[pin_project]
struct Struct<T, U> {
#[pin]
f1: Inner<T>,
f2: U,
}
assert_unpin!(Struct<(), ()>);
assert_unpin!(Struct<(), PhantomPinned>);
assert_not_unpin!(Struct<PhantomPinned, ()>);
assert_not_unpin!(Struct<PhantomPinned, PhantomPinned>);
#[pin_project(project = EnumProj, project_ref = EnumProjRef)]
enum Enum<T, U> {
V1 {
#[pin]
f1: Inner<T>,
f2: U,
},
}
assert_unpin!(Enum<(), ()>);
assert_unpin!(Enum<(), PhantomPinned>);
assert_not_unpin!(Enum<PhantomPinned, ()>);
assert_not_unpin!(Enum<PhantomPinned, PhantomPinned>);
#[pin_project]
struct TrivialBounds {
#[pin]
f: PhantomPinned,
}
assert_not_unpin!(TrivialBounds);
#[pin_project]
struct PinRef<'a, T, U> {
#[pin]
f1: &'a mut Inner<T>,
f2: U,
}
assert_unpin!(PinRef<'_, PhantomPinned, PhantomPinned>);
}
pub mod cfg {
use std::marker::PhantomPinned;
use pin_project::pin_project;
#[pin_project]
struct Foo<T> {
#[cfg(any())]
#[pin]
f: T,
#[cfg(not(any()))]
f: T,
}
assert_unpin!(Foo<PhantomPinned>);
#[pin_project]
struct Bar<T> {
#[cfg(any())]
f: T,
#[cfg(not(any()))]
#[pin]
f: T,
}
assert_unpin!(Bar<()>);
assert_not_unpin!(Bar<PhantomPinned>);
}
pub mod cfg_attr {
use std::marker::PhantomPinned;
use pin_project::pin_project;
#[cfg_attr(any(), pin_project)]
struct Foo<T> {
f: T,
}
assert_unpin!(Foo<()>);
assert_not_unpin!(Foo<PhantomPinned>);
#[cfg_attr(not(any()), pin_project)]
struct Bar<T> {
#[cfg_attr(not(any()), pin)]
f: T,
}
assert_unpin!(Bar<()>);
assert_not_unpin!(Bar<PhantomPinned>);
}
// pin_project(!Unpin)
pub mod not_unpin {
use std::marker::PhantomPinned;
use pin_project::pin_project;
struct Inner<T> {
f: T,
}
#[pin_project(!Unpin)]
struct Struct<T, U> {
#[pin]
inner: Inner<T>,
other: U,
}
assert_not_unpin!(Struct<(), ()>);
assert_not_unpin!(Struct<(), PhantomPinned>);
assert_not_unpin!(Struct<PhantomPinned, ()>);
assert_not_unpin!(Struct<PhantomPinned, PhantomPinned>);
#[pin_project(!Unpin)]
struct TrivialBounds {
#[pin]
f: PhantomPinned,
}
assert_not_unpin!(TrivialBounds);
#[pin_project(!Unpin)]
struct PinRef<'a, T, U> {
#[pin]
inner: &'a mut Inner<T>,
other: U,
}
assert_not_unpin!(PinRef<'_, (), ()>);
}

View File

@@ -0,0 +1,52 @@
#![warn(rust_2018_idioms, single_use_lifetimes)]
// unaligned_references did not exist in older compilers and safe_packed_borrows was removed in the latest compilers.
// https://github.com/rust-lang/rust/pull/82525
#![allow(unknown_lints, renamed_and_removed_lints)]
#![forbid(unaligned_references, safe_packed_borrows)]
use std::cell::Cell;
// Ensure that the compiler doesn't copy the fields
// of #[repr(packed)] types during drop, if the field has alignment 1
// (that is, any reference to the field is guaranteed to have proper alignment)
// We are currently unable to statically prevent the usage of #[pin_project]
// on #[repr(packed)] types composed entirely of fields of alignment 1.
// This shouldn't lead to undefined behavior, as long as the compiler doesn't
// try to move the field anyway during drop.
//
// This tests validates that the compiler is doing what we expect.
#[test]
fn weird_repr_packed() {
// We keep track of the field address during
// drop using a thread local, to avoid changing
// the layout of our #[repr(packed)] type.
thread_local! {
static FIELD_ADDR: Cell<usize> = Cell::new(0);
}
#[repr(packed)]
struct Struct {
field: u8,
}
impl Drop for Struct {
fn drop(&mut self) {
FIELD_ADDR.with(|f| {
f.set(&self.field as *const u8 as usize);
});
}
}
#[allow(clippy::let_and_return)]
let field_addr = {
// We let this field drop by going out of scope,
// rather than explicitly calling drop(foo).
// Calling drop(foo) causes 'foo' to be moved
// into the 'drop' function, resulting in a different
// address.
let x = Struct { field: 27 };
let field_addr = &x.field as *const u8 as usize;
field_addr
};
assert_eq!(field_addr, FIELD_ADDR.with(Cell::get));
}

View File

@@ -0,0 +1,11 @@
use std::pin::Pin;
#[cfg_attr(any(), pin_project::pin_project)]
struct Foo<T> {
f: T,
}
fn main() {
let mut x = Foo { f: 0_u8 };
let _ = Pin::new(&mut x).project(); //~ ERROR E0599
}

View File

@@ -0,0 +1,5 @@
error[E0599]: no method named `project` found for struct `Pin<&mut Foo<u8>>` in the current scope
--> tests/ui/cfg/cfg_attr-resolve.rs:10:30
|
10 | let _ = Pin::new(&mut x).project(); //~ ERROR E0599
| ^^^^^^^ method not found in `Pin<&mut Foo<u8>>`

View File

@@ -0,0 +1,25 @@
use std::pin::Pin;
use pin_project::pin_project;
#[cfg_attr(not(any()), pin_project)]
struct Foo<T> {
#[cfg_attr(any(), pin)]
f: T,
}
#[cfg_attr(not(any()), pin_project)]
struct Bar<T> {
#[cfg_attr(not(any()), pin)]
f: T,
}
fn main() {
let mut x = Foo { f: 0_u8 };
let x = Pin::new(&mut x).project();
let _: Pin<&mut u8> = x.f; //~ ERROR E0308
let mut x = Bar { f: 0_u8 };
let x = Pin::new(&mut x).project();
let _: &mut u8 = x.f; //~ ERROR E0308
}

View File

@@ -0,0 +1,23 @@
error[E0308]: mismatched types
--> tests/ui/cfg/cfg_attr-type-mismatch.rs:20:27
|
20 | let _: Pin<&mut u8> = x.f; //~ ERROR E0308
| ------------ ^^^ expected struct `Pin`, found `&mut u8`
| |
| expected due to this
|
= note: expected struct `Pin<&mut u8>`
found mutable reference `&mut u8`
error[E0308]: mismatched types
--> tests/ui/cfg/cfg_attr-type-mismatch.rs:24:22
|
24 | let _: &mut u8 = x.f; //~ ERROR E0308
| ------- ^^^
| | |
| | expected `&mut u8`, found struct `Pin`
| | help: consider mutably borrowing here: `&mut x.f`
| expected due to this
|
= note: expected mutable reference `&mut u8`
found struct `Pin<&mut u8>`

View File

@@ -0,0 +1,15 @@
use auxiliary_macro::hidden_repr;
use pin_project::pin_project;
#[pin_project]
#[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types
struct S {
#[cfg(not(any()))]
#[pin]
f: u32,
#[cfg(any())]
#[pin]
f: u8,
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: #[pin_project] attribute may not be used on #[repr(packed)] types
--> tests/ui/cfg/packed_sneaky-span-issue-1.rs:5:15
|
5 | #[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types
| ^^^^^^

View File

@@ -0,0 +1,15 @@
use auxiliary_macro::hidden_repr;
use pin_project::pin_project;
#[pin_project]
#[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types
struct S {
#[cfg(any())]
#[pin]
f: u32,
#[cfg(not(any()))]
#[pin]
f: u8,
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: #[pin_project] attribute may not be used on #[repr(packed)] types
--> tests/ui/cfg/packed_sneaky-span-issue-2.rs:5:15
|
5 | #[hidden_repr(packed)] //~ ERROR may not be used on #[repr(packed)] types
| ^^^^^^

View File

@@ -0,0 +1,12 @@
use auxiliary_macro::hidden_repr_cfg_not_any;
use pin_project::pin_project;
// `#[hidden_repr_cfg_not_any(packed)]` generates `#[cfg_attr(not(any()), repr(packed))]`.
#[pin_project]
#[hidden_repr_cfg_not_any(packed)] //~ ERROR may not be used on #[repr(packed)] types
struct S {
#[pin]
f: u32,
}
fn main() {}

View File

@@ -0,0 +1,5 @@
error: #[pin_project] attribute may not be used on #[repr(packed)] types
--> tests/ui/cfg/packed_sneaky.rs:6:27
|
6 | #[hidden_repr_cfg_not_any(packed)] //~ ERROR may not be used on #[repr(packed)] types
| ^^^^^^

View File

@@ -0,0 +1,11 @@
use pin_project::pin_project;
#[pin_project]
struct S {
//~^ ERROR may not be used on structs with zero fields
#[cfg(any())]
#[pin]
f: u8,
}
fn main() {}

View File

@@ -0,0 +1,11 @@
error: #[pin_project] attribute may not be used on structs with zero fields
--> tests/ui/cfg/unsupported.rs:4:10
|
4 | struct S {
| __________^
5 | | //~^ ERROR may not be used on structs with zero fields
6 | | #[cfg(any())]
7 | | #[pin]
8 | | f: u8,
9 | | }
| |_^

View File

@@ -0,0 +1,30 @@
use pin_project::pin_project;
#[pin_project(!Unpin)] //~ ERROR E0119
struct Foo<T, U> {
#[pin]
f1: T,
f2: U,
}
impl<T, U> Unpin for Foo<T, U> where T: Unpin {}
#[pin_project(!Unpin)] //~ ERROR E0119
struct Bar<T, U> {
#[pin]
f1: T,
f2: U,
}
impl<T, U> Unpin for Bar<T, U> {}
#[pin_project(!Unpin)] //~ ERROR E0119
struct Baz<T, U> {
#[pin]
f1: T,
f2: U,
}
impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {}
fn main() {}

View File

@@ -0,0 +1,26 @@
error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Foo<_, _>`
--> tests/ui/not_unpin/conflict-unpin.rs:3:15
|
3 | #[pin_project(!Unpin)] //~ ERROR E0119
| ^^^^^^ conflicting implementation for `Foo<_, _>`
...
10 | impl<T, U> Unpin for Foo<T, U> where T: Unpin {}
| ------------------------------ first implementation here
error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Bar<_, _>`
--> tests/ui/not_unpin/conflict-unpin.rs:12:15
|
12 | #[pin_project(!Unpin)] //~ ERROR E0119
| ^^^^^^ conflicting implementation for `Bar<_, _>`
...
19 | impl<T, U> Unpin for Bar<T, U> {}
| ------------------------------ first implementation here
error[E0119]: conflicting implementations of trait `std::marker::Unpin` for type `Baz<_, _>`
--> tests/ui/not_unpin/conflict-unpin.rs:21:15
|
21 | #[pin_project(!Unpin)] //~ ERROR E0119
| ^^^^^^ conflicting implementation for `Baz<_, _>`
...
28 | impl<T: Unpin, U: Unpin> Unpin for Baz<T, U> {}
| -------------------------------------------- first implementation here

View File

@@ -0,0 +1,30 @@
use pin_project::{pin_project, UnsafeUnpin};
#[pin_project(!Unpin)] //~ ERROR E0119
struct Foo<T, U> {
#[pin]
f1: T,
f2: U,
}
unsafe impl<T, U> UnsafeUnpin for Foo<T, U> where T: Unpin {}
#[pin_project(!Unpin)] //~ ERROR E0119
struct Bar<T, U> {
#[pin]
f1: T,
f2: U,
}
unsafe impl<T, U> UnsafeUnpin for Bar<T, U> {}
#[pin_project(!Unpin)] //~ ERROR E0119
struct Baz<T, U> {
#[pin]
f1: T,
f2: U,
}
unsafe impl<T: Unpin, U: Unpin> UnsafeUnpin for Baz<T, U> {}
fn main() {}

Some files were not shown because too many files have changed in this diff Show More