mirror of
https://github.com/openharmony/third_party_rust_pin-project-lite.git
synced 2026-07-01 20:44:14 -04:00
Reorder rules in __pin_project_internal!.
This isn't useful by itself, but it sets things up for the next commit, which will break `__pin_project_internal!` into a number of smaller macros.
This commit is contained in:
+86
-86
@@ -310,25 +310,6 @@ macro_rules! pin_project {
|
||||
#[doc(hidden)]
|
||||
#[macro_export]
|
||||
macro_rules! __pin_project_internal {
|
||||
// macro helpers
|
||||
// ignores any projection without a projection identity
|
||||
(@make_proj_ty;
|
||||
[] // no identity given, so we ignore the projection
|
||||
$($field:tt)*
|
||||
) => {};
|
||||
// ignores make_proj_replace_ty without a projection identity
|
||||
(@make_proj_replace_ty;
|
||||
[] // no identity given, so we ignore the projection
|
||||
$($field:tt)*
|
||||
) => {};
|
||||
(@$struct_ty_ident:ident=>make_proj_method;
|
||||
[]
|
||||
$($variant:tt)*
|
||||
) => {};
|
||||
(@$struct_ty_ident:ident=>make_proj_replace_method;
|
||||
[]
|
||||
$($field:tt)*
|
||||
) => {};
|
||||
// =============================================================================================
|
||||
// struct:main
|
||||
(@expand;
|
||||
@@ -690,49 +671,12 @@ macro_rules! __pin_project_internal {
|
||||
),+
|
||||
}
|
||||
};
|
||||
// construct a projected type
|
||||
// macro helpers
|
||||
// ignores any projection without a projection identity
|
||||
(@make_proj_ty;
|
||||
[$proj_ty_ident:ident]
|
||||
[$proj_vis:vis $struct_ty_ident:ident $ident:ident]
|
||||
[$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)* )?]
|
||||
[$($body_data:tt)+]
|
||||
) => {
|
||||
#[allow(dead_code)] // This lint warns unused fields/variants.
|
||||
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
|
||||
// This lint warns of `clippy::*` generated by external macros.
|
||||
// We allow this lint for compatibility with older compilers.
|
||||
#[allow(clippy::unknown_clippy_lints)]
|
||||
#[allow(clippy::mut_mut)] // This lint warns `&mut &mut <ty>`. (only needed for project)
|
||||
#[allow(clippy::redundant_pub_crate)] // This lint warns `pub(crate)` field in private struct.
|
||||
#[allow(clippy::ref_option_ref)] // This lint warns `&Option<&<ty>>`. (only needed for project_ref)
|
||||
#[allow(clippy::type_repetition_in_bounds)] // https://github.com/rust-lang/rust-clippy/issues/4326
|
||||
$proj_vis $struct_ty_ident $proj_ty_ident <'__pin, $($impl_generics)*>
|
||||
where
|
||||
$ident <$($ty_generics)*>: '__pin
|
||||
$(, $($where_clause)*)?
|
||||
{
|
||||
$($body_data)+
|
||||
}
|
||||
};
|
||||
// construct a project_replace type
|
||||
(@make_proj_replace_ty;
|
||||
[$proj_ty_ident:ident]
|
||||
[$proj_vis:vis $struct_ty_ident:ident]
|
||||
[$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)* )?]
|
||||
[$($body_data:tt)+]
|
||||
) => {
|
||||
#[allow(dead_code)] // This lint warns unused fields/variants.
|
||||
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
|
||||
#[allow(clippy::mut_mut)] // This lint warns `&mut &mut <ty>`. (only needed for project)
|
||||
#[allow(clippy::redundant_pub_crate)] // This lint warns `pub(crate)` field in private struct.
|
||||
#[allow(clippy::type_repetition_in_bounds)] // https://github.com/rust-lang/rust-clippy/issues/4326
|
||||
$proj_vis $struct_ty_ident $proj_ty_ident <$($impl_generics)*>
|
||||
where
|
||||
$($($where_clause)*)?
|
||||
{
|
||||
$($body_data)+
|
||||
}
|
||||
};
|
||||
[] // no identity given, so we ignore the projection
|
||||
$($field:tt)*
|
||||
) => {};
|
||||
// =============================================================================================
|
||||
// struct:make_proj_ty
|
||||
// if a proj_ty_ident was given, we do *not* create one with the default
|
||||
@@ -766,31 +710,6 @@ macro_rules! __pin_project_internal {
|
||||
]
|
||||
}
|
||||
};
|
||||
(@make_proj_replace_ty;
|
||||
[$proj_ty_ident:ident]
|
||||
[$proj_vis:vis struct]
|
||||
[$make_proj_field:ident]
|
||||
[$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)* )?]
|
||||
{
|
||||
$(
|
||||
$(#[$pin:ident])?
|
||||
$field_vis:vis $field:ident: $field_ty:ty
|
||||
),+ $(,)?
|
||||
}
|
||||
) => {
|
||||
$crate::__pin_project_internal!{@make_proj_replace_ty;
|
||||
[$proj_ty_ident]
|
||||
[$proj_vis struct]
|
||||
[$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)* )?]
|
||||
[
|
||||
$(
|
||||
$field_vis $field: $crate::__pin_project_internal!(@$make_proj_field;
|
||||
$(#[$pin])? $field_ty
|
||||
)
|
||||
),+
|
||||
]
|
||||
}
|
||||
};
|
||||
// =============================================================================================
|
||||
// enum:make_proj_ty
|
||||
(@make_proj_ty;
|
||||
@@ -827,6 +746,60 @@ macro_rules! __pin_project_internal {
|
||||
]
|
||||
}
|
||||
};
|
||||
// construct a projected type
|
||||
(@make_proj_ty;
|
||||
[$proj_ty_ident:ident]
|
||||
[$proj_vis:vis $struct_ty_ident:ident $ident:ident]
|
||||
[$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)* )?]
|
||||
[$($body_data:tt)+]
|
||||
) => {
|
||||
#[allow(dead_code)] // This lint warns unused fields/variants.
|
||||
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
|
||||
// This lint warns of `clippy::*` generated by external macros.
|
||||
// We allow this lint for compatibility with older compilers.
|
||||
#[allow(clippy::unknown_clippy_lints)]
|
||||
#[allow(clippy::mut_mut)] // This lint warns `&mut &mut <ty>`. (only needed for project)
|
||||
#[allow(clippy::redundant_pub_crate)] // This lint warns `pub(crate)` field in private struct.
|
||||
#[allow(clippy::ref_option_ref)] // This lint warns `&Option<&<ty>>`. (only needed for project_ref)
|
||||
#[allow(clippy::type_repetition_in_bounds)] // https://github.com/rust-lang/rust-clippy/issues/4326
|
||||
$proj_vis $struct_ty_ident $proj_ty_ident <'__pin, $($impl_generics)*>
|
||||
where
|
||||
$ident <$($ty_generics)*>: '__pin
|
||||
$(, $($where_clause)*)?
|
||||
{
|
||||
$($body_data)+
|
||||
}
|
||||
};
|
||||
// ignores make_proj_replace_ty without a projection identity
|
||||
(@make_proj_replace_ty;
|
||||
[] // no identity given, so we ignore the projection
|
||||
$($field:tt)*
|
||||
) => {};
|
||||
(@make_proj_replace_ty;
|
||||
[$proj_ty_ident:ident]
|
||||
[$proj_vis:vis struct]
|
||||
[$make_proj_field:ident]
|
||||
[$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)* )?]
|
||||
{
|
||||
$(
|
||||
$(#[$pin:ident])?
|
||||
$field_vis:vis $field:ident: $field_ty:ty
|
||||
),+ $(,)?
|
||||
}
|
||||
) => {
|
||||
$crate::__pin_project_internal!{@make_proj_replace_ty;
|
||||
[$proj_ty_ident]
|
||||
[$proj_vis struct]
|
||||
[$($impl_generics)*] [$($ty_generics)*] [$(where $($where_clause)* )?]
|
||||
[
|
||||
$(
|
||||
$field_vis $field: $crate::__pin_project_internal!(@$make_proj_field;
|
||||
$(#[$pin])? $field_ty
|
||||
)
|
||||
),+
|
||||
]
|
||||
}
|
||||
};
|
||||
(@make_proj_replace_ty;
|
||||
[$proj_ty_ident:ident]
|
||||
[$proj_vis:vis enum]
|
||||
@@ -861,6 +834,25 @@ macro_rules! __pin_project_internal {
|
||||
]
|
||||
}
|
||||
};
|
||||
// construct a project_replace type
|
||||
(@make_proj_replace_ty;
|
||||
[$proj_ty_ident:ident]
|
||||
[$proj_vis:vis $struct_ty_ident:ident]
|
||||
[$($impl_generics:tt)*] [$($ty_generics:tt)*] [$(where $($where_clause:tt)* )?]
|
||||
[$($body_data:tt)+]
|
||||
) => {
|
||||
#[allow(dead_code)] // This lint warns unused fields/variants.
|
||||
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
|
||||
#[allow(clippy::mut_mut)] // This lint warns `&mut &mut <ty>`. (only needed for project)
|
||||
#[allow(clippy::redundant_pub_crate)] // This lint warns `pub(crate)` field in private struct.
|
||||
#[allow(clippy::type_repetition_in_bounds)] // https://github.com/rust-lang/rust-clippy/issues/4326
|
||||
$proj_vis $struct_ty_ident $proj_ty_ident <$($impl_generics)*>
|
||||
where
|
||||
$($($where_clause)*)?
|
||||
{
|
||||
$($body_data)+
|
||||
}
|
||||
};
|
||||
// =============================================================================================
|
||||
(@make_proj_replace_block;
|
||||
[$($proj_path: tt)+]
|
||||
@@ -898,6 +890,10 @@ macro_rules! __pin_project_internal {
|
||||
// =============================================================================================
|
||||
// struct:make_proj_method
|
||||
// this employs an ignored default strategy that ensures the identity used matches the one used in `struct=>make_proj_ty`
|
||||
(@$struct_ty_ident:ident=>make_proj_method;
|
||||
[]
|
||||
$($variant:tt)*
|
||||
) => {};
|
||||
(@struct=>make_proj_method;
|
||||
[$proj_ty_ident:ident $_ignored_default_arg:ident]
|
||||
[$proj_vis:vis]
|
||||
@@ -941,6 +937,10 @@ macro_rules! __pin_project_internal {
|
||||
}
|
||||
};
|
||||
|
||||
(@$struct_ty_ident:ident=>make_proj_replace_method;
|
||||
[]
|
||||
$($field:tt)*
|
||||
) => {};
|
||||
(@struct=>make_proj_replace_method;
|
||||
[$proj_ty_ident:ident]
|
||||
[$proj_vis:vis]
|
||||
|
||||
Reference in New Issue
Block a user