From: Benno Lossin Date: Fri, 16 Jan 2026 10:54:17 +0000 (+0100) Subject: rust: pin-init: allow the crate to refer to itself as `pin-init` in doc tests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=901f1d73d2c68017065212d75ffbfbffa119921e;p=thirdparty%2Fkernel%2Flinux.git rust: pin-init: allow the crate to refer to itself as `pin-init` in doc tests The `syn` approach requires use of `::pin_init::...` instead of the `$crate::...` construct available to declarative macros. To be able to use the `pin_init` crate from itself (which includes doc tests), we have to declare it as such. Reviewed-by: Gary Guo Tested-by: Andreas Hindborg Signed-off-by: Benno Lossin --- diff --git a/rust/pin-init/src/lib.rs b/rust/pin-init/src/lib.rs index 8673008f45d26..0e707f00061f1 100644 --- a/rust/pin-init/src/lib.rs +++ b/rust/pin-init/src/lib.rs @@ -290,6 +290,11 @@ use core::{ ptr::{self, NonNull}, }; +// This is used by doc-tests -- the proc-macros expand to `::pin_init::...` and without this the +// doc-tests wouldn't have an extern crate named `pin_init`. +#[allow(unused_extern_crates)] +extern crate self as pin_init; + #[doc(hidden)] pub mod __internal; #[doc(hidden)]