Commit 2c109285 authored by Wedson Almeida Filho's avatar Wedson Almeida Filho Committed by Miguel Ojeda
Browse files

rust: kernel: remove usage of `allocator_api` unstable feature



With the adoption of `BoxExt` and `VecExt`, we don't need the functions
provided by this feature (namely the methods prefixed with `try_` and
different allocator per collection instance).

We do need `AllocError`, but we define our own as it is a trivial empty
struct.

Reviewed-by: default avatarBenno Lossin <benno.lossin@proton.me>
Signed-off-by: default avatarWedson Almeida Filho <walmeida@microsoft.com>
Link: https://lore.kernel.org/r/20240328013603.206764-11-wedsonaf@gmail.com


Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
parent c34aa00d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -8,6 +8,10 @@
pub mod box_ext;
pub mod vec_ext;

/// Indicates an allocation error.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct AllocError;

/// Flags to be used when allocating memory.
///
/// They can be combined with the operators `|`, `&`, and `!`.
+1 −2
Original line number Diff line number Diff line
@@ -2,9 +2,8 @@

//! Extensions to [`Box`] for fallible allocations.

use super::Flags;
use super::{AllocError, Flags};
use alloc::boxed::Box;
use core::alloc::AllocError;
use core::mem::MaybeUninit;
use core::result::Result;

+2 −2
Original line number Diff line number Diff line
@@ -2,8 +2,8 @@

//! Extensions to [`Vec`] for fallible allocations.

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

/// Extensions to [`Vec`].
+2 −2
Original line number Diff line number Diff line
@@ -4,9 +4,9 @@
//!
//! C header: [`include/uapi/asm-generic/errno-base.h`](srctree/include/uapi/asm-generic/errno-base.h)

use crate::str::CStr;
use crate::{alloc::AllocError, str::CStr};

use alloc::alloc::{AllocError, LayoutError};
use alloc::alloc::LayoutError;

use core::convert::From;
use core::fmt;
+1 −2
Original line number Diff line number Diff line
@@ -211,14 +211,13 @@
//! [`pin_init!`]: crate::pin_init!

use crate::{
    alloc::{box_ext::BoxExt, Flags},
    alloc::{box_ext::BoxExt, AllocError, Flags},
    error::{self, Error},
    sync::UniqueArc,
    types::{Opaque, ScopeGuard},
};
use alloc::boxed::Box;
use core::{
    alloc::AllocError,
    cell::UnsafeCell,
    convert::Infallible,
    marker::PhantomData,
Loading