]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rust: enable `raw_ref_op` feature
authorAntonio Hickey <contact@antoniohickey.com>
Thu, 20 Mar 2025 02:07:20 +0000 (22:07 -0400)
committerMiguel Ojeda <ojeda@kernel.org>
Sun, 23 Mar 2025 18:56:45 +0000 (19:56 +0100)
Since Rust 1.82.0 the `raw_ref_op` feature is stable [1].

By enabling this feature we can use `&raw const place` and
`&raw mut place` instead of using `addr_of!(place)` and
`addr_of_mut!(place)` macros.

Allowing us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are
similar to `&`, `&mut` making it fit more naturally with other
existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Link: https://blog.rust-lang.org/2024/10/17/Rust-1.82.0.html#native-syntax-for-creating-a-raw-pointer
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Tamir Duberstein <tamird@gmail.com>
Link: https://lore.kernel.org/r/20250320020740.1631171-2-contact@antoniohickey.com
[ Removed dashed line change as discussed. Added Link to the explanation
  of the feature in the Rust 1.82.0 release blog post. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/lib.rs
scripts/Makefile.build

index 001374a96d663a39dd8f9beeee27381b6c69c469..ba0f3b0297b27dbda6a7b5d9ef8fdb8b7e6463dc 100644 (file)
@@ -19,6 +19,8 @@
 #![cfg_attr(not(CONFIG_RUSTC_HAS_COERCE_POINTEE), feature(unsize))]
 #![feature(inline_const)]
 #![feature(lint_reasons)]
+// Stable in Rust 1.82
+#![feature(raw_ref_op)]
 // Stable in Rust 1.83
 #![feature(const_maybe_uninit_as_mut_ptr)]
 #![feature(const_mut_refs)]
index 08b6380933f5aac8c6483900a440774fb387f9ab..56be83024851326a4ee56d6f0e04d353a37715ae 100644 (file)
@@ -226,7 +226,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE
 # Compile Rust sources (.rs)
 # ---------------------------------------------------------------------------
 
-rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons
+rust_allowed_features := asm_const,asm_goto,arbitrary_self_types,lint_reasons,raw_ref_op
 
 # `--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