Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: remove `RUSTC_HAS_SLICE_AS_FLATTENED` and simplify code

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.

Reviewed-by: Tamir Duberstein <tamird@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260405235309.418950-10-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

-56
-3
init/Kconfig
··· 178 178 # https://github.com/llvm/llvm-project/pull/130661 179 179 def_bool LD_IS_BFD || LLD_VERSION >= 210000 180 180 181 - config RUSTC_HAS_SLICE_AS_FLATTENED 182 - def_bool RUSTC_VERSION >= 108000 183 - 184 181 config RUSTC_HAS_COERCE_POINTEE 185 182 def_bool RUSTC_VERSION >= 108400 186 183
-1
rust/kernel/lib.rs
··· 140 140 pub mod security; 141 141 pub mod seq_file; 142 142 pub mod sizes; 143 - pub mod slice; 144 143 #[cfg(CONFIG_SOC_BUS)] 145 144 pub mod soc; 146 145 #[doc(hidden)]
-3
rust/kernel/prelude.rs
··· 107 107 // `super::std_vendor` is hidden, which makes the macro inline for some reason. 108 108 #[doc(no_inline)] 109 109 pub use super::dbg; 110 - 111 - #[cfg(not(CONFIG_RUSTC_HAS_SLICE_AS_FLATTENED))] 112 - pub use super::slice::AsFlattened;
-49
rust/kernel/slice.rs
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - 3 - //! Additional (and temporary) slice helpers. 4 - 5 - /// Extension trait providing a portable version of [`as_flattened`] and 6 - /// [`as_flattened_mut`]. 7 - /// 8 - /// In Rust 1.80, the previously unstable `slice::flatten` family of methods 9 - /// have been stabilized and renamed from `flatten` to `as_flattened`. 10 - /// 11 - /// This creates an issue for as long as the MSRV is < 1.80, as the same functionality is provided 12 - /// by different methods depending on the compiler version. 13 - /// 14 - /// This extension trait solves this by abstracting `as_flatten` and calling the correct method 15 - /// depending on the Rust version. 16 - /// 17 - /// This trait can be removed once the MSRV passes 1.80. 18 - /// 19 - /// [`as_flattened`]: https://doc.rust-lang.org/std/primitive.slice.html#method.as_flattened 20 - /// [`as_flattened_mut`]: https://doc.rust-lang.org/std/primitive.slice.html#method.as_flattened_mut 21 - #[cfg(not(CONFIG_RUSTC_HAS_SLICE_AS_FLATTENED))] 22 - pub trait AsFlattened<T> { 23 - /// Takes a `&[[T; N]]` and flattens it to a `&[T]`. 24 - /// 25 - /// This is an portable layer on top of [`as_flattened`]; see its documentation for details. 26 - /// 27 - /// [`as_flattened`]: https://doc.rust-lang.org/std/primitive.slice.html#method.as_flattened 28 - fn as_flattened(&self) -> &[T]; 29 - 30 - /// Takes a `&mut [[T; N]]` and flattens it to a `&mut [T]`. 31 - /// 32 - /// This is an portable layer on top of [`as_flattened_mut`]; see its documentation for details. 33 - /// 34 - /// [`as_flattened_mut`]: https://doc.rust-lang.org/std/primitive.slice.html#method.as_flattened_mut 35 - fn as_flattened_mut(&mut self) -> &mut [T]; 36 - } 37 - 38 - #[cfg(not(CONFIG_RUSTC_HAS_SLICE_AS_FLATTENED))] 39 - impl<T, const N: usize> AsFlattened<T> for [[T; N]] { 40 - #[allow(clippy::incompatible_msrv)] 41 - fn as_flattened(&self) -> &[T] { 42 - self.flatten() 43 - } 44 - 45 - #[allow(clippy::incompatible_msrv)] 46 - fn as_flattened_mut(&mut self) -> &mut [T] { 47 - self.flatten_mut() 48 - } 49 - }