Skip to content

Commit 79deef1

Browse files
committed
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 <gary@garyguo.net> Signed-off-by: Benno Lossin <lossin@kernel.org>
1 parent 40618c0 commit 79deef1

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

rust/pin-init/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,11 @@ use core::{
290290
ptr::{self, NonNull},
291291
};
292292

293+
// This is used by doc-tests -- the proc-macros expand to `::pin_init::...` and without this the
294+
// doc-tests wouldn't have an extern crate named `pin_init`.
295+
#[allow(unused_extern_crates)]
296+
extern crate self as pin_init;
297+
293298
#[doc(hidden)]
294299
pub mod __internal;
295300
#[doc(hidden)]

0 commit comments

Comments
 (0)