Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: make pin-init its own crate

Rename relative paths inside of the crate to still refer to the same
items, also rename paths inside of the kernel crate and adjust the build
system to build the crate.

[ Remove the `expect` (and thus the `lint_reasons` feature) since
the tree now uses `quote!` from `rust/macros/export.rs`. Remove the
`TokenStream` import removal, since it is now used as well.

In addition, temporarily (i.e. just for this commit) use an `--extern
force:alloc` to prevent an unknown `new_uninit` error in the `rustdoc`
target. For context, please see a similar case in:

https://lore.kernel.org/lkml/20240422090644.525520-1-ojeda@kernel.org/

And adjusted the message above. - Miguel ]

Signed-off-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Fiona Behrens <me@kloenk.dev>
Tested-by: Andreas Hindborg <a.hindborg@kernel.org>
Link: https://lore.kernel.org/r/20250308110339.2997091-16-benno.lossin@proton.me
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

authored by

Benno Lossin and committed by
Miguel Ojeda
dbd5058b d7659acc

+164 -153
+7 -7
rust/Makefile
··· 116 116 rustdoc-pin_init_internal: private rustdoc_host = yes 117 117 rustdoc-pin_init_internal: private rustc_target_flags = --cfg kernel \ 118 118 --extern proc_macro --crate-type proc-macro 119 - rustdoc-pin_init_internal: $(src)/pin-init/internal/src/_lib.rs FORCE 119 + rustdoc-pin_init_internal: $(src)/pin-init/internal/src/lib.rs FORCE 120 120 +$(call if_changed,rustdoc) 121 121 122 122 rustdoc-pin_init: private rustdoc_host = yes 123 123 rustdoc-pin_init: private rustc_target_flags = --extern pin_init_internal \ 124 - --extern macros --extern alloc --cfg kernel --cfg feature=\"alloc\" 125 - rustdoc-pin_init: $(src)/pin-init/src/_lib.rs rustdoc-pin_init_internal \ 124 + --extern macros --extern force:alloc --cfg kernel --cfg feature=\"alloc\" 125 + rustdoc-pin_init: $(src)/pin-init/src/lib.rs rustdoc-pin_init_internal \ 126 126 rustdoc-macros FORCE 127 127 +$(call if_changed,rustdoc) 128 128 ··· 158 158 rusttestlib-pin_init_internal: private rustc_target_flags = --cfg kernel \ 159 159 --extern proc_macro 160 160 rusttestlib-pin_init_internal: private rustc_test_library_proc = yes 161 - rusttestlib-pin_init_internal: $(src)/pin-init/internal/src/_lib.rs FORCE 161 + rusttestlib-pin_init_internal: $(src)/pin-init/internal/src/lib.rs FORCE 162 162 +$(call if_changed,rustc_test_library) 163 163 164 164 rusttestlib-pin_init: private rustc_target_flags = --extern pin_init_internal \ 165 165 --extern macros --cfg kernel 166 - rusttestlib-pin_init: $(src)/pin-init/src/_lib.rs rusttestlib-macros \ 166 + rusttestlib-pin_init: $(src)/pin-init/src/lib.rs rusttestlib-macros \ 167 167 rusttestlib-pin_init_internal $(obj)/$(libpin_init_internal_name) FORCE 168 168 +$(call if_changed,rustc_test_library) 169 169 ··· 401 401 +$(call if_changed_dep,rustc_procmacro) 402 402 403 403 $(obj)/$(libpin_init_internal_name): private rustc_target_flags = --cfg kernel 404 - $(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/_lib.rs FORCE 404 + $(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/lib.rs FORCE 405 405 +$(call if_changed_dep,rustc_procmacro) 406 406 407 407 quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L $@ ··· 486 486 $(obj)/pin_init.o: private skip_gendwarfksyms = 1 487 487 $(obj)/pin_init.o: private rustc_target_flags = --extern pin_init_internal \ 488 488 --extern macros --cfg kernel 489 - $(obj)/pin_init.o: $(src)/pin-init/src/_lib.rs $(obj)/compiler_builtins.o \ 489 + $(obj)/pin_init.o: $(src)/pin-init/src/lib.rs $(obj)/compiler_builtins.o \ 490 490 $(obj)/$(libpin_init_internal_name) $(obj)/$(libmacros_name) FORCE 491 491 +$(call if_changed_rule,rustc_library) 492 492
+2 -2
rust/kernel/alloc/kbox.rs
··· 15 15 use core::ptr::NonNull; 16 16 use core::result::Result; 17 17 18 - use crate::init::{InPlaceWrite, Init, PinInit, ZeroableOption}; 19 - use crate::init_ext::InPlaceInit; 18 + use crate::init::InPlaceInit; 20 19 use crate::types::ForeignOwnable; 20 + use pin_init::{InPlaceWrite, Init, PinInit, ZeroableOption}; 21 21 22 22 /// The kernel's [`Box`] type -- a heap allocation for a single value of type `T`. 23 23 ///
+2 -3
rust/kernel/block/mq/tag_set.rs
··· 10 10 bindings, 11 11 block::mq::{operations::OperationsVTable, request::RequestDataWrapper, Operations}, 12 12 error, 13 - prelude::PinInit, 14 - try_pin_init, 13 + prelude::try_pin_init, 15 14 types::Opaque, 16 15 }; 17 16 use core::{convert::TryInto, marker::PhantomData}; 18 - use macros::{pin_data, pinned_drop}; 17 + use pin_init::{pin_data, pinned_drop, PinInit}; 19 18 20 19 /// A wrapper for the C `struct blk_mq_tag_set`. 21 20 ///
+3 -3
rust/kernel/driver.rs
··· 6 6 //! register using the [`Registration`] class. 7 7 8 8 use crate::error::{Error, Result}; 9 - use crate::{device, init::PinInit, of, str::CStr, try_pin_init, types::Opaque, ThisModule}; 9 + use crate::{device, of, str::CStr, try_pin_init, types::Opaque, ThisModule}; 10 10 use core::pin::Pin; 11 - use macros::{pin_data, pinned_drop}; 11 + use pin_init::{pin_data, pinned_drop, PinInit}; 12 12 13 13 /// The [`RegistrationOps`] trait serves as generic interface for subsystems (e.g., PCI, Platform, 14 14 /// Amba, etc.) to provide the corresponding subsystem specific implementation to register / ··· 114 114 impl $crate::InPlaceModule for DriverModule { 115 115 fn init( 116 116 module: &'static $crate::ThisModule 117 - ) -> impl $crate::init::PinInit<Self, $crate::error::Error> { 117 + ) -> impl ::pin_init::PinInit<Self, $crate::error::Error> { 118 118 $crate::try_pin_init!(Self { 119 119 _driver <- $crate::driver::Registration::new( 120 120 <Self as $crate::ModuleMetadata>::NAME,
+12 -10
rust/kernel/init.rs
··· 23 23 //! 24 24 //! [`Opaque<T>`]: crate::types::Opaque 25 25 //! [`Opaque::ffi_init`]: crate::types::Opaque::ffi_init 26 - //! [`pin_init!`]: crate::pin_init 26 + //! [`pin_init!`]: pin_init::pin_init 27 27 //! 28 28 //! # Examples 29 29 //! ··· 137 137 use crate::{ 138 138 alloc::{AllocError, Flags}, 139 139 error::{self, Error}, 140 - init::{init_from_closure, pin_init_from_closure, Init, PinInit}, 141 140 }; 141 + use pin_init::{init_from_closure, pin_init_from_closure, Init, PinInit}; 142 142 143 143 /// Smart pointer that can initialize memory in-place. 144 144 pub trait InPlaceInit<T>: Sized { ··· 205 205 /// # Examples 206 206 /// 207 207 /// ```rust 208 - /// use kernel::{init::zeroed, error::Error}; 208 + /// use kernel::error::Error; 209 + /// use pin_init::zeroed; 209 210 /// struct BigBuf { 210 211 /// big: KBox<[u8; 1024 * 1024 * 1024]>, 211 212 /// small: [u8; 1024 * 1024], ··· 223 222 /// ``` 224 223 /// 225 224 /// [`Infallible`]: core::convert::Infallible 226 - /// [`init!`]: crate::init! 225 + /// [`init!`]: pin_init::init 227 226 /// [`try_pin_init!`]: crate::try_pin_init! 228 227 /// [`Error`]: crate::error::Error 229 228 #[macro_export] ··· 231 230 ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? { 232 231 $($fields:tt)* 233 232 }) => { 234 - $crate::_try_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? { 233 + ::pin_init::try_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? { 235 234 $($fields)* 236 235 }? $crate::error::Error) 237 236 }; 238 237 ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? { 239 238 $($fields:tt)* 240 239 }? $err:ty) => { 241 - $crate::_try_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? { 240 + ::pin_init::try_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? { 242 241 $($fields)* 243 242 }? $err) 244 243 }; ··· 263 262 /// 264 263 /// ```rust 265 264 /// # #![feature(new_uninit)] 266 - /// use kernel::{init::zeroed, error::Error}; 265 + /// use kernel::error::Error; 266 + /// use pin_init::zeroed; 267 267 /// #[pin_data] 268 268 /// struct BigBuf { 269 269 /// big: KBox<[u8; 1024 * 1024 * 1024]>, ··· 284 282 /// ``` 285 283 /// 286 284 /// [`Infallible`]: core::convert::Infallible 287 - /// [`pin_init!`]: crate::pin_init 285 + /// [`pin_init!`]: pin_init::pin_init 288 286 /// [`Error`]: crate::error::Error 289 287 #[macro_export] 290 288 macro_rules! try_pin_init { 291 289 ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? { 292 290 $($fields:tt)* 293 291 }) => { 294 - $crate::_try_pin_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? { 292 + ::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? { 295 293 $($fields)* 296 294 }? $crate::error::Error) 297 295 }; 298 296 ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? { 299 297 $($fields:tt)* 300 298 }? $err:ty) => { 301 - $crate::_try_pin_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? { 299 + ::pin_init::try_pin_init!($(&$this in)? $t $(::<$($generics),* $(,)?>)? { 302 300 $($fields)* 303 301 }? $err) 304 302 };
+3 -7
rust/kernel/lib.rs
··· 50 50 #[cfg(CONFIG_RUST_FW_LOADER_ABSTRACTIONS)] 51 51 pub mod firmware; 52 52 pub mod fs; 53 - #[path = "../pin-init/src/lib.rs"] 54 53 pub mod init; 55 - // momentarily use the name `init_ext` and set the path manually 56 - #[path = "init.rs"] 57 - pub mod init_ext; 58 54 pub mod io; 59 55 pub mod ioctl; 60 56 pub mod jump_label; ··· 112 116 /// Creates an initialiser for the module. 113 117 /// 114 118 /// It is called when the module is loaded. 115 - fn init(module: &'static ThisModule) -> impl init::PinInit<Self, error::Error>; 119 + fn init(module: &'static ThisModule) -> impl pin_init::PinInit<Self, error::Error>; 116 120 } 117 121 118 122 impl<T: Module> InPlaceModule for T { 119 - fn init(module: &'static ThisModule) -> impl init::PinInit<Self, error::Error> { 123 + fn init(module: &'static ThisModule) -> impl pin_init::PinInit<Self, error::Error> { 120 124 let initer = move |slot: *mut Self| { 121 125 let m = <Self as Module>::init(module)?; 122 126 ··· 126 130 }; 127 131 128 132 // SAFETY: On success, `initer` always fully initialises an instance of `Self`. 129 - unsafe { init::pin_init_from_closure(initer) } 133 + unsafe { pin_init::pin_init_from_closure(initer) } 130 134 } 131 135 } 132 136
+1 -1
rust/kernel/list.rs
··· 4 4 5 5 //! A linked list implementation. 6 6 7 - use crate::init::PinInit; 8 7 use crate::sync::ArcBorrow; 9 8 use crate::types::Opaque; 10 9 use core::iter::{DoubleEndedIterator, FusedIterator}; 11 10 use core::marker::PhantomData; 12 11 use core::ptr; 12 + use pin_init::PinInit; 13 13 14 14 mod impl_list_item_mod; 15 15 pub use self::impl_list_item_mod::{
+5 -4
rust/kernel/prelude.rs
··· 17 17 pub use crate::alloc::{flags::*, Box, KBox, KVBox, KVVec, KVec, VBox, VVec, Vec}; 18 18 19 19 #[doc(no_inline)] 20 - pub use macros::{export, module, pin_data, pinned_drop, vtable, Zeroable}; 20 + pub use macros::{export, module, vtable}; 21 + 22 + pub use pin_init::{init, pin_data, pin_init, pinned_drop, InPlaceWrite, Init, PinInit, Zeroable}; 21 23 22 24 pub use super::{build_assert, build_error}; 23 25 ··· 30 28 pub use super::{dev_alert, dev_crit, dev_dbg, dev_emerg, dev_err, dev_info, dev_notice, dev_warn}; 31 29 pub use super::{pr_alert, pr_crit, pr_debug, pr_emerg, pr_err, pr_info, pr_notice, pr_warn}; 32 30 33 - pub use super::{init, pin_init, try_init, try_pin_init}; 31 + pub use super::{try_init, try_pin_init}; 34 32 35 33 pub use super::static_assert; 36 34 ··· 38 36 39 37 pub use super::{str::CStr, ThisModule}; 40 38 41 - pub use super::init::{InPlaceWrite, Init, PinInit}; 42 - pub use super::init_ext::InPlaceInit; 39 + pub use super::init::InPlaceInit; 43 40 44 41 pub use super::current;
+3 -4
rust/kernel/sync/arc.rs
··· 19 19 use crate::{ 20 20 alloc::{AllocError, Flags, KBox}, 21 21 bindings, 22 - init::{self, InPlaceWrite, Init, PinInit}, 23 - init_ext::InPlaceInit, 22 + init::InPlaceInit, 24 23 try_init, 25 24 types::{ForeignOwnable, Opaque}, 26 25 }; ··· 32 33 pin::Pin, 33 34 ptr::NonNull, 34 35 }; 35 - use macros::pin_data; 36 + use pin_init::{self, pin_data, InPlaceWrite, Init, PinInit}; 36 37 37 38 mod std_vendor; 38 39 ··· 737 738 try_init!(ArcInner { 738 739 // SAFETY: There are no safety requirements for this FFI call. 739 740 refcount: Opaque::new(unsafe { bindings::REFCOUNT_INIT(1) }), 740 - data <- init::uninit::<T, AllocError>(), 741 + data <- pin_init::uninit::<T, AllocError>(), 741 742 }? AllocError), 742 743 flags, 743 744 )?;
+1 -3
rust/kernel/sync/condvar.rs
··· 8 8 use super::{lock::Backend, lock::Guard, LockClassKey}; 9 9 use crate::{ 10 10 ffi::{c_int, c_long}, 11 - init::PinInit, 12 - pin_init, 13 11 str::CStr, 14 12 task::{MAX_SCHEDULE_TIMEOUT, TASK_INTERRUPTIBLE, TASK_NORMAL, TASK_UNINTERRUPTIBLE}, 15 13 time::Jiffies, ··· 15 17 }; 16 18 use core::marker::PhantomPinned; 17 19 use core::ptr; 18 - use macros::pin_data; 20 + use pin_init::{pin_data, pin_init, PinInit}; 19 21 20 22 /// Creates a [`CondVar`] initialiser with the given name and a newly-created lock class. 21 23 #[macro_export]
+1 -3
rust/kernel/sync/lock.rs
··· 7 7 8 8 use super::LockClassKey; 9 9 use crate::{ 10 - init::PinInit, 11 - pin_init, 12 10 str::CStr, 13 11 types::{NotThreadSafe, Opaque, ScopeGuard}, 14 12 }; 15 13 use core::{cell::UnsafeCell, marker::PhantomPinned}; 16 - use macros::pin_data; 14 + use pin_init::{pin_data, pin_init, PinInit}; 17 15 18 16 pub mod mutex; 19 17 pub mod spinlock;
+1 -1
rust/kernel/sync/lock/mutex.rs
··· 26 26 /// Since it may block, [`Mutex`] needs to be used with care in atomic contexts. 27 27 /// 28 28 /// Instances of [`Mutex`] need a lock class and to be pinned. The recommended way to create such 29 - /// instances is with the [`pin_init`](crate::pin_init) and [`new_mutex`] macros. 29 + /// instances is with the [`pin_init`](pin_init::pin_init) and [`new_mutex`] macros. 30 30 /// 31 31 /// # Examples 32 32 ///
+1 -1
rust/kernel/sync/lock/spinlock.rs
··· 24 24 /// unlocked, at which point another CPU will be allowed to make progress. 25 25 /// 26 26 /// Instances of [`SpinLock`] need a lock class and to be pinned. The recommended way to create such 27 - /// instances is with the [`pin_init`](crate::pin_init) and [`new_spinlock`] macros. 27 + /// instances is with the [`pin_init`](pin_init::pin_init) and [`new_spinlock`] macros. 28 28 /// 29 29 /// # Examples 30 30 ///
+6 -4
rust/kernel/types.rs
··· 2 2 3 3 //! Kernel types. 4 4 5 - use crate::init::{self, PinInit, Zeroable}; 6 5 use core::{ 7 6 cell::UnsafeCell, 8 7 marker::{PhantomData, PhantomPinned}, ··· 9 10 ops::{Deref, DerefMut}, 10 11 ptr::NonNull, 11 12 }; 13 + use pin_init::{PinInit, Zeroable}; 12 14 13 15 /// Used to transfer ownership to and from foreign (non-Rust) languages. 14 16 /// ··· 336 336 // - `ptr` is a valid pointer to uninitialized memory, 337 337 // - `slot` is not accessed on error; the call is infallible, 338 338 // - `slot` is pinned in memory. 339 - let _ = unsafe { init::PinInit::<T>::__pinned_init(slot, ptr) }; 339 + let _ = unsafe { PinInit::<T>::__pinned_init(slot, ptr) }; 340 340 }) 341 341 } 342 342 ··· 352 352 // SAFETY: We contain a `MaybeUninit`, so it is OK for the `init_func` to not fully 353 353 // initialize the `T`. 354 354 unsafe { 355 - init::pin_init_from_closure::<_, ::core::convert::Infallible>(move |slot| { 355 + pin_init::pin_init_from_closure::<_, ::core::convert::Infallible>(move |slot| { 356 356 init_func(Self::raw_get(slot)); 357 357 Ok(()) 358 358 }) ··· 372 372 ) -> impl PinInit<Self, E> { 373 373 // SAFETY: We contain a `MaybeUninit`, so it is OK for the `init_func` to not fully 374 374 // initialize the `T`. 375 - unsafe { init::pin_init_from_closure::<_, E>(move |slot| init_func(Self::raw_get(slot))) } 375 + unsafe { 376 + pin_init::pin_init_from_closure::<_, E>(move |slot| init_func(Self::raw_get(slot))) 377 + } 376 378 } 377 379 378 380 /// Returns a raw pointer to the opaque data.
-2
rust/macros/helpers.rs
··· 86 86 } 87 87 None 88 88 } 89 - 90 - include!("../pin-init/internal/src/helpers.rs");
-8
rust/macros/lib.rs
··· 13 13 mod helpers; 14 14 mod module; 15 15 mod paste; 16 - #[path = "../pin-init/internal/src/pin_data.rs"] 17 - mod pin_data; 18 - #[path = "../pin-init/internal/src/pinned_drop.rs"] 19 - mod pinned_drop; 20 16 mod vtable; 21 - #[path = "../pin-init/internal/src/zeroable.rs"] 22 - mod zeroable; 23 17 24 18 use proc_macro::TokenStream; 25 19 ··· 392 398 paste::expand(&mut tokens); 393 399 tokens.into_iter().collect() 394 400 } 395 - 396 - include!("../pin-init/internal/src/lib.rs");
+1 -1
rust/macros/module.rs
··· 244 244 mod __module_init {{ 245 245 mod __module_init {{ 246 246 use super::super::{type_}; 247 - use kernel::init::PinInit; 247 + use pin_init::PinInit; 248 248 249 249 /// The \"Rust loadable module\" mark. 250 250 //
+1
rust/macros/quote.rs
··· 2 2 3 3 use proc_macro::{TokenStream, TokenTree}; 4 4 5 + #[allow(dead_code)] 5 6 pub(crate) trait ToTokens { 6 7 fn to_tokens(&self, tokens: &mut TokenStream); 7 8 }
-3
rust/pin-init/internal/src/_lib.rs
··· 1 - // SPDX-License-Identifier: Apache-2.0 OR MIT 2 - 3 - //! Will be removed in a future commit, only exists to prevent compilation errors.
+2
rust/pin-init/internal/src/helpers.rs
··· 1 1 // SPDX-License-Identifier: Apache-2.0 OR MIT 2 2 3 + use proc_macro::{TokenStream, TokenTree}; 4 + 3 5 /// Parsed generics. 4 6 /// 5 7 /// See the field documentation for an explanation what each of the fields represents.
+16
rust/pin-init/internal/src/lib.rs
··· 4 4 // and thus add a dependency on `include/config/RUSTC_VERSION_TEXT`, which is 5 5 // touched by Kconfig when the version string from the compiler changes. 6 6 7 + //! `pin-init` proc macros. 8 + 9 + #![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))] 10 + 11 + use proc_macro::TokenStream; 12 + 13 + #[cfg(kernel)] 14 + #[path = "../../../macros/quote.rs"] 15 + #[macro_use] 16 + mod quote; 17 + 18 + mod helpers; 19 + mod pin_data; 20 + mod pinned_drop; 21 + mod zeroable; 22 + 7 23 #[allow(missing_docs)] 8 24 #[proc_macro_attribute] 9 25 pub fn pin_data(inner: TokenStream, item: TokenStream) -> TokenStream {
+2 -2
rust/pin-init/internal/src/pin_data.rs
··· 5 5 6 6 pub(crate) fn pin_data(args: TokenStream, input: TokenStream) -> TokenStream { 7 7 // This proc-macro only does some pre-parsing and then delegates the actual parsing to 8 - // `kernel::__pin_data!`. 8 + // `pin_init::__pin_data!`. 9 9 10 10 let ( 11 11 Generics { ··· 71 71 .collect::<Vec<_>>(); 72 72 // This should be the body of the struct `{...}`. 73 73 let last = rest.pop(); 74 - let mut quoted = quote!(::kernel::__pin_data! { 74 + let mut quoted = quote!(::pin_init::__pin_data! { 75 75 parse_input: 76 76 @args(#args), 77 77 @sig(#(#rest)*),
+2 -2
rust/pin-init/internal/src/pinned_drop.rs
··· 35 35 let idx = pinned_drop_idx 36 36 .unwrap_or_else(|| panic!("Expected an `impl` block implementing `PinnedDrop`.")); 37 37 // Fully qualify the `PinnedDrop`, as to avoid any tampering. 38 - toks.splice(idx..idx, quote!(::kernel::init::)); 38 + toks.splice(idx..idx, quote!(::pin_init::)); 39 39 // Take the `{}` body and call the declarative macro. 40 40 if let Some(TokenTree::Group(last)) = toks.pop() { 41 41 let last = last.stream(); 42 - quote!(::kernel::__pinned_drop! { 42 + quote!(::pin_init::__pinned_drop! { 43 43 @impl_sig(#(#toks)*), 44 44 @impl_body(#last), 45 45 })
+4 -4
rust/pin-init/internal/src/zeroable.rs
··· 27 27 // If we find a `,`, then we have finished a generic/constant/lifetime parameter. 28 28 TokenTree::Punct(p) if nested == 0 && p.as_char() == ',' => { 29 29 if in_generic && !inserted { 30 - new_impl_generics.extend(quote! { : ::kernel::init::Zeroable }); 30 + new_impl_generics.extend(quote! { : ::pin_init::Zeroable }); 31 31 } 32 32 in_generic = true; 33 33 inserted = false; ··· 41 41 TokenTree::Punct(p) if nested == 0 && p.as_char() == ':' => { 42 42 new_impl_generics.push(tt); 43 43 if in_generic { 44 - new_impl_generics.extend(quote! { ::kernel::init::Zeroable + }); 44 + new_impl_generics.extend(quote! { ::pin_init::Zeroable + }); 45 45 inserted = true; 46 46 } 47 47 } ··· 59 59 } 60 60 assert_eq!(nested, 0); 61 61 if in_generic && !inserted { 62 - new_impl_generics.extend(quote! { : ::kernel::init::Zeroable }); 62 + new_impl_generics.extend(quote! { : ::pin_init::Zeroable }); 63 63 } 64 64 quote! { 65 - ::kernel::__derive_zeroable!( 65 + ::pin_init::__derive_zeroable!( 66 66 parse_input: 67 67 @sig(#(#rest)*), 68 68 @impl_generics(#(#new_impl_generics)*),
-5
rust/pin-init/src/_lib.rs
··· 1 - // SPDX-License-Identifier: Apache-2.0 OR MIT 2 - 3 - //! Will be removed in a future commit, only exists to prevent compilation errors. 4 - 5 - #![no_std]
+29 -17
rust/pin-init/src/lib.rs
··· 209 209 //! [`impl PinInit<Foo>`]: PinInit 210 210 //! [`impl PinInit<T, E>`]: PinInit 211 211 //! [`impl Init<T, E>`]: Init 212 - //! [`pin_data`]: ::macros::pin_data 212 + //! [`pin_data`]: crate::pin_data 213 213 //! [`pin_init!`]: crate::pin_init! 214 + 215 + #![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))] 216 + #![cfg_attr( 217 + all( 218 + any(feature = "alloc", feature = "std"), 219 + not(RUSTC_NEW_UNINIT_IS_STABLE) 220 + ), 221 + feature(new_uninit) 222 + )] 223 + #![forbid(missing_docs, unsafe_op_in_unsafe_fn)] 224 + #![cfg_attr(not(feature = "std"), no_std)] 225 + #![cfg_attr(feature = "alloc", feature(allocator_api))] 214 226 215 227 use core::{ 216 228 cell::UnsafeCell, ··· 300 288 /// ``` 301 289 /// 302 290 /// [`pin_init!`]: crate::pin_init 303 - pub use ::macros::pin_data; 291 + pub use ::pin_init_internal::pin_data; 304 292 305 293 /// Used to implement `PinnedDrop` safely. 306 294 /// ··· 334 322 /// } 335 323 /// } 336 324 /// ``` 337 - pub use ::macros::pinned_drop; 325 + pub use ::pin_init_internal::pinned_drop; 338 326 339 327 /// Derives the [`Zeroable`] trait for the given struct. 340 328 /// ··· 352 340 /// len: usize, 353 341 /// } 354 342 /// ``` 355 - pub use ::macros::Zeroable; 343 + pub use ::pin_init_internal::Zeroable; 356 344 357 345 /// Initialize and pin a type directly on the stack. 358 346 /// ··· 397 385 macro_rules! stack_pin_init { 398 386 (let $var:ident $(: $t:ty)? = $val:expr) => { 399 387 let val = $val; 400 - let mut $var = ::core::pin::pin!($crate::init::__internal::StackInit$(::<$t>)?::uninit()); 401 - let mut $var = match $crate::init::__internal::StackInit::init($var, val) { 388 + let mut $var = ::core::pin::pin!($crate::__internal::StackInit$(::<$t>)?::uninit()); 389 + let mut $var = match $crate::__internal::StackInit::init($var, val) { 402 390 Ok(res) => res, 403 391 Err(x) => { 404 392 let x: ::core::convert::Infallible = x; ··· 475 463 macro_rules! stack_try_pin_init { 476 464 (let $var:ident $(: $t:ty)? = $val:expr) => { 477 465 let val = $val; 478 - let mut $var = ::core::pin::pin!($crate::init::__internal::StackInit$(::<$t>)?::uninit()); 479 - let mut $var = $crate::init::__internal::StackInit::init($var, val); 466 + let mut $var = ::core::pin::pin!($crate::__internal::StackInit$(::<$t>)?::uninit()); 467 + let mut $var = $crate::__internal::StackInit::init($var, val); 480 468 }; 481 469 (let $var:ident $(: $t:ty)? =? $val:expr) => { 482 470 let val = $val; 483 - let mut $var = ::core::pin::pin!($crate::init::__internal::StackInit$(::<$t>)?::uninit()); 484 - let mut $var = $crate::init::__internal::StackInit::init($var, val)?; 471 + let mut $var = ::core::pin::pin!($crate::__internal::StackInit$(::<$t>)?::uninit()); 472 + let mut $var = $crate::__internal::StackInit::init($var, val)?; 485 473 }; 486 474 } 487 475 ··· 682 670 ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? { 683 671 $($fields:tt)* 684 672 }) => { 685 - $crate::_try_pin_init!($(&$this in)? $t $(::<$($generics),*>)? { 673 + $crate::try_pin_init!($(&$this in)? $t $(::<$($generics),*>)? { 686 674 $($fields)* 687 675 }? ::core::convert::Infallible) 688 676 }; ··· 728 716 // For a detailed example of how this macro works, see the module documentation of the hidden 729 717 // module `__internal` inside of `init/__internal.rs`. 730 718 #[macro_export] 731 - macro_rules! _try_pin_init { 719 + macro_rules! try_pin_init { 732 720 ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? { 733 721 $($fields:tt)* 734 722 }? $err:ty) => { ··· 767 755 ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? { 768 756 $($fields:tt)* 769 757 }) => { 770 - $crate::_try_init!($(&$this in)? $t $(::<$($generics),*>)? { 758 + $crate::try_init!($(&$this in)? $t $(::<$($generics),*>)? { 771 759 $($fields)* 772 760 }? ::core::convert::Infallible) 773 761 } ··· 810 798 // For a detailed example of how this macro works, see the module documentation of the hidden 811 799 // module `__internal` inside of `init/__internal.rs`. 812 800 #[macro_export] 813 - macro_rules! _try_init { 801 + macro_rules! try_init { 814 802 ($(&$this:ident in)? $t:ident $(::<$($generics:ty),* $(,)?>)? { 815 803 $($fields:tt)* 816 804 }? $err:ty) => { ··· 880 868 ($ty:ty, $field:ident, $field_ty:ty, inline) => { 881 869 let _ = move |ptr: *mut $field_ty| { 882 870 // SAFETY: This code is unreachable. 883 - let data = unsafe { <$ty as $crate::init::__internal::HasPinData>::__pin_data() }; 884 - let init = $crate::init::__internal::AlwaysFail::<$field_ty>::new(); 871 + let data = unsafe { <$ty as $crate::__internal::HasPinData>::__pin_data() }; 872 + let init = $crate::__internal::AlwaysFail::<$field_ty>::new(); 885 873 // SAFETY: This code is unreachable. 886 874 unsafe { data.$field(ptr, init) }.ok(); 887 875 }; ··· 1274 1262 /// 1275 1263 /// This trait must be implemented via the [`pinned_drop`] proc-macro attribute on the impl. 1276 1264 /// 1277 - /// [`pinned_drop`]: crate::macros::pinned_drop 1265 + /// [`pinned_drop`]: crate::pinned_drop 1278 1266 pub unsafe trait PinnedDrop: __internal::HasPinData { 1279 1267 /// Executes the pinned destructor of this type. 1280 1268 ///
+57 -54
rust/pin-init/src/macros.rs
··· 19 19 //! We will look at the following example: 20 20 //! 21 21 //! ```rust,ignore 22 - //! # use kernel::init::*; 22 + //! # use pin_init::*; 23 23 //! # use core::pin::Pin; 24 24 //! #[pin_data] 25 25 //! #[repr(C)] ··· 75 75 //! Here is the definition of `Bar` from our example: 76 76 //! 77 77 //! ```rust,ignore 78 - //! # use kernel::init::*; 78 + //! # use pin_init::*; 79 79 //! #[pin_data] 80 80 //! #[repr(C)] 81 81 //! struct Bar<T> { ··· 121 121 //! self, 122 122 //! slot: *mut T, 123 123 //! // Since `t` is `#[pin]`, this is `PinInit`. 124 - //! init: impl ::kernel::init::PinInit<T, E>, 124 + //! init: impl ::pin_init::PinInit<T, E>, 125 125 //! ) -> ::core::result::Result<(), E> { 126 - //! unsafe { ::kernel::init::PinInit::__pinned_init(init, slot) } 126 + //! unsafe { ::pin_init::PinInit::__pinned_init(init, slot) } 127 127 //! } 128 128 //! pub unsafe fn x<E>( 129 129 //! self, 130 130 //! slot: *mut usize, 131 131 //! // Since `x` is not `#[pin]`, this is `Init`. 132 - //! init: impl ::kernel::init::Init<usize, E>, 132 + //! init: impl ::pin_init::Init<usize, E>, 133 133 //! ) -> ::core::result::Result<(), E> { 134 - //! unsafe { ::kernel::init::Init::__init(init, slot) } 134 + //! unsafe { ::pin_init::Init::__init(init, slot) } 135 135 //! } 136 136 //! } 137 137 //! // Implement the internal `HasPinData` trait that associates `Bar` with the pin-data struct 138 138 //! // that we constructed above. 139 - //! unsafe impl<T> ::kernel::init::__internal::HasPinData for Bar<T> { 139 + //! unsafe impl<T> ::pin_init::__internal::HasPinData for Bar<T> { 140 140 //! type PinData = __ThePinData<T>; 141 141 //! unsafe fn __pin_data() -> Self::PinData { 142 142 //! __ThePinData { ··· 147 147 //! // Implement the internal `PinData` trait that marks the pin-data struct as a pin-data 148 148 //! // struct. This is important to ensure that no user can implement a rogue `__pin_data` 149 149 //! // function without using `unsafe`. 150 - //! unsafe impl<T> ::kernel::init::__internal::PinData for __ThePinData<T> { 150 + //! unsafe impl<T> ::pin_init::__internal::PinData for __ThePinData<T> { 151 151 //! type Datee = Bar<T>; 152 152 //! } 153 153 //! // Now we only want to implement `Unpin` for `Bar` when every structurally pinned field is ··· 191 191 //! #[expect(non_camel_case_types)] 192 192 //! trait UselessPinnedDropImpl_you_need_to_specify_PinnedDrop {} 193 193 //! impl< 194 - //! T: ::kernel::init::PinnedDrop, 194 + //! T: ::pin_init::PinnedDrop, 195 195 //! > UselessPinnedDropImpl_you_need_to_specify_PinnedDrop for T {} 196 196 //! impl<T> UselessPinnedDropImpl_you_need_to_specify_PinnedDrop for Bar<T> {} 197 197 //! }; ··· 227 227 //! // - we `use` the `HasPinData` trait in the block, it is only available in that 228 228 //! // scope. 229 229 //! let data = unsafe { 230 - //! use ::kernel::init::__internal::HasPinData; 230 + //! use ::pin_init::__internal::HasPinData; 231 231 //! Self::__pin_data() 232 232 //! }; 233 233 //! // Ensure that `data` really is of type `PinData` and help with type inference: 234 - //! let init = ::kernel::init::__internal::PinData::make_closure::< 234 + //! let init = ::pin_init::__internal::PinData::make_closure::< 235 235 //! _, 236 236 //! __InitOk, 237 237 //! ::core::convert::Infallible, ··· 262 262 //! } 263 263 //! // We again create a `DropGuard`. 264 264 //! let __x_guard = unsafe { 265 - //! ::kernel::init::__internal::DropGuard::new(::core::addr_of_mut!((*slot).x)) 265 + //! ::pin_init::__internal::DropGuard::new(::core::addr_of_mut!((*slot).x)) 266 266 //! }; 267 267 //! // Since initialization has successfully completed, we can now forget 268 268 //! // the guards. This is not `mem::forget`, since we only have ··· 303 303 //! }; 304 304 //! // Construct the initializer. 305 305 //! let init = unsafe { 306 - //! ::kernel::init::pin_init_from_closure::< 306 + //! ::pin_init::pin_init_from_closure::< 307 307 //! _, 308 308 //! ::core::convert::Infallible, 309 309 //! >(init) ··· 350 350 //! unsafe fn b<E>( 351 351 //! self, 352 352 //! slot: *mut Bar<u32>, 353 - //! init: impl ::kernel::init::PinInit<Bar<u32>, E>, 353 + //! init: impl ::pin_init::PinInit<Bar<u32>, E>, 354 354 //! ) -> ::core::result::Result<(), E> { 355 - //! unsafe { ::kernel::init::PinInit::__pinned_init(init, slot) } 355 + //! unsafe { ::pin_init::PinInit::__pinned_init(init, slot) } 356 356 //! } 357 357 //! unsafe fn a<E>( 358 358 //! self, 359 359 //! slot: *mut usize, 360 - //! init: impl ::kernel::init::Init<usize, E>, 360 + //! init: impl ::pin_init::Init<usize, E>, 361 361 //! ) -> ::core::result::Result<(), E> { 362 - //! unsafe { ::kernel::init::Init::__init(init, slot) } 362 + //! unsafe { ::pin_init::Init::__init(init, slot) } 363 363 //! } 364 364 //! } 365 - //! unsafe impl ::kernel::init::__internal::HasPinData for Foo { 365 + //! unsafe impl ::pin_init::__internal::HasPinData for Foo { 366 366 //! type PinData = __ThePinData; 367 367 //! unsafe fn __pin_data() -> Self::PinData { 368 368 //! __ThePinData { ··· 370 370 //! } 371 371 //! } 372 372 //! } 373 - //! unsafe impl ::kernel::init::__internal::PinData for __ThePinData { 373 + //! unsafe impl ::pin_init::__internal::PinData for __ThePinData { 374 374 //! type Datee = Foo; 375 375 //! } 376 376 //! #[allow(dead_code)] ··· 394 394 //! let pinned = unsafe { ::core::pin::Pin::new_unchecked(self) }; 395 395 //! // Create the unsafe token that proves that we are inside of a destructor, this 396 396 //! // type is only allowed to be created in a destructor. 397 - //! let token = unsafe { ::kernel::init::__internal::OnlyCallFromDrop::new() }; 398 - //! ::kernel::init::PinnedDrop::drop(pinned, token); 397 + //! let token = unsafe { ::pin_init::__internal::OnlyCallFromDrop::new() }; 398 + //! ::pin_init::PinnedDrop::drop(pinned, token); 399 399 //! } 400 400 //! } 401 401 //! }; ··· 421 421 //! 422 422 //! ```rust,ignore 423 423 //! // `unsafe`, full path and the token parameter are added, everything else stays the same. 424 - //! unsafe impl ::kernel::init::PinnedDrop for Foo { 425 - //! fn drop(self: Pin<&mut Self>, _: ::kernel::init::__internal::OnlyCallFromDrop) { 424 + //! unsafe impl ::pin_init::PinnedDrop for Foo { 425 + //! fn drop(self: Pin<&mut Self>, _: ::pin_init::__internal::OnlyCallFromDrop) { 426 426 //! pr_info!("{self:p} is getting dropped."); 427 427 //! } 428 428 //! } ··· 448 448 //! let initializer = { 449 449 //! struct __InitOk; 450 450 //! let data = unsafe { 451 - //! use ::kernel::init::__internal::HasPinData; 451 + //! use ::pin_init::__internal::HasPinData; 452 452 //! Foo::__pin_data() 453 453 //! }; 454 - //! let init = ::kernel::init::__internal::PinData::make_closure::< 454 + //! let init = ::pin_init::__internal::PinData::make_closure::< 455 455 //! _, 456 456 //! __InitOk, 457 457 //! ::core::convert::Infallible, ··· 462 462 //! unsafe { ::core::ptr::write(::core::addr_of_mut!((*slot).a), a) }; 463 463 //! } 464 464 //! let __a_guard = unsafe { 465 - //! ::kernel::init::__internal::DropGuard::new(::core::addr_of_mut!((*slot).a)) 465 + //! ::pin_init::__internal::DropGuard::new(::core::addr_of_mut!((*slot).a)) 466 466 //! }; 467 467 //! let init = Bar::new(36); 468 468 //! unsafe { data.b(::core::addr_of_mut!((*slot).b), b)? }; 469 469 //! let __b_guard = unsafe { 470 - //! ::kernel::init::__internal::DropGuard::new(::core::addr_of_mut!((*slot).b)) 470 + //! ::pin_init::__internal::DropGuard::new(::core::addr_of_mut!((*slot).b)) 471 471 //! }; 472 472 //! ::core::mem::forget(__b_guard); 473 473 //! ::core::mem::forget(__a_guard); ··· 492 492 //! init(slot).map(|__InitOk| ()) 493 493 //! }; 494 494 //! let init = unsafe { 495 - //! ::kernel::init::pin_init_from_closure::<_, ::core::convert::Infallible>(init) 495 + //! ::pin_init::pin_init_from_closure::<_, ::core::convert::Infallible>(init) 496 496 //! }; 497 497 //! init 498 498 //! }; 499 499 //! ``` 500 500 501 + #[cfg(kernel)] 501 502 pub use ::macros::paste; 503 + #[cfg(not(kernel))] 504 + pub use ::paste::paste; 502 505 503 506 /// Creates a `unsafe impl<...> PinnedDrop for $type` block. 504 507 /// ··· 522 519 unsafe $($impl_sig)* { 523 520 // Inherit all attributes and the type/ident tokens for the signature. 524 521 $(#[$($attr)*])* 525 - fn drop($($sig)*, _: $crate::init::__internal::OnlyCallFromDrop) { 522 + fn drop($($sig)*, _: $crate::__internal::OnlyCallFromDrop) { 526 523 $($inner)* 527 524 } 528 525 } ··· 868 865 // SAFETY: We have added the correct projection functions above to `__ThePinData` and 869 866 // we also use the least restrictive generics possible. 870 867 unsafe impl<$($impl_generics)*> 871 - $crate::init::__internal::HasPinData for $name<$($ty_generics)*> 868 + $crate::__internal::HasPinData for $name<$($ty_generics)*> 872 869 where $($whr)* 873 870 { 874 871 type PinData = __ThePinData<$($ty_generics)*>; ··· 880 877 881 878 // SAFETY: TODO. 882 879 unsafe impl<$($impl_generics)*> 883 - $crate::init::__internal::PinData for __ThePinData<$($ty_generics)*> 880 + $crate::__internal::PinData for __ThePinData<$($ty_generics)*> 884 881 where $($whr)* 885 882 { 886 883 type Datee = $name<$($ty_generics)*>; ··· 939 936 // `PinnedDrop` as the parameter to `#[pin_data]`. 940 937 #[expect(non_camel_case_types)] 941 938 trait UselessPinnedDropImpl_you_need_to_specify_PinnedDrop {} 942 - impl<T: $crate::init::PinnedDrop> 939 + impl<T: $crate::PinnedDrop> 943 940 UselessPinnedDropImpl_you_need_to_specify_PinnedDrop for T {} 944 941 impl<$($impl_generics)*> 945 942 UselessPinnedDropImpl_you_need_to_specify_PinnedDrop for $name<$($ty_generics)*> ··· 962 959 let pinned = unsafe { ::core::pin::Pin::new_unchecked(self) }; 963 960 // SAFETY: Since this is a drop function, we can create this token to call the 964 961 // pinned destructor of this type. 965 - let token = unsafe { $crate::init::__internal::OnlyCallFromDrop::new() }; 966 - $crate::init::PinnedDrop::drop(pinned, token); 962 + let token = unsafe { $crate::__internal::OnlyCallFromDrop::new() }; 963 + $crate::PinnedDrop::drop(pinned, token); 967 964 } 968 965 } 969 966 }; ··· 1003 1000 $pvis unsafe fn $p_field<E>( 1004 1001 self, 1005 1002 slot: *mut $p_type, 1006 - init: impl $crate::init::PinInit<$p_type, E>, 1003 + init: impl $crate::PinInit<$p_type, E>, 1007 1004 ) -> ::core::result::Result<(), E> { 1008 1005 // SAFETY: TODO. 1009 - unsafe { $crate::init::PinInit::__pinned_init(init, slot) } 1006 + unsafe { $crate::PinInit::__pinned_init(init, slot) } 1010 1007 } 1011 1008 )* 1012 1009 $( ··· 1014 1011 $fvis unsafe fn $field<E>( 1015 1012 self, 1016 1013 slot: *mut $type, 1017 - init: impl $crate::init::Init<$type, E>, 1014 + init: impl $crate::Init<$type, E>, 1018 1015 ) -> ::core::result::Result<(), E> { 1019 1016 // SAFETY: TODO. 1020 - unsafe { $crate::init::Init::__init(init, slot) } 1017 + unsafe { $crate::Init::__init(init, slot) } 1021 1018 } 1022 1019 )* 1023 1020 } ··· 1134 1131 // 1135 1132 // SAFETY: TODO. 1136 1133 let data = unsafe { 1137 - use $crate::init::__internal::$has_data; 1134 + use $crate::__internal::$has_data; 1138 1135 // Here we abuse `paste!` to retokenize `$t`. Declarative macros have some internal 1139 1136 // information that is associated to already parsed fragments, so a path fragment 1140 1137 // cannot be used in this position. Doing the retokenization results in valid rust 1141 1138 // code. 1142 - $crate::init::macros::paste!($t::$get_data()) 1139 + $crate::macros::paste!($t::$get_data()) 1143 1140 }; 1144 1141 // Ensure that `data` really is of type `$data` and help with type inference: 1145 - let init = $crate::init::__internal::$data::make_closure::<_, __InitOk, $err>( 1142 + let init = $crate::__internal::$data::make_closure::<_, __InitOk, $err>( 1146 1143 data, 1147 1144 move |slot| { 1148 1145 { ··· 1152 1149 // error when fields are missing (since they will be zeroed). We also have to 1153 1150 // check that the type actually implements `Zeroable`. 1154 1151 $({ 1155 - fn assert_zeroable<T: $crate::init::Zeroable>(_: *mut T) {} 1152 + fn assert_zeroable<T: $crate::Zeroable>(_: *mut T) {} 1156 1153 // Ensure that the struct is indeed `Zeroable`. 1157 1154 assert_zeroable(slot); 1158 1155 // SAFETY: The type implements `Zeroable` by the check above. ··· 1189 1186 init(slot).map(|__InitOk| ()) 1190 1187 }; 1191 1188 // SAFETY: TODO. 1192 - let init = unsafe { $crate::init::$construct_closure::<_, $err>(init) }; 1189 + let init = unsafe { $crate::$construct_closure::<_, $err>(init) }; 1193 1190 init 1194 1191 }}; 1195 1192 (init_slot($($use_data:ident)?): ··· 1220 1217 // 1221 1218 // We rely on macro hygiene to make it impossible for users to access this local variable. 1222 1219 // We use `paste!` to create new hygiene for `$field`. 1223 - $crate::init::macros::paste! { 1220 + $crate::macros::paste! { 1224 1221 // SAFETY: We forget the guard later when initialization has succeeded. 1225 1222 let [< __ $field _guard >] = unsafe { 1226 - $crate::init::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field)) 1223 + $crate::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field)) 1227 1224 }; 1228 1225 1229 1226 $crate::__init_internal!(init_slot($use_data): ··· 1246 1243 // 1247 1244 // SAFETY: `slot` is valid, because we are inside of an initializer closure, we 1248 1245 // return when an error/panic occurs. 1249 - unsafe { $crate::init::Init::__init(init, ::core::ptr::addr_of_mut!((*$slot).$field))? }; 1246 + unsafe { $crate::Init::__init(init, ::core::ptr::addr_of_mut!((*$slot).$field))? }; 1250 1247 // Create the drop guard: 1251 1248 // 1252 1249 // We rely on macro hygiene to make it impossible for users to access this local variable. 1253 1250 // We use `paste!` to create new hygiene for `$field`. 1254 - $crate::init::macros::paste! { 1251 + $crate::macros::paste! { 1255 1252 // SAFETY: We forget the guard later when initialization has succeeded. 1256 1253 let [< __ $field _guard >] = unsafe { 1257 - $crate::init::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field)) 1254 + $crate::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field)) 1258 1255 }; 1259 1256 1260 1257 $crate::__init_internal!(init_slot(): ··· 1283 1280 // 1284 1281 // We rely on macro hygiene to make it impossible for users to access this local variable. 1285 1282 // We use `paste!` to create new hygiene for `$field`. 1286 - $crate::init::macros::paste! { 1283 + $crate::macros::paste! { 1287 1284 // SAFETY: We forget the guard later when initialization has succeeded. 1288 1285 let [< __ $field _guard >] = unsafe { 1289 - $crate::init::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field)) 1286 + $crate::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field)) 1290 1287 }; 1291 1288 1292 1289 $crate::__init_internal!(init_slot($($use_data)?): ··· 1320 1317 // information that is associated to already parsed fragments, so a path fragment 1321 1318 // cannot be used in this position. Doing the retokenization results in valid rust 1322 1319 // code. 1323 - $crate::init::macros::paste!( 1320 + $crate::macros::paste!( 1324 1321 ::core::ptr::write($slot, $t { 1325 1322 $($acc)* 1326 1323 ..zeroed ··· 1344 1341 // information that is associated to already parsed fragments, so a path fragment 1345 1342 // cannot be used in this position. Doing the retokenization results in valid rust 1346 1343 // code. 1347 - $crate::init::macros::paste!( 1344 + $crate::macros::paste!( 1348 1345 ::core::ptr::write($slot, $t { 1349 1346 $($acc)* 1350 1347 }); ··· 1399 1396 ) => { 1400 1397 // SAFETY: Every field type implements `Zeroable` and padding bytes may be zero. 1401 1398 #[automatically_derived] 1402 - unsafe impl<$($impl_generics)*> $crate::init::Zeroable for $name<$($ty_generics)*> 1399 + unsafe impl<$($impl_generics)*> $crate::Zeroable for $name<$($ty_generics)*> 1403 1400 where 1404 1401 $($($whr)*)? 1405 1402 {} 1406 1403 const _: () = { 1407 - fn assert_zeroable<T: ?::core::marker::Sized + $crate::init::Zeroable>() {} 1404 + fn assert_zeroable<T: ?::core::marker::Sized + $crate::Zeroable>() {} 1408 1405 fn ensure_zeroable<$($impl_generics)*>() 1409 1406 where $($($whr)*)? 1410 1407 {
+2 -2
scripts/generate_rust_analyzer.py
··· 95 95 96 96 append_crate( 97 97 "pin_init_internal", 98 - srctree / "rust" / "pin-init" / "internal" / "src" / "_lib.rs", 98 + srctree / "rust" / "pin-init" / "internal" / "src" / "lib.rs", 99 99 [], 100 100 cfg=["kernel"], 101 101 is_proc_macro=True, ··· 103 103 104 104 append_crate( 105 105 "pin_init", 106 - srctree / "rust" / "pin-init" / "src" / "_lib.rs", 106 + srctree / "rust" / "pin-init" / "src" / "lib.rs", 107 107 ["core", "pin_init_internal", "macros"], 108 108 cfg=["kernel"], 109 109 )