[PATCH 1/2] rust: add `ptr_as_ref_unchecked` to `rust_allowed_features`

From: Victor Prokhorov

Date: Wed Apr 08 2026 - 05:30:34 EST


From: Victor Prokhorov <mail@xxxxxxxxxxxxxxxxxxx>

Add `ptr_as_ref_unchecked` to the list of allowed Rust unstable
features. This feature provides `as_ref_unchecked()` and
`as_mut_unchecked()` on raw pointers, which are the named counterparts
to the `&*ptr` and `&mut *ptr` patterns.

The feature has been available since Rust 1.80.0 and was stabilized in
Rust 1.95.0.

Suggested-by: Miguel Ojeda <ojeda@xxxxxxxxxx>
Link: https://github.com/Rust-for-Linux/linux/issues/1225
Signed-off-by: Victor Prokhorov <mail@xxxxxxxxxxxxxxxxxxx>
---
rust/kernel/lib.rs | 3 +++
scripts/Makefile.build | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
index 0fa9d820fe7c..59916eba22e9 100644
--- a/rust/kernel/lib.rs
+++ b/rust/kernel/lib.rs
@@ -16,6 +16,9 @@
// Please see https://github.com/Rust-for-Linux/linux/issues/2 for details on
// the unstable features in use.
//
+// Stable since Rust 1.95.0.
+#![feature(ptr_as_ref_unchecked)]
+//
// Expected to become stable.
#![feature(arbitrary_self_types)]
#![feature(derive_coerce_pointee)]
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 57cff77c2897..6a0862c9174b 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -316,7 +316,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE
#
# Please see https://github.com/Rust-for-Linux/linux/issues/2 for details on
# the unstable features in use.
-rust_allowed_features := arbitrary_self_types,asm_goto,used_with_arg
+rust_allowed_features := arbitrary_self_types,asm_goto,used_with_arg,ptr_as_ref_unchecked

# `--out-dir` is required to avoid temporaries being created by `rustc` in the
# current working directory, which may be not accessible in the out-of-tree
--
2.51.0