Commit 00280272 authored by Miguel Ojeda's avatar Miguel Ojeda
Browse files

rust: kernel: remove redundant imports

Rust's `unused_imports` lint covers both unused and redundant imports.
In the upcoming 1.78.0, the lint detects more cases of redundant imports
[1], e.g.:

    error: the item `bindings` is imported redundantly
      --> rust/kernel/print.rs:38:9
       |
    38 |     use crate::bindings;
       |         ^^^^^^^^^^^^^^^ the item `bindings` is already defined by prelude

Most cases are `use crate::bindings`, plus a few other items like `Box`.
Thus clean them up.

Note that, in the `bindings` case, the message "defined by prelude"
above means the extern prelude, i.e. the `--extern` flags we pass.

Link: https://github.com/rust-lang/rust/pull/117772

 [1]
Reviewed-by: default avatarAlice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20240401212303.537355-3-ojeda@kernel.org


Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
parent 7c81aa85
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ fn not(self) -> Self::Output {
/// These are meant to be used in functions that can allocate memory.
pub mod flags {
    use super::Flags;
    use crate::bindings;

    /// Zeroes out the allocated memory.
    ///
+0 −2
Original line number Diff line number Diff line
@@ -6,8 +6,6 @@
use core::alloc::{GlobalAlloc, Layout};
use core::ptr;

use crate::bindings;

struct KernelAllocator;

/// Calls `krealloc` with a proper size to alloc a new object aligned to `new_layout`'s alignment.
+0 −1
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@
use super::{AllocError, Flags};
use alloc::boxed::Box;
use core::mem::MaybeUninit;
use core::result::Result;

/// Extensions to [`Box`].
pub trait BoxExt<T>: Sized {
+0 −1
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@

use super::{AllocError, Flags};
use alloc::vec::Vec;
use core::result::Result;

/// Extensions to [`Vec`].
pub trait VecExt<T>: Sized {
+0 −1
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@

use alloc::alloc::LayoutError;

use core::convert::From;
use core::fmt;
use core::num::TryFromIntError;
use core::str::Utf8Error;
Loading