Open
Description
pin_project_lite
generates code that looks like this:
impl <'__pin> ::pin_project_lite::__private::Unpin for Sleep<> where
__Origin<'__pin>: ::pin_project_lite::__private::Unpin {
}
Full output of cargo expand
#![feature(prelude_import)]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std;
use pin_project_lite::pin_project;
struct TimerEntry {
}
// The link between the `Sleep` instance and the timer that drives it.
#[doc = r" Future returned by [`sleep`](sleep) and"]
#[doc = r" [`sleep_until`](sleep_until)."]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Sleep {
deadline: std::time::Duration,
entry: TimerEntry,
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::fmt::Debug for Sleep {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match *self {
Sleep { deadline: ref __self_0_0, entry: ref __self_0_1 } => {
let mut debug_trait_builder = f.debug_struct("Sleep");
let _ =
debug_trait_builder.field("deadline", &&(*__self_0_0));
let _ = debug_trait_builder.field("entry", &&(*__self_0_1));
debug_trait_builder.finish()
}
}
}
}
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy :: redundant_pub_crate)]
#[allow(clippy :: used_underscore_binding)]
const _: () =
{
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy :: mut_mut)]
#[allow(clippy :: redundant_pub_crate)]
#[allow(clippy :: type_repetition_in_bounds)]
pub(crate) struct Projection<'__pin> where Sleep<>: '__pin {
deadline: &'__pin mut (std::time::Duration),
entry: ::pin_project_lite::__private::Pin<&'__pin mut (TimerEntry)>,
}
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy :: mut_mut)]
#[allow(clippy :: redundant_pub_crate)]
#[allow(clippy :: type_repetition_in_bounds)]
pub(crate) struct ProjectionRef<'__pin> where Sleep<>: '__pin {
deadline: &'__pin (std::time::Duration),
entry: ::pin_project_lite::__private::Pin<&'__pin (TimerEntry)>,
}
impl Sleep<> {
pub(crate) fn project<'__pin>(self:
::pin_project_lite::__private::Pin<&'__pin mut Self>)
-> Projection<'__pin> {
unsafe {
let Self { deadline, entry } = self.get_unchecked_mut();
Projection{deadline: deadline,
entry:
::pin_project_lite::__private::Pin::new_unchecked(entry),}
}
}
pub(crate) fn project_ref<'__pin>(self:
::pin_project_lite::__private::Pin<&'__pin Self>)
-> ProjectionRef<'__pin> {
unsafe {
let Self { deadline, entry } = self.get_ref();
ProjectionRef{deadline: deadline,
entry:
::pin_project_lite::__private::Pin::new_unchecked(entry),}
}
}
}
#[allow(non_snake_case)]
pub struct __Origin<'__pin> {
__dummy_lifetime: ::pin_project_lite::__private::PhantomData<&'__pin ()>,
deadline: ::pin_project_lite::__private::AlwaysUnpin<std::time::Duration>,
entry: TimerEntry,
}
impl <'__pin> ::pin_project_lite::__private::Unpin for Sleep<> where
__Origin<'__pin>: ::pin_project_lite::__private::Unpin {
}
trait MustNotImplDrop { }
#[allow(clippy :: drop_bounds, drop_bounds)]
impl <T: ::pin_project_lite::__private::Drop> MustNotImplDrop for T {
}
impl MustNotImplDrop for Sleep<> { }
#[forbid(safe_packed_borrows)]
fn __assert_not_repr_packed(this: &Sleep<>) {
let _ = &this.deadline;
let _ = &this.entry;
}
};
Rustdoc in turn generates documentation like this:
impl<'__pin> Unpin for Sleep where
__Origin<'__pin>: Unpin,
This is really unfortunate, because __Origin
does not in fact implement Unpin
. Rustdoc shouldn't show trait implementations that can never be applied.
Originally posted by @jyn514 in tokio-rs/tokio#3330 (comment)