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: clarify the language unstable features in use

We track the details of which Rust features we use at our usual "live
list" [1] (and its sub-lists), but in light of a discussion in the LWN
article [2], it would help to clarify it in the source code.

In particular, we are very close to rely only on stable Rust language-wise
-- essentially only two language features remain (including the `kernel`
crate).

Thus add some details in both the feature list of the `kernel` crate as
well as the list of allowed features.

This does not over every single feature, and there are quite a few
non-language features that we use too. To have the full picture, please
refer to [1].

Link: https://github.com/Rust-for-Linux/linux/issues/2 [1]
Link: https://lwn.net/Articles/1015409/ [2]
Suggested-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20250327211302.286313-1-ojeda@kernel.org
[ Improved comments with suggestions from the list. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

+30 -7
+21 -7
rust/kernel/lib.rs
··· 12 12 //! do so first instead of bypassing this crate. 13 13 14 14 #![no_std] 15 - #![feature(arbitrary_self_types)] 16 - #![cfg_attr(CONFIG_RUSTC_HAS_COERCE_POINTEE, feature(derive_coerce_pointee))] 17 - #![cfg_attr(not(CONFIG_RUSTC_HAS_COERCE_POINTEE), feature(coerce_unsized))] 18 - #![cfg_attr(not(CONFIG_RUSTC_HAS_COERCE_POINTEE), feature(dispatch_from_dyn))] 19 - #![cfg_attr(not(CONFIG_RUSTC_HAS_COERCE_POINTEE), feature(unsize))] 15 + // 16 + // Please see https://github.com/Rust-for-Linux/linux/issues/2 for details on 17 + // the unstable features in use. 18 + // 19 + // Stable since Rust 1.79.0. 20 20 #![feature(inline_const)] 21 + // 22 + // Stable since Rust 1.81.0. 21 23 #![feature(lint_reasons)] 22 - // Stable in Rust 1.82 24 + // 25 + // Stable since Rust 1.82.0. 23 26 #![feature(raw_ref_op)] 24 - // Stable in Rust 1.83 27 + // 28 + // Stable since Rust 1.83.0. 25 29 #![feature(const_maybe_uninit_as_mut_ptr)] 26 30 #![feature(const_mut_refs)] 27 31 #![feature(const_ptr_write)] 28 32 #![feature(const_refs_to_cell)] 33 + // 34 + // Expected to become stable. 35 + #![feature(arbitrary_self_types)] 36 + // 37 + // `feature(derive_coerce_pointee)` is expected to become stable. Before Rust 38 + // 1.84.0, it did not exist, so enable the predecessor features. 39 + #![cfg_attr(CONFIG_RUSTC_HAS_COERCE_POINTEE, feature(derive_coerce_pointee))] 40 + #![cfg_attr(not(CONFIG_RUSTC_HAS_COERCE_POINTEE), feature(coerce_unsized))] 41 + #![cfg_attr(not(CONFIG_RUSTC_HAS_COERCE_POINTEE), feature(dispatch_from_dyn))] 42 + #![cfg_attr(not(CONFIG_RUSTC_HAS_COERCE_POINTEE), feature(unsize))] 29 43 30 44 // Ensure conditional compilation based on the kernel configuration works; 31 45 // otherwise we may silently break things like initcall handling.
+9
scripts/Makefile.build
··· 222 222 # Compile Rust sources (.rs) 223 223 # --------------------------------------------------------------------------- 224 224 225 + # The features in this list are the ones allowed for non-`rust/` code. 226 + # 227 + # - Stable since Rust 1.81.0: `feature(lint_reasons)`. 228 + # - Stable since Rust 1.82.0: `feature(asm_const)`, `feature(raw_ref_op)`. 229 + # - Stable since Rust 1.87.0: `feature(asm_goto)`. 230 + # - Expected to become stable: `feature(arbitrary_self_types)`. 231 + # 232 + # Please see https://github.com/Rust-for-Linux/linux/issues/2 for details on 233 + # the unstable features in use. 225 234 rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,raw_ref_op 226 235 227 236 # `--out-dir` is required to avoid temporaries being created by `rustc` in the