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: 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>

authored by

Benno Lossin and committed by
Miguel Ojeda
b321b938 31547c98

+8 -6
+8 -6
rust/pin-init/src/macros.rs
··· 498 498 //! }; 499 499 //! ``` 500 500 501 + pub use ::macros::paste; 502 + 501 503 /// Creates a `unsafe impl<...> PinnedDrop for $type` block. 502 504 /// 503 505 /// See [`PinnedDrop`] for more information. ··· 1136 1134 // information that is associated to already parsed fragments, so a path fragment 1137 1135 // cannot be used in this position. Doing the retokenization results in valid rust 1138 1136 // code. 1139 - ::kernel::macros::paste!($t::$get_data()) 1137 + $crate::init::macros::paste!($t::$get_data()) 1140 1138 }; 1141 1139 // Ensure that `data` really is of type `$data` and help with type inference: 1142 1140 let init = $crate::init::__internal::$data::make_closure::<_, __InitOk, $err>( ··· 1217 1215 // 1218 1216 // We rely on macro hygiene to make it impossible for users to access this local variable. 1219 1217 // We use `paste!` to create new hygiene for `$field`. 1220 - ::kernel::macros::paste! { 1218 + $crate::init::macros::paste! { 1221 1219 // SAFETY: We forget the guard later when initialization has succeeded. 1222 1220 let [< __ $field _guard >] = unsafe { 1223 1221 $crate::init::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field)) ··· 1248 1246 // 1249 1247 // We rely on macro hygiene to make it impossible for users to access this local variable. 1250 1248 // We use `paste!` to create new hygiene for `$field`. 1251 - ::kernel::macros::paste! { 1249 + $crate::init::macros::paste! { 1252 1250 // SAFETY: We forget the guard later when initialization has succeeded. 1253 1251 let [< __ $field _guard >] = unsafe { 1254 1252 $crate::init::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field)) ··· 1280 1278 // 1281 1279 // We rely on macro hygiene to make it impossible for users to access this local variable. 1282 1280 // We use `paste!` to create new hygiene for `$field`. 1283 - ::kernel::macros::paste! { 1281 + $crate::init::macros::paste! { 1284 1282 // SAFETY: We forget the guard later when initialization has succeeded. 1285 1283 let [< __ $field _guard >] = unsafe { 1286 1284 $crate::init::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field)) ··· 1317 1315 // information that is associated to already parsed fragments, so a path fragment 1318 1316 // cannot be used in this position. Doing the retokenization results in valid rust 1319 1317 // code. 1320 - ::kernel::macros::paste!( 1318 + $crate::init::macros::paste!( 1321 1319 ::core::ptr::write($slot, $t { 1322 1320 $($acc)* 1323 1321 ..zeroed ··· 1341 1339 // information that is associated to already parsed fragments, so a path fragment 1342 1340 // cannot be used in this position. Doing the retokenization results in valid rust 1343 1341 // code. 1344 - ::kernel::macros::paste!( 1342 + $crate::init::macros::paste!( 1345 1343 ::core::ptr::write($slot, $t { 1346 1344 $($acc)* 1347 1345 });