|
243 | 243 | //! [structurally pinned fields]:
|
244 | 244 | //! https://doc.rust-lang.org/std/pin/index.html#pinning-is-structural-for-field
|
245 | 245 | //! [stack]: crate::stack_pin_init
|
246 |
| -//! [`Arc<T>`]: https://doc.rust-lang.org/stable/alloc/sync/struct.Arc.html |
247 |
| -//! [`Box<T>`]: https://doc.rust-lang.org/stable/alloc/boxed/struct.Box.html |
| 246 | +#![cfg_attr( |
| 247 | + kernel, |
| 248 | + doc = "[`Arc<T>`]: https://rust.docs.kernel.org/kernel/sync/struct.Arc.html" |
| 249 | +)] |
| 250 | +#![cfg_attr( |
| 251 | + kernel, |
| 252 | + doc = "[`Box<T>`]: https://rust.docs.kernel.org/kernel/alloc/kbox/struct.Box.html" |
| 253 | +)] |
| 254 | +#![cfg_attr(not(kernel), doc = "[`Arc<T>`]: alloc::alloc::sync::Arc")] |
| 255 | +#![cfg_attr(not(kernel), doc = "[`Box<T>`]: alloc::alloc::boxed::Box")] |
248 | 256 | //! [`impl PinInit<Foo>`]: crate::PinInit
|
249 | 257 | //! [`impl PinInit<T, E>`]: crate::PinInit
|
250 | 258 | //! [`impl Init<T, E>`]: crate::Init
|
@@ -981,8 +989,16 @@ macro_rules! assert_pinned {
|
981 | 989 | /// - `slot` is not partially initialized.
|
982 | 990 | /// - while constructing the `T` at `slot` it upholds the pinning invariants of `T`.
|
983 | 991 | ///
|
984 |
| -/// [`Arc<T>`]: alloc::alloc::sync::Arc |
985 |
| -/// [`Box<T>`]: alloc::alloc::boxed::Box |
| 992 | +#[cfg_attr( |
| 993 | + kernel, |
| 994 | + doc = "[`Arc<T>`]: https://rust.docs.kernel.org/kernel/sync/struct.Arc.html" |
| 995 | +)] |
| 996 | +#[cfg_attr( |
| 997 | + kernel, |
| 998 | + doc = "[`Box<T>`]: https://rust.docs.kernel.org/kernel/alloc/kbox/struct.Box.html" |
| 999 | +)] |
| 1000 | +#[cfg_attr(not(kernel), doc = "[`Arc<T>`]: alloc::alloc::sync::Arc")] |
| 1001 | +#[cfg_attr(not(kernel), doc = "[`Box<T>`]: alloc::alloc::boxed::Box")] |
986 | 1002 | #[must_use = "An initializer must be used in order to create its value."]
|
987 | 1003 | pub unsafe trait PinInit<T: ?Sized, E = Infallible>: Sized {
|
988 | 1004 | /// Initializes `slot`.
|
@@ -1072,8 +1088,16 @@ where
|
1072 | 1088 | /// Contrary to its supertype [`PinInit<T, E>`] the caller is allowed to
|
1073 | 1089 | /// move the pointee after initialization.
|
1074 | 1090 | ///
|
1075 |
| -/// [`Arc<T>`]: alloc::alloc::sync::Arc |
1076 |
| -/// [`Box<T>`]: alloc::alloc::boxed::Box |
| 1091 | +#[cfg_attr( |
| 1092 | + kernel, |
| 1093 | + doc = "[`Arc<T>`]: https://rust.docs.kernel.org/kernel/sync/struct.Arc.html" |
| 1094 | +)] |
| 1095 | +#[cfg_attr( |
| 1096 | + kernel, |
| 1097 | + doc = "[`Box<T>`]: https://rust.docs.kernel.org/kernel/alloc/kbox/struct.Box.html" |
| 1098 | +)] |
| 1099 | +#[cfg_attr(not(kernel), doc = "[`Arc<T>`]: alloc::alloc::sync::Arc")] |
| 1100 | +#[cfg_attr(not(kernel), doc = "[`Box<T>`]: alloc::alloc::boxed::Box")] |
1077 | 1101 | #[must_use = "An initializer must be used in order to create its value."]
|
1078 | 1102 | pub unsafe trait Init<T: ?Sized, E = Infallible>: PinInit<T, E> {
|
1079 | 1103 | /// Initializes `slot`.
|
@@ -1422,16 +1446,13 @@ impl_zeroable! {
|
1422 | 1446 | // SAFETY: `T: Zeroable` and `UnsafeCell` is `repr(transparent)`.
|
1423 | 1447 | {<T: ?Sized + Zeroable>} UnsafeCell<T>,
|
1424 | 1448 |
|
1425 |
| - // SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee). |
| 1449 | + // SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee: |
| 1450 | + // https://doc.rust-lang.org/stable/std/option/index.html#representation). |
1426 | 1451 | Option<NonZeroU8>, Option<NonZeroU16>, Option<NonZeroU32>, Option<NonZeroU64>,
|
1427 | 1452 | Option<NonZeroU128>, Option<NonZeroUsize>,
|
1428 | 1453 | Option<NonZeroI8>, Option<NonZeroI16>, Option<NonZeroI32>, Option<NonZeroI64>,
|
1429 | 1454 | Option<NonZeroI128>, Option<NonZeroIsize>,
|
1430 |
| - |
1431 |
| - // SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee). |
1432 |
| - // |
1433 |
| - // In this case we are allowed to use `T: ?Sized`, since all zeros is the `None` variant. |
1434 |
| - {<T: ?Sized>} Option<NonNull<T>>, |
| 1455 | + {<T>} Option<NonNull<T>>, |
1435 | 1456 |
|
1436 | 1457 | // SAFETY: `null` pointer is valid.
|
1437 | 1458 | //
|
|
0 commit comments