From: Greg Kroah-Hartman Date: Tue, 10 Dec 2024 10:31:52 +0000 (+0100) Subject: 6.12-stable patches X-Git-Tag: v6.6.65~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fa905724f4f9314454edee69c769c81c32204e23;p=thirdparty%2Fkernel%2Fstable-queue.git 6.12-stable patches added patches: rust-enable-arbitrary_self_types-and-remove-receiver.patch --- diff --git a/queue-6.12/rust-enable-arbitrary_self_types-and-remove-receiver.patch b/queue-6.12/rust-enable-arbitrary_self_types-and-remove-receiver.patch new file mode 100644 index 00000000000..f5dbe88ef60 --- /dev/null +++ b/queue-6.12/rust-enable-arbitrary_self_types-and-remove-receiver.patch @@ -0,0 +1,110 @@ +From c95bbb59a9b22f9b838b15d28319185c1c884329 Mon Sep 17 00:00:00 2001 +From: Gary Guo +Date: Sun, 15 Sep 2024 14:26:31 +0100 +Subject: rust: enable arbitrary_self_types and remove `Receiver` + +From: Gary Guo + +commit c95bbb59a9b22f9b838b15d28319185c1c884329 upstream. + +The term "receiver" means that a type can be used as the type of `self`, +and thus enables method call syntax `foo.bar()` instead of +`Foo::bar(foo)`. Stable Rust as of today (1.81) enables a limited +selection of types (primitives and types in std, e.g. `Box` and `Arc`) +to be used as receivers, while custom types cannot. + +We want the kernel `Arc` type to have the same functionality as the Rust +std `Arc`, so we use the `Receiver` trait (gated behind `receiver_trait` +unstable feature) to gain the functionality. + +The `arbitrary_self_types` RFC [1] (tracking issue [2]) is accepted and +it will allow all types that implement a new `Receiver` trait (different +from today's unstable trait) to be used as receivers. This trait will be +automatically implemented for all `Deref` types, which include our `Arc` +type, so we no longer have to opt-in to be used as receiver. To prepare +us for the change, remove the `Receiver` implementation and the +associated feature. To still allow `Arc` and others to be used as method +receivers, turn on `arbitrary_self_types` feature instead. + +This feature gate is introduced in 1.23.0. It used to enable both +`Deref` types and raw pointer types to be used as receivers, but the +latter is now split into a different feature gate in Rust 1.83 nightly. +We do not need receivers on raw pointers so this change would not affect +us and usage of `arbitrary_self_types` feature would work for all Rust +versions that we support (>=1.78). + +Cc: Adrian Taylor +Link: https://github.com/rust-lang/rfcs/pull/3519 [1] +Link: https://github.com/rust-lang/rust/issues/44874 [2] +Signed-off-by: Gary Guo +Reviewed-by: Benno Lossin +Reviewed-by: Alice Ryhl +Link: https://lore.kernel.org/r/20240915132734.1653004-1-gary@garyguo.net +Signed-off-by: Miguel Ojeda +Signed-off-by: Greg Kroah-Hartman +--- + rust/kernel/lib.rs | 2 +- + rust/kernel/list/arc.rs | 3 --- + rust/kernel/sync/arc.rs | 6 ------ + scripts/Makefile.build | 2 +- + 4 files changed, 2 insertions(+), 11 deletions(-) + +--- a/rust/kernel/lib.rs ++++ b/rust/kernel/lib.rs +@@ -12,10 +12,10 @@ + //! do so first instead of bypassing this crate. + + #![no_std] ++#![feature(arbitrary_self_types)] + #![feature(coerce_unsized)] + #![feature(dispatch_from_dyn)] + #![feature(new_uninit)] +-#![feature(receiver_trait)] + #![feature(unsize)] + + // Ensure conditional compilation based on the kernel configuration works; +--- a/rust/kernel/list/arc.rs ++++ b/rust/kernel/list/arc.rs +@@ -441,9 +441,6 @@ where + } + } + +-// This is to allow [`ListArc`] (and variants) to be used as the type of `self`. +-impl core::ops::Receiver for ListArc where T: ListArcSafe + ?Sized {} +- + // This is to allow coercion from `ListArc` to `ListArc` if `T` can be converted to the + // dynamically-sized type (DST) `U`. + impl core::ops::CoerceUnsized> for ListArc +--- a/rust/kernel/sync/arc.rs ++++ b/rust/kernel/sync/arc.rs +@@ -171,9 +171,6 @@ impl ArcInner { + } + } + +-// This is to allow [`Arc`] (and variants) to be used as the type of `self`. +-impl core::ops::Receiver for Arc {} +- + // This is to allow coercion from `Arc` to `Arc` if `T` can be converted to the + // dynamically-sized type (DST) `U`. + impl, U: ?Sized> core::ops::CoerceUnsized> for Arc {} +@@ -480,9 +477,6 @@ pub struct ArcBorrow<'a, T: ?Sized + 'a> + _p: PhantomData<&'a ()>, + } + +-// This is to allow [`ArcBorrow`] (and variants) to be used as the type of `self`. +-impl core::ops::Receiver for ArcBorrow<'_, T> {} +- + // This is to allow `ArcBorrow` to be dispatched on when `ArcBorrow` can be coerced into + // `ArcBorrow`. + impl, U: ?Sized> core::ops::DispatchFromDyn> +--- a/scripts/Makefile.build ++++ b/scripts/Makefile.build +@@ -248,7 +248,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE + # Compile Rust sources (.rs) + # --------------------------------------------------------------------------- + +-rust_allowed_features := new_uninit ++rust_allowed_features := arbitrary_self_types,new_uninit + + # `--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 diff --git a/queue-6.12/series b/queue-6.12/series index cc3dce141e4..01aefa7e915 100644 --- a/queue-6.12/series +++ b/queue-6.12/series @@ -217,3 +217,4 @@ mm-fix-vrealloc-s-kasan-poisoning-logic.patch mm-respect-mmap-hint-address-when-aligning-for-thp.patch scsi-ufs-pltfrm-drop-pm-runtime-reference-count-after-ufshcd_remove.patch memblock-allow-zero-threshold-in-validate_numa_converage.patch +rust-enable-arbitrary_self_types-and-remove-receiver.patch