Rust-for-Linux / linux

Adding support for the Rust language to the Linux kernel.
https://rust-for-linux.com
Other
3.83k stars 399 forks source link

make `impl_has_work` compatible with more complex generics #1077

Open y86-dev opened 2 months ago

y86-dev commented 2 months ago

The impl_has_work macro only supports idents as generic arguments:

macro_rules! impl_has_work {
    ($(impl$(<$($implarg:ident),*>)?
       HasWork<$work_type:ty $(, $id:tt)?>
       for $self:ident $(<$($selfarg:ident),*>)?
       { self.$field:ident }
    )*) => {$(

There is a workaround, see Alice's linked list patch:

    macro_rules! impl_list_item {
        (
            impl$({$($generics:tt)*})? ListItem<$num:tt> for $t:ty {
                using ListLinks;
            } $($rest:tt)*
        ) => {

Make the impl_has_work macro compatible with more complex generics such as lifetimes and const generic arguments.


This requires submitting a proper patch to the LKML and the Rust for Linux mailing list. Please recall to test your changes, to use a proper title for the commit, to sign your commit under the Developer's Certificate of Origin and so on. Please see https://docs.kernel.org/process/submitting-patches.html and https://rust-for-linux.com/contributing for details.

Please take this issue only if you are new to the kernel development process and you would like to use it as a test to submit your first patch to the kernel. Please do not take it if you do not plan to make other contributions to the kernel.

mu001999 commented 1 month ago

I'd like to try this, and I sent an email, https://lore.kernel.org/rust-for-linux/ME0P282MB4890167E8316FECBA35D7533CCEB2@ME0P282MB4890.AUSP282.PROD.OUTLOOK.COM/T/#t. I don't know if I did the right thing