aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/rust/pin-init/internal/src/lib.rs
diff options
context:
space:
mode:
authorBenno Lossin <benno.lossin@proton.me>2025-03-08 11:05:22 +0000
committerMiguel Ojeda <ojeda@kernel.org>2025-03-16 21:59:19 +0100
commit7cb5dee4c8349f8cc3e1ce529df4e18ebe3fed2e (patch)
treef32e72a97a86c03d1f1bf92a03ef2ecadef097f5 /rust/pin-init/internal/src/lib.rs
parentrust: pin-init: synchronize documentation with the user-space version (diff)
downloadwireguard-linux-7cb5dee4c8349f8cc3e1ce529df4e18ebe3fed2e.tar.xz
wireguard-linux-7cb5dee4c8349f8cc3e1ce529df4e18ebe3fed2e.zip
rust: pin-init: internal: synchronize with user-space version
Synchronize the internal macros crate with the user-space version that uses the quote crate [1] instead of a custom `quote!` macro. The imports in the different version are achieved using `cfg` on the kernel config value. This cfg is always set in the kernel and never set in the user-space version. Since the quote crate requires the proc_macro2 crate, imports also need to be adjusted and `.into()` calls have to be inserted. Link: https://crates.io/crates/quote [1] Signed-off-by: Benno Lossin <benno.lossin@proton.me> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org> Tested-by: Andreas Hindborg <a.hindborg@kernel.org> Reviewed-by: Fiona Behrens <me@Kloenk.dev> Link: https://lore.kernel.org/r/20250308110339.2997091-19-benno.lossin@proton.me Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/pin-init/internal/src/lib.rs')
-rw-r--r--rust/pin-init/internal/src/lib.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/rust/pin-init/internal/src/lib.rs b/rust/pin-init/internal/src/lib.rs
index c201b8a53915..30e145f80bc0 100644
--- a/rust/pin-init/internal/src/lib.rs
+++ b/rust/pin-init/internal/src/lib.rs
@@ -7,6 +7,13 @@
//! `pin-init` proc macros.
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
+// Allow `.into()` to convert
+// - `proc_macro2::TokenStream` into `proc_macro::TokenStream` in the user-space version.
+// - `proc_macro::TokenStream` into `proc_macro::TokenStream` in the kernel version.
+// Clippy warns on this conversion, but it's required by the user-space version.
+//
+// Remove once we have `proc_macro2` in the kernel.
+#![allow(clippy::useless_conversion)]
use proc_macro::TokenStream;
@@ -14,6 +21,9 @@ use proc_macro::TokenStream;
#[path = "../../../macros/quote.rs"]
#[macro_use]
mod quote;
+#[cfg(not(kernel))]
+#[macro_use]
+extern crate quote;
mod helpers;
mod pin_data;
@@ -23,17 +33,17 @@ mod zeroable;
#[allow(missing_docs)]
#[proc_macro_attribute]
pub fn pin_data(inner: TokenStream, item: TokenStream) -> TokenStream {
- pin_data::pin_data(inner, item)
+ pin_data::pin_data(inner.into(), item.into()).into()
}
#[allow(missing_docs)]
#[proc_macro_attribute]
pub fn pinned_drop(args: TokenStream, input: TokenStream) -> TokenStream {
- pinned_drop::pinned_drop(args, input)
+ pinned_drop::pinned_drop(args.into(), input.into()).into()
}
#[allow(missing_docs)]
#[proc_macro_derive(Zeroable)]
pub fn derive_zeroable(input: TokenStream) -> TokenStream {
- zeroable::derive(input)
+ zeroable::derive(input.into()).into()
}