* [PATCH] rust: enable arbitrary_self_types and remove `Receiver`
@ 2024-09-10 12:07 Gary Guo
2024-09-10 12:25 ` Alice Ryhl
0 siblings, 1 reply; 2+ messages in thread
From: Gary Guo @ 2024-09-10 12:07 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Masahiro Yamada, Nathan Chancellor,
Nicolas Schier, Danilo Krummrich, FUJITA Tomonori, Valentin Obst,
Martin Rodriguez Reboredo, Alex Mantel
Cc: Adrian Taylor, rust-for-linux, linux-kernel, linux-kbuild
The `arbitrary_self_types` RFC [1] is accepted and the feature is being
worked on [2]. As part of the RFC, a new `Receiver` trait is to be added,
and it will be automatically implemented for all types that have `Deref`
implementation. This is different from the existing `Receiver` trait
that we use, which is a custom implementation that opts-in a type into
being 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.
Cc: Adrian Taylor <ade@hohum.me.uk>
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 <gary@garyguo.net>
---
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(-)
diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
index f10b06a78b9d5..35a65a085bce5 100644
--- 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;
diff --git a/rust/kernel/list/arc.rs b/rust/kernel/list/arc.rs
index d801b9dc6291d..3483d8c232c4f 100644
--- a/rust/kernel/list/arc.rs
+++ b/rust/kernel/list/arc.rs
@@ -441,9 +441,6 @@ fn as_ref(&self) -> &Arc<T> {
}
}
-// This is to allow [`ListArc`] (and variants) to be used as the type of `self`.
-impl<T, const ID: u64> core::ops::Receiver for ListArc<T, ID> where T: ListArcSafe<ID> + ?Sized {}
-
// This is to allow coercion from `ListArc<T>` to `ListArc<U>` if `T` can be converted to the
// dynamically-sized type (DST) `U`.
impl<T, U, const ID: u64> core::ops::CoerceUnsized<ListArc<U, ID>> for ListArc<T, ID>
diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs
index 3021f30fd822f..28743a7c74a84 100644
--- a/rust/kernel/sync/arc.rs
+++ b/rust/kernel/sync/arc.rs
@@ -171,9 +171,6 @@ unsafe fn container_of(ptr: *const T) -> NonNull<ArcInner<T>> {
}
}
-// This is to allow [`Arc`] (and variants) to be used as the type of `self`.
-impl<T: ?Sized> core::ops::Receiver for Arc<T> {}
-
// This is to allow coercion from `Arc<T>` to `Arc<U>` if `T` can be converted to the
// dynamically-sized type (DST) `U`.
impl<T: ?Sized + Unsize<U>, U: ?Sized> core::ops::CoerceUnsized<Arc<U>> for Arc<T> {}
@@ -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<T: ?Sized> core::ops::Receiver for ArcBorrow<'_, T> {}
-
// This is to allow `ArcBorrow<U>` to be dispatched on when `ArcBorrow<T>` can be coerced into
// `ArcBorrow<U>`.
impl<T: ?Sized + Unsize<U>, U: ?Sized> core::ops::DispatchFromDyn<ArcBorrow<'_, U>>
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 72b1232b1f7d9..56b8c72687255 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -263,7 +263,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
base-commit: 93dc3be19450447a3a7090bd1dfb9f3daac3e8d2
--
2.44.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] rust: enable arbitrary_self_types and remove `Receiver`
2024-09-10 12:07 [PATCH] rust: enable arbitrary_self_types and remove `Receiver` Gary Guo
@ 2024-09-10 12:25 ` Alice Ryhl
0 siblings, 0 replies; 2+ messages in thread
From: Alice Ryhl @ 2024-09-10 12:25 UTC (permalink / raw)
To: Gary Guo
Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Masahiro Yamada, Nathan Chancellor, Nicolas Schier,
Danilo Krummrich, FUJITA Tomonori, Valentin Obst,
Martin Rodriguez Reboredo, Alex Mantel, Adrian Taylor,
rust-for-linux, linux-kernel, linux-kbuild
On Tue, Sep 10, 2024 at 2:09 PM Gary Guo <gary@garyguo.net> wrote:
>
> The `arbitrary_self_types` RFC [1] is accepted and the feature is being
> worked on [2]. As part of the RFC, a new `Receiver` trait is to be added,
> and it will be automatically implemented for all types that have `Deref`
> implementation. This is different from the existing `Receiver` trait
> that we use, which is a custom implementation that opts-in a type into
> being 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.
>
> Cc: Adrian Taylor <ade@hohum.me.uk>
> 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 <gary@garyguo.net>
Please update the commit message to explain the compatibility
situation with various rustc releases.
Alice
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-10 12:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-10 12:07 [PATCH] rust: enable arbitrary_self_types and remove `Receiver` Gary Guo
2024-09-10 12:25 ` Alice Ryhl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®