Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Sep 21, 2020
1 parent 99c34e0 commit 9579d1e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 28 deletions.
34 changes: 10 additions & 24 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,7 @@ macro_rules! __pin_project_internal {
[$proj_vis:vis]
[$(#[$attrs:meta])* $vis:vis struct $ident:ident]
[$($def_generics:tt)*]
[$($impl_generics:tt)*]
[$($ty_generics:tt)*]
[$(where $($where_clause:tt)*)?]
[$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)*)?]
{
$(
$(#[$pin:ident])?
Expand All @@ -216,9 +214,7 @@ macro_rules! __pin_project_internal {
$crate::__pin_project_internal! { @make_proj_ty_struct;
[$proj_vis]
[$vis struct $ident]
[$($impl_generics)*]
[$($ty_generics)*]
[$(where $($where_clause)*)?]
[$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
{
$(
$(#[$pin])?
Expand All @@ -233,7 +229,7 @@ macro_rules! __pin_project_internal {
{
$proj_vis fn project<'__pin>(
self: $crate::__private::Pin<&'__pin mut Self>,
) -> Projection<'__pin, $($ty_generics)*> {
) -> Projection <'__pin, $($ty_generics)*> {
unsafe {
let Self { $($field),* } = self.get_unchecked_mut();
Projection {
Expand All @@ -247,7 +243,7 @@ macro_rules! __pin_project_internal {
}
$proj_vis fn project_ref<'__pin>(
self: $crate::__private::Pin<&'__pin Self>,
) -> ProjectionRef<'__pin, $($ty_generics)*> {
) -> ProjectionRef <'__pin, $($ty_generics)*> {
unsafe {
let Self { $($field),* } = self.get_ref();
ProjectionRef {
Expand All @@ -263,9 +259,7 @@ macro_rules! __pin_project_internal {

$crate::__pin_project_internal! { @make_unpin_impl;
[$vis $ident]
[$($impl_generics)*]
[$($ty_generics)*]
[$(where $($where_clause)*)?]
[$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
$(
$field: $crate::__pin_project_internal!(@make_unpin_bound;
$(#[$pin])? $field_ty
Expand All @@ -275,9 +269,7 @@ macro_rules! __pin_project_internal {

$crate::__pin_project_internal! { @make_drop_impl;
[$ident]
[$($impl_generics)*]
[$($ty_generics)*]
[$(where $($where_clause)*)?]
[$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)*)?]
}

// Ensure that it's impossible to use pin projections on a #[repr(packed)] struct.
Expand All @@ -299,7 +291,7 @@ macro_rules! __pin_project_internal {
$($where_clause)*)?
{
$(
&this.$field;
let _ = &this.$field;
)+
}
};
Expand All @@ -310,9 +302,7 @@ macro_rules! __pin_project_internal {
(@make_proj_ty_struct;
[$proj_vis:vis]
[$vis:vis struct $ident:ident]
[$($impl_generics:tt)*]
[$($ty_generics:tt)*]
[$(where $($where_clause:tt)* )?]
[$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)* )?]
{
$(
$(#[$pin:ident])?
Expand Down Expand Up @@ -353,9 +343,7 @@ macro_rules! __pin_project_internal {
// make_unpin_impl
(@make_unpin_impl;
[$vis:vis $ident:ident]
[$($impl_generics:tt)*]
[$($ty_generics:tt)*]
[$(where $($where_clause:tt)* )?]
[$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)* )?]
$($field:tt)*
) => {
// Automatically create the appropriate conditional `Unpin` implementation.
Expand Down Expand Up @@ -402,9 +390,7 @@ macro_rules! __pin_project_internal {
// make_drop_impl
(@make_drop_impl;
[$ident:ident]
[$($impl_generics:tt)*]
[$($ty_generics:tt)*]
[$(where $($where_clause:tt)* )?]
[$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)* )?]
) => {
// Ensure that struct does not implement `Drop`.
//
Expand Down
4 changes: 2 additions & 2 deletions tests/expand/tests/expand/default-struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ const _: () = {
impl<T, U> MustNotImplDrop for Struct<T, U> {}
#[deny(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
&this.pinned;
&this.unpinned;
let _ = &this.pinned;
let _ = &this.unpinned;
}
};
fn main() {}
4 changes: 2 additions & 2 deletions tests/expand/tests/expand/pub-struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ const _: () = {
impl<T, U> MustNotImplDrop for Struct<T, U> {}
#[deny(safe_packed_borrows)]
fn __assert_not_repr_packed<T, U>(this: &Struct<T, U>) {
&this.pinned;
&this.unpinned;
let _ = &this.pinned;
let _ = &this.unpinned;
}
};
fn main() {}

0 comments on commit 9579d1e

Please sign in to comment.