linux-stable/rust/kernel
Benno Lossin 674b1c7aed rust: init: add support for arbitrary paths in init macros
Previously only `ident` and generic types were supported in the
`{try_}{pin_}init!` macros. This patch allows arbitrary path fragments,
so for example `Foo::Bar` but also very complex paths such as
`<Foo as Baz>::Bar::<0, i32>`.

Internally this is accomplished by using `path` fragments. Due to some
peculiar declarative macro limitations, we have to "forget" certain
additional parsing information in the token trees. This is achieved by
using the `paste!` proc macro. It does not actually modify the input,
since no `[< >]` will be present in the input, so it just strips the
information held by declarative macros. For example, if a declarative
macro takes `$t:path` as its input, it cannot sensibly propagate this to
a macro that takes `$($p:tt)*` as its input, since the `$t` token will
only be considered one `tt` token for the second macro. If we first pipe
the tokens through `paste!`, then it parses as expected.

Suggested-by: Asahi Lina <lina@asahilina.net>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20230814084602.25699-10-benno.lossin@proton.me
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-08-21 14:31:49 +02:00
..
init rust: init: add support for arbitrary paths in init macros 2023-08-21 14:31:49 +02:00
sync rust: lock: Add intra-doc links to the Backend trait 2023-08-07 11:33:33 +02:00
allocator.rs rust: upgrade to Rust 1.71.1 2023-08-14 17:50:02 +02:00
build_assert.rs rust: upgrade to Rust 1.68.2 2023-05-31 17:35:03 +02:00
error.rs rust: error: impl Debug for Error with errname() integration 2023-06-13 01:24:42 +02:00
init.rs rust: init: add functions to create array initializers 2023-08-21 14:31:49 +02:00
ioctl.rs rust: ioctl: Add ioctl number manipulation functions 2023-04-22 01:46:45 +02:00
lib.rs rust: bindgen: upgrade to 0.65.1 2023-08-15 00:37:22 +02:00
prelude.rs rust: add derive macro for Zeroable 2023-08-21 14:31:48 +02:00
print.rs rust: kernel: Mark rust_fmt_argument as extern "C" 2023-04-06 23:11:04 +02:00
static_assert.rs rust: static_assert: add static_assert! macro 2022-12-04 01:59:16 +01:00
std_vendor.rs rust: upgrade to Rust 1.68.2 2023-05-31 17:35:03 +02:00
str.rs rust: str: add conversion from CStr to CString 2023-05-31 18:53:10 +02:00
sync.rs rust: sync: introduce CondVar 2023-04-22 01:46:45 +02:00
task.rs rust: task: add Send marker to Task 2023-05-31 18:53:10 +02:00
types.rs rust: types: make Opaque be !Unpin 2023-08-10 01:18:34 +02:00