diff options
| author | Gary Guo <gary@garyguo.net> | 2026-09-01 17:50:25 +0100 |
|---|---|---|
| committer | Danilo Krummrich <dakr@kernel.org> | 2026-09-03 20:25:54 +0200 |
| commit | 63b2578517df761ec8aed607b29e24c0e2655410 (patch) | |
| tree | 8866bbbb0a39ee1cc7bea4e819e663a7bd1cea26 /scripts/Makefile.thinlto | |
| parent | cee9395acd8043be0644b25c34bfa86623f2b935 (diff) | |
| download | linux-next-63b2578517df761ec8aed607b29e24c0e2655410.tar.gz linux-next-63b2578517df761ec8aed607b29e24c0e2655410.zip | |
rust: io: register: reimplement as proc macro
The existing `register!` macro is implemented as a declarative macro.
Reimplement it as proc macro instead, with no functional changes intended.
The old implementation produces unhelpful diagnostics when things go wrong.
For example, for code like
register! {
pub(crate) TESTREG(u32) {
31:0 data;
}
}
which misses out the "@ offset" part of the specification, and the
following error is produced:
error: no rules expected `{`
--> test.rs:42:5
|
42 | / register! {
43 | | pub(crate) TESTREG(u32) {
44 | | 31:0 data;
... |
100 | | }
| |_____^ no rules expected this token in macro call
which isn't very helpful. With the proc macro implementation, the following
error is produced:
error: expected `@` or `=>`
--> tests.rs:43:33
|
43 | pub(crate) TESTREG(u32) {
| ^
which is much more helpful. Apart from diagnostics, proc macro also has a
benefit of not having follow-set restrictions, which makes syntax like
register!(name: ty @ offset);
possible; declarative macro will reject this as `@` is not in the
follow-set of "ty" metavariable kind.
Signed-off-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Tested-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://patch.msgid.link/20260901-typed_register-v4-1-5552b1d59525@garyguo.net
[ Fix typo in module-level doc comment and fix ArrayDef syntax
description to match the actual macro syntax. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions
