diff options
author | Alice Ryhl <aliceryhl@google.com> | 2025-03-03 08:45:13 +0000 |
---|---|---|
committer | Miguel Ojeda <ojeda@kernel.org> | 2025-03-09 20:52:46 +0100 |
commit | 85525eda4f13c496defc46712348fe0711a59b2b (patch) | |
tree | cf3962a22b8fb10a084c24d29b434b740d559672 /rust/kernel/platform.rs | |
parent | 901b3290bd4dc35e613d13abd03c129e754dd3dd (diff) | |
download | linux-85525eda4f13c496defc46712348fe0711a59b2b.tar.gz linux-85525eda4f13c496defc46712348fe0711a59b2b.tar.bz2 linux-85525eda4f13c496defc46712348fe0711a59b2b.zip |
rust: macros: support additional tokens in quote!
This gives the quote! macro support for the following additional tokens:
* The = token.
* The _ token.
* The # token. (when not followed by an identifier)
* Using #my_var with variables of type Ident.
Additionally, some type annotations are added to allow cases where
groups are empty. For example, quote! does support () in the input, but
only when it is *not* empty. When it is empty, there are zero `.push`
calls, so the compiler can't infer the item type and also emits a
warning about it not needing to be mutable.
These additional quote! features are used by a new proc macro that
generates code looking like this:
const _: () = {
if true {
::kernel::bindings::#name
} else {
#name
};
};
where #name has type Ident.
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Tamir Duberstein <tamird@gmail.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20250303-export-macro-v3-2-41fbad85a27f@google.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/kernel/platform.rs')
0 files changed, 0 insertions, 0 deletions