Skip to content

Commit 2a88e8a

Browse files
committed
rust: macros: rewrite #[pin_data] using syn
Now that `syn` and `quote` are available in the Kernel use them for the `#[pin_data]` proc-macro attribute instead of the current hybrid proc-macro/declarative approach. Proc-macros written using `syn` are a lot more readable and thus easier to maintain than convoluted declarative macros. An additional advantage of `syn` is the improved error reporting, here is an example: #[pin_data] struct Foo { x } Prior to this patch, the error reads: error: expected `:`, found `}` --> samples/rust/rust_minimal.rs:43:1 | 41 | struct Foo { | --- while parsing this struct 42 | x | - expected `:` 43 | } | ^ unexpected token error: recursion limit reached while expanding `$crate::__pin_data!` --> samples/rust/rust_minimal.rs:40:1 | 40 | #[pin_data] | ^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`rust_minimal`) = note: this error originates in the macro `$crate::__pin_data` which comes from the expansion of the attribute macro `pin_data` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors After this patch, the error reads: error: expected `:`, found `}` --> samples/rust/rust_minimal.rs:43:1 | 41 | struct Foo { | --- while parsing this struct 42 | x | - expected `:` 43 | } | ^ unexpected token error: aborting due to 1 previous error Signed-off-by: Benno Lossin <[email protected]>
1 parent bdb4cff commit 2a88e8a

File tree

3 files changed

+300
-603
lines changed

3 files changed

+300
-603
lines changed

0 commit comments

Comments
 (0)