aboutsummaryrefslogtreecommitdiff
path: root/examples/pinned_drop-expanded.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/pinned_drop-expanded.rs')
-rw-r--r--examples/pinned_drop-expanded.rs75
1 files changed, 34 insertions, 41 deletions
diff --git a/examples/pinned_drop-expanded.rs b/examples/pinned_drop-expanded.rs
index 8f295e9..ad22c0b 100644
--- a/examples/pinned_drop-expanded.rs
+++ b/examples/pinned_drop-expanded.rs
@@ -21,47 +21,35 @@
// fn main() {}
// ```
-#![allow(dead_code, unused_imports, unused_parens)]
-#![allow(clippy::no_effect)]
+#![allow(dead_code, unused_imports, unused_parens, unknown_lints, renamed_and_removed_lints)]
+#![allow(clippy::needless_lifetimes)]
use pin_project::{pin_project, pinned_drop};
use std::pin::Pin;
+// #[pin_project(PinnedDrop)]
pub struct Struct<'a, T> {
was_dropped: &'a mut bool,
// #[pin]
field: T,
}
-#[doc(hidden)]
-#[allow(dead_code)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::mut_mut)]
-#[allow(clippy::type_repetition_in_bounds)]
-pub(crate) struct __StructProjection<'pin, 'a, T>
-where
- Struct<'a, T>: 'pin,
-{
- was_dropped: &'pin mut (&'a mut bool),
- field: ::pin_project::__private::Pin<&'pin mut (T)>,
-}
-#[doc(hidden)]
-#[allow(dead_code)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::type_repetition_in_bounds)]
-pub(crate) struct __StructProjectionRef<'pin, 'a, T>
-where
- Struct<'a, T>: 'pin,
-{
- was_dropped: &'pin (&'a mut bool),
- field: ::pin_project::__private::Pin<&'pin (T)>,
-}
-
-#[doc(hidden)]
-#[allow(non_upper_case_globals)]
-#[allow(single_use_lifetimes)]
-#[allow(clippy::used_underscore_binding)]
const _: () = {
+ pub(crate) struct __StructProjection<'pin, 'a, T>
+ where
+ Struct<'a, T>: 'pin,
+ {
+ was_dropped: &'pin mut (&'a mut bool),
+ field: ::pin_project::__private::Pin<&'pin mut (T)>,
+ }
+ pub(crate) struct __StructProjectionRef<'pin, 'a, T>
+ where
+ Struct<'a, T>: 'pin,
+ {
+ was_dropped: &'pin (&'a mut bool),
+ field: ::pin_project::__private::Pin<&'pin (T)>,
+ }
+
impl<'a, T> Struct<'a, T> {
pub(crate) fn project<'pin>(
self: ::pin_project::__private::Pin<&'pin mut Self>,
@@ -87,6 +75,17 @@ const _: () = {
}
}
+ // Ensure that it's impossible to use pin projections on a #[repr(packed)]
+ // struct.
+ //
+ // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
+ // for details.
+ #[forbid(safe_packed_borrows)]
+ fn __assert_not_repr_packed<'a, T>(this: &Struct<'a, T>) {
+ let _ = &this.was_dropped;
+ let _ = &this.field;
+ }
+
impl<'a, T> ::pin_project::__private::Drop for Struct<'a, T> {
fn drop(&mut self) {
// Safety - we're in 'drop', so we know that 'self' will
@@ -114,17 +113,11 @@ const _: () = {
__Struct<'pin, 'a, T>: ::pin_project::__private::Unpin
{
}
- unsafe impl<'a, T> ::pin_project::UnsafeUnpin for Struct<'a, T> {}
-
- // Ensure that it's impossible to use pin projections on a #[repr(packed)]
- // struct.
- //
- // See ./struct-default-expanded.rs and https://github.com/taiki-e/pin-project/pull/34
- // for details.
- #[deny(safe_packed_borrows)]
- fn __assert_not_repr_packed<'a, T>(val: &Struct<'a, T>) {
- &val.was_dropped;
- &val.field;
+ // A dummy impl of `UnsafeUnpin`, to ensure that the user cannot implement it.
+ #[doc(hidden)]
+ unsafe impl<'pin, 'a, T> ::pin_project::UnsafeUnpin for Struct<'a, T> where
+ __Struct<'pin, 'a, T>: ::pin_project::__private::Unpin
+ {
}
};