Skip to content

Commit ec51531

Browse files
author
Danilo Krummrich
committed
rust: alloc: cleanup doctest imports to "kernel vertical" style
Change all imports in the alloc module's doctests to use the "kernel vertical" import style [1]. While at it, drop imports that are automatically included in doctests. Link: https://docs.kernel.org/rust/coding-guidelines.html#imports [1] Reviewed-by: Eliot Courtney <ecourtney@nvidia.com> Link: https://patch.msgid.link/20260513190946.619810-2-dakr@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
1 parent 9b25d41 commit ec51531

4 files changed

Lines changed: 27 additions & 12 deletions

File tree

rust/kernel/alloc/allocator.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,11 @@ impl Vmalloc {
174174
/// # Examples
175175
///
176176
/// ```
177-
/// # use core::ptr::{NonNull, from_mut};
178-
/// # use kernel::{page, prelude::*};
177+
/// # use core::ptr::{
178+
/// # from_mut,
179+
/// # NonNull, //
180+
/// # };
181+
/// # use kernel::page;
179182
/// use kernel::alloc::allocator::Vmalloc;
180183
///
181184
/// let mut vbox = VBox::<[u8; page::PAGE_SIZE]>::new_uninit(GFP_KERNEL)?;

rust/kernel/alloc/kbox.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,10 @@ where
297297
/// # Examples
298298
///
299299
/// ```
300-
/// use kernel::sync::{new_spinlock, SpinLock};
300+
/// use kernel::sync::{
301+
/// new_spinlock,
302+
/// SpinLock, //
303+
/// };
301304
///
302305
/// struct Inner {
303306
/// a: u32,
@@ -590,7 +593,6 @@ where
590593
///
591594
/// ```
592595
/// # use core::borrow::Borrow;
593-
/// # use kernel::alloc::KBox;
594596
/// struct Foo<B: Borrow<u32>>(B);
595597
///
596598
/// // Owned instance.
@@ -618,7 +620,6 @@ where
618620
///
619621
/// ```
620622
/// # use core::borrow::BorrowMut;
621-
/// # use kernel::alloc::KBox;
622623
/// struct Foo<B: BorrowMut<u32>>(B);
623624
///
624625
/// // Owned instance.
@@ -683,9 +684,13 @@ where
683684
/// # Examples
684685
///
685686
/// ```
686-
/// # use kernel::prelude::*;
687-
/// use kernel::alloc::allocator::VmallocPageIter;
688-
/// use kernel::page::{AsPageIter, PAGE_SIZE};
687+
/// use kernel::{
688+
/// alloc::allocator::VmallocPageIter,
689+
/// page::{
690+
/// AsPageIter,
691+
/// PAGE_SIZE, //
692+
/// }, //
693+
/// };
689694
///
690695
/// let mut vbox = VBox::new((), GFP_KERNEL)?;
691696
///

rust/kernel/alloc/kvec.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,9 +1187,13 @@ where
11871187
/// # Examples
11881188
///
11891189
/// ```
1190-
/// # use kernel::prelude::*;
1191-
/// use kernel::alloc::allocator::VmallocPageIter;
1192-
/// use kernel::page::{AsPageIter, PAGE_SIZE};
1190+
/// use kernel::{
1191+
/// alloc::allocator::VmallocPageIter,
1192+
/// page::{
1193+
/// AsPageIter,
1194+
/// PAGE_SIZE, //
1195+
/// }, //
1196+
/// };
11931197
///
11941198
/// let mut vec = VVec::<u8>::new();
11951199
///

rust/kernel/alloc/layout.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ impl<T> ArrayLayout<T> {
5050
/// # Examples
5151
///
5252
/// ```
53-
/// # use kernel::alloc::layout::{ArrayLayout, LayoutError};
53+
/// # use kernel::alloc::layout::{
54+
/// # ArrayLayout,
55+
/// # LayoutError, //
56+
/// # };
5457
/// let layout = ArrayLayout::<i32>::new(15)?;
5558
/// assert_eq!(layout.len(), 15);
5659
///

0 commit comments

Comments
 (0)