Skip to content

Commit b321b93

Browse files
y86-devojeda
authored andcommittedMar 16, 2025
rust: pin-init: change the way the paste! macro is called
Change the paste macro path from `::kernel::macros::paste!` to use `$crate::init::macros::paste!` instead, which links to `::macros::paste!`. This is because the pin-init crate will be a dependency of the kernel, so it itself cannot have the kernel as a dependency. Signed-off-by: Benno Lossin <benno.lossin@proton.me> Reviewed-by: Fiona Behrens <me@kloenk.dev> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org> Tested-by: Andreas Hindborg <a.hindborg@kernel.org> Link: https://lore.kernel.org/r/20250308110339.2997091-14-benno.lossin@proton.me Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 31547c9 commit b321b93

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed
 

‎rust/pin-init/src/macros.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,8 @@
498498
//! };
499499
//! ```
500500
501+
pub use ::macros::paste;
502+
501503
/// Creates a `unsafe impl<...> PinnedDrop for $type` block.
502504
///
503505
/// See [`PinnedDrop`] for more information.
@@ -1134,7 +1136,7 @@ macro_rules! __init_internal {
11341136
// information that is associated to already parsed fragments, so a path fragment
11351137
// cannot be used in this position. Doing the retokenization results in valid rust
11361138
// code.
1137-
::kernel::macros::paste!($t::$get_data())
1139+
$crate::init::macros::paste!($t::$get_data())
11381140
};
11391141
// Ensure that `data` really is of type `$data` and help with type inference:
11401142
let init = $crate::init::__internal::$data::make_closure::<_, __InitOk, $err>(
@@ -1215,7 +1217,7 @@ macro_rules! __init_internal {
12151217
//
12161218
// We rely on macro hygiene to make it impossible for users to access this local variable.
12171219
// We use `paste!` to create new hygiene for `$field`.
1218-
::kernel::macros::paste! {
1220+
$crate::init::macros::paste! {
12191221
// SAFETY: We forget the guard later when initialization has succeeded.
12201222
let [< __ $field _guard >] = unsafe {
12211223
$crate::init::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field))
@@ -1246,7 +1248,7 @@ macro_rules! __init_internal {
12461248
//
12471249
// We rely on macro hygiene to make it impossible for users to access this local variable.
12481250
// We use `paste!` to create new hygiene for `$field`.
1249-
::kernel::macros::paste! {
1251+
$crate::init::macros::paste! {
12501252
// SAFETY: We forget the guard later when initialization has succeeded.
12511253
let [< __ $field _guard >] = unsafe {
12521254
$crate::init::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field))
@@ -1278,7 +1280,7 @@ macro_rules! __init_internal {
12781280
//
12791281
// We rely on macro hygiene to make it impossible for users to access this local variable.
12801282
// We use `paste!` to create new hygiene for `$field`.
1281-
::kernel::macros::paste! {
1283+
$crate::init::macros::paste! {
12821284
// SAFETY: We forget the guard later when initialization has succeeded.
12831285
let [< __ $field _guard >] = unsafe {
12841286
$crate::init::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field))
@@ -1315,7 +1317,7 @@ macro_rules! __init_internal {
13151317
// information that is associated to already parsed fragments, so a path fragment
13161318
// cannot be used in this position. Doing the retokenization results in valid rust
13171319
// code.
1318-
::kernel::macros::paste!(
1320+
$crate::init::macros::paste!(
13191321
::core::ptr::write($slot, $t {
13201322
$($acc)*
13211323
..zeroed
@@ -1339,7 +1341,7 @@ macro_rules! __init_internal {
13391341
// information that is associated to already parsed fragments, so a path fragment
13401342
// cannot be used in this position. Doing the retokenization results in valid rust
13411343
// code.
1342-
::kernel::macros::paste!(
1344+
$crate::init::macros::paste!(
13431345
::core::ptr::write($slot, $t {
13441346
$($acc)*
13451347
});

0 commit comments

Comments
 (0)
Please sign in to comment.