| 42ec9800 | 06-Apr-2026 |
Miguel Ojeda <ojeda@kernel.org> |
rust: macros: simplify code using `feature(extract_if)`
`feature(extract_if)` [1] was stabilized in Rust 1.87.0 [2], and the last significant change happened in Rust 1.85.0 [3] when the range parame
rust: macros: simplify code using `feature(extract_if)`
`feature(extract_if)` [1] was stabilized in Rust 1.87.0 [2], and the last significant change happened in Rust 1.85.0 [3] when the range parameter was added.
That is, with our new minimum version, we can start using the feature.
Thus simplify the code using the feature and remove the TODO comment.
Suggested-by: Gary Guo <gary@garyguo.net> Link: https://lore.kernel.org/rust-for-linux/DHHVSX66206Y.3E7I9QUNTCJ8I@garyguo.net/ Link: https://github.com/rust-lang/rust/issues/43244 [1] Link: https://github.com/rust-lang/rust/pull/137109 [2] Link: https://github.com/rust-lang/rust/pull/133265 [3] Link: https://patch.msgid.link/20260405235309.418950-16-ojeda@kernel.org Reviewed-by: Tamir Duberstein <tamird@kernel.org> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| 7ed18860 | 06-Apr-2026 |
Miguel Ojeda <ojeda@kernel.org> |
rust: allow globally `clippy::incompatible_msrv`
`clippy::incompatible_msrv` is not buying us much, and we discussed allowing it several times in the past.
For instance, there was recently another
rust: allow globally `clippy::incompatible_msrv`
`clippy::incompatible_msrv` is not buying us much, and we discussed allowing it several times in the past.
For instance, there was recently another patch sent to `allow` it where needed [1]. While that particular case would not be needed after the minimum version bump to 1.85.0, it is simpler to just allow it to prevent future instances.
[ In addition, the lint fired without taking into account the features that have been enabled in a crate [2]. While this was improved in Rust 1.90.0 [3], it would still fire in a case like this patch. ]
Thus do so, and remove the last instance of locally allowing it we have in the tree (except the one in the vendored `proc_macro2` crate).
Note that we still keep the `msrv` config option in `clippy.toml` since that affects other lints as well.
Link: https://lore.kernel.org/rust-for-linux/20260404212831.78971-4-jhubbard@nvidia.com/ [1] Link: https://github.com/rust-lang/rust-clippy/issues/14425 [2] Link: https://github.com/rust-lang/rust-clippy/pull/14433 [3] Link: https://patch.msgid.link/20260405235309.418950-8-ojeda@kernel.org Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Tamir Duberstein <tamird@kernel.org> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| 779f6e3e | 13-Jan-2026 |
Gary Guo <gary@garyguo.net> |
rust: macros: support `#[cfg]` properly in `#[vtable]` macro.
Currently, we generate `HAS_` constants as long as the definition exists in the source, regardless if it is cfg-ed out or not.
Currentl
rust: macros: support `#[cfg]` properly in `#[vtable]` macro.
Currently, we generate `HAS_` constants as long as the definition exists in the source, regardless if it is cfg-ed out or not.
Currently, uses of `#[cfg]` present in both trait and impl, so it is not a problem; however if only the impl side uses `#[cfg]` then `HAS_` constants will incorrectly be true while it shouldnt't.
With `syn` support, we can now implement `#[cfg]` handling properly by propagating the `#[cfg]` attributes to the constants.
Signed-off-by: Gary Guo <gary@garyguo.net> Reviewed-by: Benno Lossin <lossin@kernel.org> Link: https://patch.msgid.link/20260113170529.2240744-1-gary@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| be97f3c8 | 12-Jan-2026 |
Gary Guo <gary@garyguo.net> |
rust: kunit: use `pin_init::zeroed` instead of custom null value
The last null element can be created (constly) using `pin_init::zeroed`, so prefer to use it instead of adding a custom way of buildi
rust: kunit: use `pin_init::zeroed` instead of custom null value
The last null element can be created (constly) using `pin_init::zeroed`, so prefer to use it instead of adding a custom way of building it.
Reviewed-by: Tamir Duberstein <tamird@gmail.com> Reviewed-by: Benno Lossin <lossin@kernel.org> Signed-off-by: Gary Guo <gary@garyguo.net> Reviewed-by: David Gow <davidgow@google.com> Link: https://patch.msgid.link/20260112170919.1888584-12-gary@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| d421fa4f | 12-Jan-2026 |
Gary Guo <gary@garyguo.net> |
rust: macros: rearrange `#[doc(hidden)]` in `module!` macro
This `#[doc(hidden)]` can just be applied on a module to hide anything within.
Reviewed-by: Tamir Duberstein <tamird@gmail.com> Reviewed-
rust: macros: rearrange `#[doc(hidden)]` in `module!` macro
This `#[doc(hidden)]` can just be applied on a module to hide anything within.
Reviewed-by: Tamir Duberstein <tamird@gmail.com> Reviewed-by: Benno Lossin <lossin@kernel.org> Signed-off-by: Gary Guo <gary@garyguo.net> Link: https://patch.msgid.link/20260112170919.1888584-11-gary@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| 3d5731a6 | 12-Jan-2026 |
Gary Guo <gary@garyguo.net> |
rust: macros: allow arbitrary types to be used in `module!` macro
Previously this only accepts an identifier, but now with `syn` it is easy to make it accepts any type.
Reviewed-by: Benno Lossin <l
rust: macros: allow arbitrary types to be used in `module!` macro
Previously this only accepts an identifier, but now with `syn` it is easy to make it accepts any type.
Reviewed-by: Benno Lossin <lossin@kernel.org> Signed-off-by: Gary Guo <gary@garyguo.net> Link: https://patch.msgid.link/20260112170919.1888584-10-gary@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| c3b416e1 | 12-Jan-2026 |
Gary Guo <gary@garyguo.net> |
rust: macros: convert `#[kunit_tests]` macro to use `syn`
Make use of `syn` to parse the module structurally and thus improve the robustness of parsing.
String interpolation is avoided by generatin
rust: macros: convert `#[kunit_tests]` macro to use `syn`
Make use of `syn` to parse the module structurally and thus improve the robustness of parsing.
String interpolation is avoided by generating tokens directly using `quote!`.
Reviewed-by: Tamir Duberstein <tamird@gmail.com> Signed-off-by: Gary Guo <gary@garyguo.net> Reviewed-by: Benno Lossin <lossin@kernel.org> Reviewed-by: David Gow <davidgow@google.com> Link: https://patch.msgid.link/20260112170919.1888584-9-gary@kernel.org [ Pass C string to match commit 6c37b6841a92 ("rust: kunit: replace `kernel::c_str!` with C-Strings"). - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| a863b21b | 12-Jan-2026 |
Gary Guo <gary@garyguo.net> |
rust: macros: convert `concat_idents!` to use `syn`
This eliminates the need for `expect_punct` helper.
Reviewed-by: Tamir Duberstein <tamird@gmail.com> Reviewed-by: Benno Lossin <lossin@kernel.org
rust: macros: convert `concat_idents!` to use `syn`
This eliminates the need for `expect_punct` helper.
Reviewed-by: Tamir Duberstein <tamird@gmail.com> Reviewed-by: Benno Lossin <lossin@kernel.org> Signed-off-by: Gary Guo <gary@garyguo.net> Link: https://patch.msgid.link/20260112170919.1888584-8-gary@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| 8db9164b | 12-Jan-2026 |
Gary Guo <gary@garyguo.net> |
rust: macros: convert `#[export]` to use `syn`
This eliminates the custom `function_name` helper.
Reviewed-by: Tamir Duberstein <tamird@gmail.com> Reviewed-by: Benno Lossin <lossin@kernel.org> Sign
rust: macros: convert `#[export]` to use `syn`
This eliminates the custom `function_name` helper.
Reviewed-by: Tamir Duberstein <tamird@gmail.com> Reviewed-by: Benno Lossin <lossin@kernel.org> Signed-off-by: Gary Guo <gary@garyguo.net> Link: https://patch.msgid.link/20260112170919.1888584-7-gary@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| 5f704577 | 12-Jan-2026 |
Gary Guo <gary@garyguo.net> |
rust: macros: use `quote!` for `module!` macro
This has no behavioural change, but is good for maintainability. With `quote!`, we're no longer using string templates, so we don't need to quote " and
rust: macros: use `quote!` for `module!` macro
This has no behavioural change, but is good for maintainability. With `quote!`, we're no longer using string templates, so we don't need to quote " and {} inside the template anymore. Further more, editors can now highlight the code template.
This also improves the robustness as it eliminates the need for string quoting and escaping.
Co-developed-by: Benno Lossin <lossin@kernel.org> Signed-off-by: Benno Lossin <lossin@kernel.org> Signed-off-by: Gary Guo <gary@garyguo.net> Link: https://patch.msgid.link/20260112170919.1888584-6-gary@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| c578ad70 | 12-Jan-2026 |
Gary Guo <gary@garyguo.net> |
rust: macros: use `syn` to parse `module!` macro
With `syn` being available in the kernel, use it to parse the complex custom `module!` macro to replace existing helpers. Only parsing is changed in
rust: macros: use `syn` to parse `module!` macro
With `syn` being available in the kernel, use it to parse the complex custom `module!` macro to replace existing helpers. Only parsing is changed in this commit, the code generation is untouched.
This has the benefit of better error message when the macro is used incorrectly, as it can point to a concrete span on what's going wrong.
For example, if a field is specified twice, previously it reads:
error: proc macro panicked --> samples/rust/rust_minimal.rs:7:1 | 7 | / module! { 8 | | type: RustMinimal, 9 | | name: "rust_minimal", 10 | | author: "Rust for Linux Contributors", 11 | | description: "Rust minimal sample", 12 | | license: "GPL", 13 | | license: "GPL", 14 | | } | |_^ | = help: message: Duplicated key "license". Keys can only be specified once.
now it reads:
error: duplicated key "license". Keys can only be specified once. --> samples/rust/rust_minimal.rs:13:5 | 13 | license: "GPL", | ^^^^^^^
Reviewed-by: Tamir Duberstein <tamird@gmail.com> Signed-off-by: Gary Guo <gary@garyguo.net> Reviewed-by: Benno Lossin <lossin@kernel.org> Link: https://patch.msgid.link/20260112170919.1888584-5-gary@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| 5f160950 | 12-Jan-2026 |
Gary Guo <gary@garyguo.net> |
rust: macros: convert `#[vtable]` macro to use `syn`
`#[vtable]` is converted to use syn. This is more robust than the previous heuristic-based searching of defined methods and functions.
When doin
rust: macros: convert `#[vtable]` macro to use `syn`
`#[vtable]` is converted to use syn. This is more robust than the previous heuristic-based searching of defined methods and functions.
When doing so, the trait and impl are split into two code paths as the types are distinct when parsed by `syn`.
Reviewed-by: Tamir Duberstein <tamird@gmail.com> Signed-off-by: Gary Guo <gary@garyguo.net> Reviewed-by: Benno Lossin <lossin@kernel.org> Link: https://patch.msgid.link/20260112170919.1888584-4-gary@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| 7f87c7a0 | 30-Nov-2025 |
Peter Novak <seimun018r@gmail.com> |
rust: use consistent backtick formatting for NULL in docs
Some doc comments use `NULL` while others use plain NULL. Make it consistent by adding backticks everywhere, matching the majority of exist
rust: use consistent backtick formatting for NULL in docs
Some doc comments use `NULL` while others use plain NULL. Make it consistent by adding backticks everywhere, matching the majority of existing usage.
Signed-off-by: Peter Novak <seimun018r@gmail.com> Acked-by: Stephen Boyd <sboyd@kernel.org> Acked-by: David Gow <davidgow@google.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Acked-by: Danilo Krummrich <dakr@kernel.org> Link: https://patch.msgid.link/20251130211233.367946-1-seimun018r@gmail.com [ Reworded slightly. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| 81a304f5 | 14-Jan-2026 |
FUJITA Tomonori <fujita.tomonori@gmail.com> |
rust: macros: ignore example with module parameters
`ModuleParamAccess` uses `SetOnce`, which depends on the helper functions so the `macros` crate example under `rusttest` fails to build:
----
rust: macros: ignore example with module parameters
`ModuleParamAccess` uses `SetOnce`, which depends on the helper functions so the `macros` crate example under `rusttest` fails to build:
---- rust/macros/lib.rs - module (line 62) stdout ---- error: linking with `cc` failed: exit status: 1 | = note: "cc" "-m64" ... = note: some arguments are omitted. use `--verbose` to show all linker arguments = note: rust-lld: error: undefined symbol: rust_helper_atomic_try_cmpxchg_relaxed >>> referenced by kernel.ecd446ce39a5fcbb-cgu.3 >>> kernel.kernel.ecd446ce39a5fcbb-cgu.3.rcgu.o:(kernel::sync::set_once::SetOnce$LT$T$GT$::populate::h8b02644e30bd70bc) in archive ./rust/test/libkernel.rlib
rust-lld: error: undefined symbol: rust_helper_atomic_set_release >>> referenced by kernel.ecd446ce39a5fcbb-cgu.3 >>> kernel.kernel.ecd446ce39a5fcbb-cgu.3.rcgu.o:(kernel::sync::set_once::SetOnce$LT$T$GT$::populate::h8b02644e30bd70bc) in archive ./rust/test/libkernel.rlib collect2: error: ld returned 1 exit status
Thus ignore that example to fix the error.
[ Only the first one is needed (the other example does not use parameters), so we can keep it enabled. Thus I removed that second deletion (and reworded a bit).
We may want to do something better here later on; on the other hand, we should get KUnit tests for `macros` too eventually, so we may end up removing or repurposing that target anyway, so it is not a big deal.
- Miguel ]
Reported-by: Miguel Ojeda <ojeda@kernel.org> Closes: https://lore.kernel.org/rust-for-linux/CANiq72mEYacdZmHKvpbahJzO_X_qqYyiSiSTYaWEQZAfp6sbxg@mail.gmail.com/ Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Fixes: 0b24f9740f26 ("rust: module: update the module macro with module parameter support") Link: https://patch.msgid.link/20251210.082603.290476643413141778.fujita.tomonori@gmail.com Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| 0b24f974 | 24-Sep-2025 |
Andreas Hindborg <a.hindborg@kernel.org> |
rust: module: update the module macro with module parameter support
Allow module parameters to be declared in the rust `module!` macro.
Reviewed-by: Benno Lossin <lossin@kernel.org> Signed-off-by:
rust: module: update the module macro with module parameter support
Allow module parameters to be declared in the rust `module!` macro.
Reviewed-by: Benno Lossin <lossin@kernel.org> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org> Tested-by: Daniel Gomez <da.gomez@samsung.com> Signed-off-by: Daniel Gomez <da.gomez@kernel.org>
show more ...
|