Re: [PATCH 1/2] rust: alloc: cleanup imports and use "kernel vertical" style

From: Danilo Krummrich

Date: Tue May 12 2026 - 11:22:33 EST


On Tue May 12, 2026 at 3:46 PM CEST, Eliot Courtney wrote:
> On Tue May 12, 2026 at 6:41 AM JST, Danilo Krummrich wrote:
>> Change all imports in the alloc module to use the "kernel vertical"
>> import style [1].
>>
>> While at it, drop unnecessary imports covered by prelude::*.
>>
>> Link: https://docs.kernel.org/rust/coding-guidelines.html#imports [1]
>> Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>
>> ---
>
> There are some non-vertical style imports in rust/kernel/alloc.rs,
> should those be changed too?

Yes, thanks for catching this, and the one below.

>> --- a/rust/kernel/alloc/kbox.rs
>> +++ b/rust/kernel/alloc/kbox.rs
>> @@ -3,24 +3,46 @@
>> //! Implementation of [`Box`].
>>
>> #[allow(unused_imports)] // Used in doc comments.
>> -use super::allocator::{KVmalloc, Kmalloc, Vmalloc, VmallocPageIter};
>> -use super::{AllocError, Allocator, Flags, NumaNode};
>> -use core::alloc::Layout;
>> -use core::borrow::{Borrow, BorrowMut};
>> -use core::marker::PhantomData;
>> -use core::mem::ManuallyDrop;
>> -use core::mem::MaybeUninit;
>> -use core::ops::{Deref, DerefMut};
>> -use core::pin::Pin;
>> -use core::ptr::NonNull;
>> -use core::result::Result;
>> -
>> -use crate::ffi::c_void;
>> -use crate::fmt;
>> -use crate::init::InPlaceInit;
>> -use crate::page::AsPageIter;
>> -use crate::types::ForeignOwnable;
>> -use pin_init::{InPlaceWrite, Init, PinInit, ZeroableOption};
>> +use super::{
>> + allocator::{
>> + KVmalloc,
>> + Kmalloc,
>> + Vmalloc,
>> + VmallocPageIter, //
>> + },
>> + AllocError,
>> + Allocator,
>> + Flags,
>> + NumaNode, //
>> +};
>
> This changes the scope of `allow(unused_imports)`. Is this intentional?
>
> Both nits so:
>
> Reviewed-by: Eliot Courtney <ecourtney@xxxxxxxxxx>