Skip to content

Commit 9cec86e

Browse files
tamirdojeda
authored andcommitted
rust: list: use consistent type parameter style
Refer to the type parameters of `impl_has_list_links{,_self_ptr}!` by the same name used in `impl_list_item!`. Capture type parameters of `impl_list_item!` as `tt` using `{}` to match the style of all other macros that work with generics. Reviewed-by: Christian Schrefl <chrisi.schrefl@gmail.com> Tested-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Tamir Duberstein <tamird@gmail.com> Link: https://lore.kernel.org/r/20250709-list-no-offset-v4-2-a429e75840a9@gmail.com Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent e71d7e3 commit 9cec86e

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

rust/kernel/list/impl_list_item_mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub unsafe trait HasListLinks<const ID: u64 = 0> {
4141
/// Implements the [`HasListLinks`] trait for the given type.
4242
#[macro_export]
4343
macro_rules! impl_has_list_links {
44-
($(impl$(<$($implarg:ident),*>)?
44+
($(impl$({$($generics:tt)*})?
4545
HasListLinks$(<$id:tt>)?
4646
for $self:ty
4747
{ self$(.$field:ident)* }
@@ -51,7 +51,7 @@ macro_rules! impl_has_list_links {
5151
//
5252
// The behavior of `raw_get_list_links` is not changed since the `addr_of_mut!` macro is
5353
// equivalent to the pointer offset operation in the trait definition.
54-
unsafe impl$(<$($implarg),*>)? $crate::list::HasListLinks$(<$id>)? for $self {
54+
unsafe impl$(<$($generics)*>)? $crate::list::HasListLinks$(<$id>)? for $self {
5555
const OFFSET: usize = ::core::mem::offset_of!(Self, $($field).*) as usize;
5656

5757
#[inline]
@@ -81,16 +81,16 @@ where
8181
/// Implements the [`HasListLinks`] and [`HasSelfPtr`] traits for the given type.
8282
#[macro_export]
8383
macro_rules! impl_has_list_links_self_ptr {
84-
($(impl$({$($implarg:tt)*})?
84+
($(impl$({$($generics:tt)*})?
8585
HasSelfPtr<$item_type:ty $(, $id:tt)?>
8686
for $self:ty
8787
{ self.$field:ident }
8888
)*) => {$(
8989
// SAFETY: The implementation of `raw_get_list_links` only compiles if the field has the
9090
// right type.
91-
unsafe impl$(<$($implarg)*>)? $crate::list::HasSelfPtr<$item_type $(, $id)?> for $self {}
91+
unsafe impl$(<$($generics)*>)? $crate::list::HasSelfPtr<$item_type $(, $id)?> for $self {}
9292

93-
unsafe impl$(<$($implarg)*>)? $crate::list::HasListLinks$(<$id>)? for $self {
93+
unsafe impl$(<$($generics)*>)? $crate::list::HasListLinks$(<$id>)? for $self {
9494
const OFFSET: usize = ::core::mem::offset_of!(Self, $field) as usize;
9595

9696
#[inline]

0 commit comments

Comments
 (0)