Skip to content

Commit

Permalink
Merge #325
Browse files Browse the repository at this point in the history
325: Hide PinnedDrop impl from docs r=taiki-e a=taiki-e

`PinnedDrop` is a private trait and should not appear in docs.

Co-authored-by: Taiki Endo <te316e89@gmail.com>
  • Loading branch information
bors[bot] and taiki-e authored Apr 13, 2021
2 parents 79a86bc + b6293c9 commit 878dc48
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/pinned_drop-expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ const _: () = {
// Users can implement [`Drop`] safely using `#[pinned_drop]` and can drop a
// type that implements `PinnedDrop` using the [`drop`] function safely.
// **Do not call or implement this trait directly.**
#[doc(hidden)]
impl<T> ::pin_project::__private::PinnedDrop for Struct<'_, T> {
// Since calling it twice on the same object would be UB,
// this method is unsafe.
Expand Down
3 changes: 3 additions & 0 deletions pin-project-internal/src/pinned_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ fn expand_impl(item: &mut ItemImpl) {
None
}

// `PinnedDrop` is a private trait and should not appear in docs.
item.attrs.push(parse_quote!(#[doc(hidden)]));

let path = &mut item.trait_.as_mut().unwrap().1;
*path = parse_quote_spanned! { path.span() =>
::pin_project::__private::PinnedDrop
Expand Down
1 change: 1 addition & 0 deletions tests/expand/pinned_drop/enum.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ const _: () = {
}
}
};
#[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)]
Expand Down
1 change: 1 addition & 0 deletions tests/expand/pinned_drop/struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const _: () = {
}
}
};
#[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)]
Expand Down
1 change: 1 addition & 0 deletions tests/expand/pinned_drop/tuple_struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const _: () = {
}
}
};
#[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)]
Expand Down

0 comments on commit 878dc48

Please sign in to comment.