forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 474
Commit 2a88e8a
committed
rust: macros: rewrite
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]>#[pin_data]
using syn
1 parent bdb4cff commit 2a88e8aCopy full SHA for 2a88e8a
File tree
Expand file treeCollapse file tree
3 files changed
+300
-603
lines changedFilter options
- rust
- kernel/init
- macros
Expand file treeCollapse file tree
3 files changed
+300
-603
lines changed
0 commit comments