1 // SPDX-License-Identifier: Apache-2.0 OR MIT 2 3 // When fixdep scans this, it will find this string `CONFIG_RUSTC_VERSION_TEXT` 4 // and thus add a dependency on `include/config/RUSTC_VERSION_TEXT`, which is 5 // touched by Kconfig when the version string from the compiler changes. 6 7 //! `pin-init` proc macros. 8 9 #![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))] 10 // Allow `.into()` to convert 11 // - `proc_macro2::TokenStream` into `proc_macro::TokenStream` in the user-space version. 12 // - `proc_macro::TokenStream` into `proc_macro::TokenStream` in the kernel version. 13 // Clippy warns on this conversion, but it's required by the user-space version. 14 // 15 // Remove once we have `proc_macro2` in the kernel. 16 #![allow(clippy::useless_conversion)] 17 // Documentation is done in the pin-init crate instead. 18 #![allow(missing_docs)] 19 20 use proc_macro::TokenStream; 21 22 #[cfg(kernel)] 23 #[path = "../../../macros/quote.rs"] 24 #[macro_use] 25 mod quote; 26 #[cfg(not(kernel))] 27 #[macro_use] 28 extern crate quote; 29 30 mod helpers; 31 mod pin_data; 32 mod pinned_drop; 33 mod zeroable; 34 35 #[proc_macro_attribute] 36 pub fn pin_data(inner: TokenStream, item: TokenStream) -> TokenStream { 37 pin_data::pin_data(inner.into(), item.into()).into() 38 } 39 40 #[proc_macro_attribute] 41 pub fn pinned_drop(args: TokenStream, input: TokenStream) -> TokenStream { 42 pinned_drop::pinned_drop(args.into(), input.into()).into() 43 } 44 45 #[proc_macro_derive(Zeroable)] 46 pub fn derive_zeroable(input: TokenStream) -> TokenStream { 47 zeroable::derive(input.into()).into() 48 } 49