summaryrefslogtreecommitdiff
path: root/rust/kernel/error.rs
diff options
context:
space:
mode:
authorBenno Lossin <benno.lossin@proton.me>2023-04-24 08:11:43 +0000
committerMiguel Ojeda <ojeda@kernel.org>2023-05-31 18:53:09 +0200
commit52b7bb46ae79fb6ff0fd806e22f5b4f5c66b71f0 (patch)
tree4d6e82f3766f46db17919d3406aacb0c2e2b9f21 /rust/kernel/error.rs
parente957b9cda31d5114905b0485af02d332fbd079d7 (diff)
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>
Diffstat (limited to 'rust/kernel/error.rs')
0 files changed, 0 insertions, 0 deletions