at master 1.7 kB view raw
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 20use proc_macro::TokenStream; 21 22#[cfg(kernel)] 23#[path = "../../../macros/quote.rs"] 24#[macro_use] 25#[cfg_attr(not(kernel), rustfmt::skip)] 26mod quote; 27#[cfg(not(kernel))] 28#[macro_use] 29extern crate quote; 30 31mod helpers; 32mod pin_data; 33mod pinned_drop; 34mod zeroable; 35 36#[proc_macro_attribute] 37pub fn pin_data(inner: TokenStream, item: TokenStream) -> TokenStream { 38 pin_data::pin_data(inner.into(), item.into()).into() 39} 40 41#[proc_macro_attribute] 42pub fn pinned_drop(args: TokenStream, input: TokenStream) -> TokenStream { 43 pinned_drop::pinned_drop(args.into(), input.into()).into() 44} 45 46#[proc_macro_derive(Zeroable)] 47pub fn derive_zeroable(input: TokenStream) -> TokenStream { 48 zeroable::derive(input.into()).into() 49} 50 51#[proc_macro_derive(MaybeZeroable)] 52pub fn maybe_derive_zeroable(input: TokenStream) -> TokenStream { 53 zeroable::maybe_derive(input.into()).into() 54}