From nobody Wed Apr 1 22:11:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E670324B16; Wed, 1 Apr 2026 11:46:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775044011; cv=none; b=pH3V4ck5LdCoexCbwWTS7tExcbGukFlWvnDnxzNb62iO/ITZThFqfe6fVE4/D4RToy0q20EJu0z0M5pLMC4MFPXNvp4tT3xelLApsKGbfPhHC/u8xAjPks9+xyDcn3BYPX+ufNunTYT8USuDFEeCmc7qsLwqkXXM55v/oEffI14= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775044011; c=relaxed/simple; bh=e8DhGnWyulpeNMl4zQDOtzs8M6k0lQwkocXJf8Znql4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NaGanF02o4RoL328QSK54zaacB8WeKzXO5+0u8d47APx4imXYGgHSsHIdUgeDFgFfv492sEwf+wvxHqcioozgmdct+ymnw+o5x9Xu2HymfOllHjg3d+DhM07giWc8jGmXHeLnEWgmhegemcSUYwuy8p06TXuOPwIqQ5RsrDMZPI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CndxmCi7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CndxmCi7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E848C4AF0C; Wed, 1 Apr 2026 11:46:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775044010; bh=e8DhGnWyulpeNMl4zQDOtzs8M6k0lQwkocXJf8Znql4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CndxmCi7THhrnhCFzhqy6KvbAgEkGaA5pYgccV/CQjuh3yuwhgtAGKi7YOptKJvyo kqULk/HwSV6RulLc0BWsv4O79mDs8iMcZCf91sdFQFz50VKP0sjsIyfBh+0qQeCTdo rCvPjk9C4McT1wKkvlhKcCB4WTzc75OK8oXNtoIsN5ZrjbB14gsu4pP4ZuffkXa6E+ GnVppQRnM/P0zARZDYa4UbsPlNPZHeWHpRT83O3pCygzfG7boiRlqXD0Fx8HTVqGdP fptMVM7dF4BLILbhiF62wWFdnCWOMxzNVvxybKbvshYWAqQq96KPt5nO0sw2WFo9Bf 3EKqN9cfSKgzA== From: Miguel Ojeda To: Miguel Ojeda , Nathan Chancellor , Nicolas Schier , Danilo Krummrich , Andreas Hindborg , Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Courbot , David Airlie , Simona Vetter , Brendan Higgins , David Gow , Greg Kroah-Hartman , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Christian Brauner , Carlos Llamas , Alice Ryhl , Jonathan Corbet Cc: Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Trevor Gross , rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org, Lorenzo Stoakes , Vlastimil Babka , "Liam R . Howlett" , Uladzislau Rezki , linux-block@vger.kernel.org, linux-arm-kernel@lists.infradead.org (moderated for non-subscribers), Alexandre Ghiti , linux-riscv@lists.infradead.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Rae Moar , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Nick Desaulniers , Bill Wendling , Justin Stitt , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Shuah Khan , linux-doc@vger.kernel.org Subject: [PATCH 04/33] rust: remove `RUSTC_HAS_SLICE_AS_FLATTENED` and simplify code Date: Wed, 1 Apr 2026 13:45:11 +0200 Message-ID: <20260401114540.30108-5-ojeda@kernel.org> In-Reply-To: <20260401114540.30108-1-ojeda@kernel.org> References: <20260401114540.30108-1-ojeda@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" With the Rust version bump in place, the `RUSTC_HAS_SLICE_AS_FLATTENED` Kconfig (automatic) option is always true. Thus remove the option and simplify the code. In particular, this includes removing the `slice` module which contained the temporary slice helpers, i.e. the `AsFlattened` extension trait and its `impl`s. Signed-off-by: Miguel Ojeda Reviewed-by: Gary Guo --- init/Kconfig | 3 --- rust/kernel/lib.rs | 1 - rust/kernel/prelude.rs | 3 --- rust/kernel/slice.rs | 49 ------------------------------------------ 4 files changed, 56 deletions(-) delete mode 100644 rust/kernel/slice.rs diff --git a/init/Kconfig b/init/Kconfig index b8a1ab0d49d4..c38f49228157 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -178,9 +178,6 @@ config LD_CAN_USE_KEEP_IN_OVERLAY # https://github.com/llvm/llvm-project/pull/130661 def_bool LD_IS_BFD || LLD_VERSION >=3D 210000 =20 -config RUSTC_HAS_SLICE_AS_FLATTENED - def_bool RUSTC_VERSION >=3D 108000 - config RUSTC_HAS_COERCE_POINTEE def_bool RUSTC_VERSION >=3D 108400 =20 diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs index 138d846f798d..621cae75030c 100644 --- a/rust/kernel/lib.rs +++ b/rust/kernel/lib.rs @@ -140,7 +140,6 @@ pub mod security; pub mod seq_file; pub mod sizes; -pub mod slice; #[cfg(CONFIG_SOC_BUS)] pub mod soc; #[doc(hidden)] diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs index 6a54597fa0a2..1cf051b83394 100644 --- a/rust/kernel/prelude.rs +++ b/rust/kernel/prelude.rs @@ -53,6 +53,3 @@ pub use super::current; =20 pub use super::uaccess::UserPtr; - -#[cfg(not(CONFIG_RUSTC_HAS_SLICE_AS_FLATTENED))] -pub use super::slice::AsFlattened; diff --git a/rust/kernel/slice.rs b/rust/kernel/slice.rs deleted file mode 100644 index ca2cde135061..000000000000 --- a/rust/kernel/slice.rs +++ /dev/null @@ -1,49 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 - -//! Additional (and temporary) slice helpers. - -/// Extension trait providing a portable version of [`as_flattened`] and -/// [`as_flattened_mut`]. -/// -/// In Rust 1.80, the previously unstable `slice::flatten` family of metho= ds -/// have been stabilized and renamed from `flatten` to `as_flattened`. -/// -/// This creates an issue for as long as the MSRV is < 1.80, as the same f= unctionality is provided -/// by different methods depending on the compiler version. -/// -/// This extension trait solves this by abstracting `as_flatten` and calli= ng the correct method -/// depending on the Rust version. -/// -/// This trait can be removed once the MSRV passes 1.80. -/// -/// [`as_flattened`]: https://doc.rust-lang.org/std/primitive.slice.html#m= ethod.as_flattened -/// [`as_flattened_mut`]: https://doc.rust-lang.org/std/primitive.slice.ht= ml#method.as_flattened_mut -#[cfg(not(CONFIG_RUSTC_HAS_SLICE_AS_FLATTENED))] -pub trait AsFlattened { - /// Takes a `&[[T; N]]` and flattens it to a `&[T]`. - /// - /// This is an portable layer on top of [`as_flattened`]; see its docu= mentation for details. - /// - /// [`as_flattened`]: https://doc.rust-lang.org/std/primitive.slice.ht= ml#method.as_flattened - fn as_flattened(&self) -> &[T]; - - /// Takes a `&mut [[T; N]]` and flattens it to a `&mut [T]`. - /// - /// This is an portable layer on top of [`as_flattened_mut`]; see its = documentation for details. - /// - /// [`as_flattened_mut`]: https://doc.rust-lang.org/std/primitive.slic= e.html#method.as_flattened_mut - fn as_flattened_mut(&mut self) -> &mut [T]; -} - -#[cfg(not(CONFIG_RUSTC_HAS_SLICE_AS_FLATTENED))] -impl AsFlattened for [[T; N]] { - #[allow(clippy::incompatible_msrv)] - fn as_flattened(&self) -> &[T] { - self.flatten() - } - - #[allow(clippy::incompatible_msrv)] - fn as_flattened_mut(&mut self) -> &mut [T] { - self.flatten_mut() - } -} --=20 2.53.0