linux/rust
Benno Lossin 52b7bb46ae rust: macros: replace Self with the concrete type in #[pin_data]
When using `#[pin_data]` on a struct that used `Self` in the field
types, a type error would be emitted when trying to use `pin_init!`.
Since an internal type would be referenced by `Self` instead of the
defined struct.

This patch fixes this issue by replacing all occurrences of `Self` in
the `#[pin_data]` macro with the concrete type circumventing the issue.
Since rust allows type definitions inside of blocks, which are
expressions, the macro also checks for these and emits a compile error
when it finds `trait`, `enum`, `union`, `struct` or `impl`. These
keywords allow creating new `Self` contexts, which conflicts with the
current implementation of replacing every `Self` ident. If these were
allowed, some `Self` idents would be replaced incorrectly.

Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Reported-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/r/20230424081112.99890-3-benno.lossin@proton.me
[ Added newline in commit message ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-05-31 18:53:09 +02:00
..
alloc rust: upgrade to Rust 1.68.2 2023-05-31 17:35:03 +02:00
bindings rust: upgrade to Rust 1.68.2 2023-05-31 17:35:03 +02:00
kernel rust: upgrade to Rust 1.68.2 2023-05-31 17:35:03 +02:00
macros rust: macros: replace Self with the concrete type in #[pin_data] 2023-05-31 18:53:09 +02:00
uapi rust: upgrade to Rust 1.68.2 2023-05-31 17:35:03 +02:00
.gitignore rust: uapi: Add UAPI crate 2023-04-22 01:46:45 +02:00
bindgen_parameters rust: bindgen: Add alt_instr as opaque type 2023-03-02 22:44:15 +01:00
build_error.rs rust: add build_error crate 2022-12-04 01:59:16 +01:00
compiler_builtins.rs rust: compiler_builtins: make stubs non-global 2023-01-16 21:04:34 +01:00
exports.c rust: add build_error crate 2022-12-04 01:59:16 +01:00
helpers.c rust: sync: introduce CondVar 2023-04-22 01:46:45 +02:00
Makefile Rust changes for v6.4 2023-04-30 11:20:22 -07:00