Skip to content

Commit ffcdb4a

Browse files
committed
update expand test
1 parent a5e3dfc commit ffcdb4a

File tree

3 files changed

+205
-0
lines changed

3 files changed

+205
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
use pin_project_lite::pin_project;
2+
use std::pin::Pin;
3+
enum Enum<T, U> {
4+
Struct { pinned: T, unpinned: U },
5+
Unit,
6+
}
7+
#[allow(dead_code)]
8+
#[allow(single_use_lifetimes)]
9+
#[allow(clippy::mut_mut)]
10+
#[allow(clippy::redundant_pub_crate)]
11+
#[allow(clippy::type_repetition_in_bounds)]
12+
enum EnumProj<'__pin, T, U>
13+
where
14+
Enum<T, U>: '__pin,
15+
{
16+
Struct {
17+
pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
18+
unpinned: &'__pin mut (U),
19+
},
20+
Unit,
21+
}
22+
#[allow(dead_code)]
23+
#[allow(single_use_lifetimes)]
24+
#[allow(clippy::mut_mut)]
25+
#[allow(clippy::redundant_pub_crate)]
26+
#[allow(clippy::type_repetition_in_bounds)]
27+
enum EnumProjRef<'__pin, T, U>
28+
where
29+
Enum<T, U>: '__pin,
30+
{
31+
Struct {
32+
pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
33+
unpinned: &'__pin (U),
34+
},
35+
Unit,
36+
}
37+
#[allow(single_use_lifetimes)]
38+
#[allow(clippy::used_underscore_binding)]
39+
const _: () = {
40+
impl<T, U> Enum<T, U> {
41+
fn project<'__pin>(
42+
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
43+
) -> EnumProj<'__pin, T, U> {
44+
unsafe {
45+
match self.get_unchecked_mut() {
46+
Enum::Struct { pinned, unpinned } => EnumProj::Struct {
47+
pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
48+
unpinned: unpinned,
49+
},
50+
Enum::Unit => EnumProj::Unit,
51+
}
52+
}
53+
}
54+
fn project_ref<'__pin>(
55+
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
56+
) -> EnumProjRef<'__pin, T, U> {
57+
unsafe {
58+
match self.get_ref() {
59+
Enum::Struct { pinned, unpinned } => EnumProjRef::Struct {
60+
pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
61+
unpinned: unpinned,
62+
},
63+
Enum::Unit => EnumProjRef::Unit,
64+
}
65+
}
66+
}
67+
}
68+
#[allow(non_snake_case)]
69+
struct __Origin<'__pin, T, U> {
70+
__dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
71+
Struct: (T, ::pin_project_lite::__private::AlwaysUnpin<U>),
72+
Unit: (),
73+
}
74+
impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Enum<T, U> where
75+
__Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
76+
{
77+
}
78+
impl<T, U> ::pin_project_lite::__private::Drop for Enum<T, U> {
79+
fn drop(&mut self) {
80+
trait __DropInner {
81+
fn __drop_inner(self: ::pin_project_lite::__private::Pin<&mut Self>);
82+
}
83+
impl<T, U> __DropInner for Enum<T, U> {
84+
fn __drop_inner(self: ::pin_project_lite::__private::Pin<&mut Self>) {
85+
let _this = self;
86+
}
87+
}
88+
let pinned_self = unsafe { ::pin_project_lite::__private::Pin::new_unchecked(self) };
89+
__DropInner::__drop_inner(pinned_self);
90+
}
91+
}
92+
};
93+
fn main() {}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use pin_project_lite::pin_project;
2+
use std::pin::Pin;
3+
4+
pin_project! {
5+
#[project = EnumProj]
6+
#[project_ref = EnumProjRef]
7+
enum Enum<T, U> {
8+
Struct {
9+
#[pin]
10+
pinned: T,
11+
unpinned: U,
12+
},
13+
Unit,
14+
}
15+
impl<T, U> PinnedDrop for Enum<T, U> {
16+
fn drop(self: Pin<&mut Self>) {
17+
let _this = self;
18+
}
19+
}
20+
}
21+
22+
fn main() {}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
use pin_project_lite::pin_project;
2+
use std::pin::Pin;
3+
struct Struct<T, U> {
4+
pinned: T,
5+
unpinned: U,
6+
}
7+
#[allow(explicit_outlives_requirements)]
8+
#[allow(single_use_lifetimes)]
9+
#[allow(clippy::redundant_pub_crate)]
10+
#[allow(clippy::used_underscore_binding)]
11+
const _: () = {
12+
#[allow(dead_code)]
13+
#[allow(single_use_lifetimes)]
14+
#[allow(clippy::mut_mut)]
15+
#[allow(clippy::redundant_pub_crate)]
16+
#[allow(clippy::type_repetition_in_bounds)]
17+
struct Projection<'__pin, T, U>
18+
where
19+
Struct<T, U>: '__pin,
20+
{
21+
pinned: ::pin_project_lite::__private::Pin<&'__pin mut (T)>,
22+
unpinned: &'__pin mut (U),
23+
}
24+
#[allow(dead_code)]
25+
#[allow(single_use_lifetimes)]
26+
#[allow(clippy::mut_mut)]
27+
#[allow(clippy::redundant_pub_crate)]
28+
#[allow(clippy::type_repetition_in_bounds)]
29+
struct ProjectionRef<'__pin, T, U>
30+
where
31+
Struct<T, U>: '__pin,
32+
{
33+
pinned: ::pin_project_lite::__private::Pin<&'__pin (T)>,
34+
unpinned: &'__pin (U),
35+
}
36+
impl<T, U> Struct<T, U> {
37+
fn project<'__pin>(
38+
self: ::pin_project_lite::__private::Pin<&'__pin mut Self>,
39+
) -> Projection<'__pin, T, U> {
40+
unsafe {
41+
let Self { pinned, unpinned } = self.get_unchecked_mut();
42+
Projection {
43+
pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
44+
unpinned: unpinned,
45+
}
46+
}
47+
}
48+
fn project_ref<'__pin>(
49+
self: ::pin_project_lite::__private::Pin<&'__pin Self>,
50+
) -> ProjectionRef<'__pin, T, U> {
51+
unsafe {
52+
let Self { pinned, unpinned } = self.get_ref();
53+
ProjectionRef {
54+
pinned: ::pin_project_lite::__private::Pin::new_unchecked(pinned),
55+
unpinned: unpinned,
56+
}
57+
}
58+
}
59+
}
60+
#[allow(non_snake_case)]
61+
struct __Origin<'__pin, T, U> {
62+
__dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
63+
pinned: T,
64+
unpinned: ::pin_project_lite::__private::AlwaysUnpin<U>,
65+
}
66+
impl<'__pin, T, U> ::pin_project_lite::__private::Unpin for Struct<T, U> where
67+
__Origin<'__pin, T, U>: ::pin_project_lite::__private::Unpin
68+
{
69+
}
70+
impl<T, U> ::pin_project_lite::__private::Drop for Struct<T, U> {
71+
fn drop(&mut self) {
72+
trait __DropInner {
73+
fn __drop_inner(self: ::pin_project_lite::__private::Pin<&mut Self>);
74+
}
75+
impl<T, U> __DropInner for Struct<T, U> {
76+
fn __drop_inner(self: ::pin_project_lite::__private::Pin<&mut Self>) {
77+
let _this = self;
78+
}
79+
}
80+
let pinned_self = unsafe { ::pin_project_lite::__private::Pin::new_unchecked(self) };
81+
__DropInner::__drop_inner(pinned_self);
82+
}
83+
}
84+
#[forbid(safe_packed_borrows)]
85+
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
86+
let _ = &this.pinned;
87+
let _ = &this.unpinned;
88+
}
89+
};
90+
fn main() {}

0 commit comments

Comments
 (0)