[PATCH] rust: prelude: re-export `core::mem::{align,size}_of{,_val}`

Miguel Ojeda posted 1 patch 2 months ago
rust/kernel/prelude.rs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
[PATCH] rust: prelude: re-export `core::mem::{align,size}_of{,_val}`
Posted by Miguel Ojeda 2 months ago
Rust 1.80.0 added:

    align_of
    align_of_val
    size_of
    size_of_val

from `core::mem` to the prelude [1].

For similar reasons, and to minimize potential confusion when code may
work in later versions but not in our current minimum, add it to our
prelude too.

Link: https://github.com/rust-lang/rust/pull/123168 [1]
Link: https://lore.kernel.org/rust-for-linux/CANiq72kOLYR2A95o0ji2mDmEqOKh9e9_60zZKmgF=vZmsW6DRg@mail.gmail.com/ [2]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
 rust/kernel/prelude.rs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs
index 25fe97aafd02..198d09a31449 100644
--- a/rust/kernel/prelude.rs
+++ b/rust/kernel/prelude.rs
@@ -12,7 +12,10 @@
 //! ```
 
 #[doc(no_inline)]
-pub use core::pin::Pin;
+pub use core::{
+    mem::{align_of, align_of_val, size_of, size_of_val},
+    pin::Pin,
+};
 
 pub use ::ffi::{
     c_char, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint, c_ulong, c_ulonglong,

base-commit: dff64b072708ffef23c117fa1ee1ea59eb417807
-- 
2.50.1
Re: [PATCH] rust: prelude: re-export `core::mem::{align,size}_of{,_val}`
Posted by Alice Ryhl 2 months ago
On Fri, Aug 1, 2025 at 6:18 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Rust 1.80.0 added:
>
>     align_of
>     align_of_val
>     size_of
>     size_of_val
>
> from `core::mem` to the prelude [1].
>
> For similar reasons, and to minimize potential confusion when code may
> work in later versions but not in our current minimum, add it to our
> prelude too.
>
> Link: https://github.com/rust-lang/rust/pull/123168 [1]
> Link: https://lore.kernel.org/rust-for-linux/CANiq72kOLYR2A95o0ji2mDmEqOKh9e9_60zZKmgF=vZmsW6DRg@mail.gmail.com/ [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
>  rust/kernel/prelude.rs | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs
> index 25fe97aafd02..198d09a31449 100644
> --- a/rust/kernel/prelude.rs
> +++ b/rust/kernel/prelude.rs
> @@ -12,7 +12,10 @@
>  //! ```
>
>  #[doc(no_inline)]
> -pub use core::pin::Pin;
> +pub use core::{
> +    mem::{align_of, align_of_val, size_of, size_of_val},
> +    pin::Pin,
> +};
>
>  pub use ::ffi::{
>      c_char, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint, c_ulong, c_ulonglong,
>
> base-commit: dff64b072708ffef23c117fa1ee1ea59eb417807
> --
> 2.50.1
>

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Re: [PATCH] rust: prelude: re-export `core::mem::{align,size}_of{,_val}`
Posted by Daniel Almeida 2 months ago

> On 1 Aug 2025, at 13:17, Miguel Ojeda <ojeda@kernel.org> wrote:
> 
> Rust 1.80.0 added:
> 
>    align_of
>    align_of_val
>    size_of
>    size_of_val
> 
> from `core::mem` to the prelude [1].
> 
> For similar reasons, and to minimize potential confusion when code may
> work in later versions but not in our current minimum, add it to our
> prelude too.
> 
> Link: https://github.com/rust-lang/rust/pull/123168 [1]
> Link: https://lore.kernel.org/rust-for-linux/CANiq72kOLYR2A95o0ji2mDmEqOKh9e9_60zZKmgF=vZmsW6DRg@mail.gmail.com/ [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> rust/kernel/prelude.rs | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs
> index 25fe97aafd02..198d09a31449 100644
> --- a/rust/kernel/prelude.rs
> +++ b/rust/kernel/prelude.rs
> @@ -12,7 +12,10 @@
> //! ```
> 
> #[doc(no_inline)]
> -pub use core::pin::Pin;
> +pub use core::{
> +    mem::{align_of, align_of_val, size_of, size_of_val},
> +    pin::Pin,
> +};
> 
> pub use ::ffi::{
>     c_char, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint, c_ulong, c_ulonglong,
> 
> base-commit: dff64b072708ffef23c117fa1ee1ea59eb417807
> -- 
> 2.50.1
> 
> 

Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Re: [PATCH] rust: prelude: re-export `core::mem::{align,size}_of{,_val}`
Posted by Benno Lossin 2 months ago
On Fri Aug 1, 2025 at 6:17 PM CEST, Miguel Ojeda wrote:
> Rust 1.80.0 added:
>
>     align_of
>     align_of_val
>     size_of
>     size_of_val
>
> from `core::mem` to the prelude [1].
>
> For similar reasons, and to minimize potential confusion when code may
> work in later versions but not in our current minimum, add it to our
> prelude too.
>
> Link: https://github.com/rust-lang/rust/pull/123168 [1]
> Link: https://lore.kernel.org/rust-for-linux/CANiq72kOLYR2A95o0ji2mDmEqOKh9e9_60zZKmgF=vZmsW6DRg@mail.gmail.com/ [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Reviewed-by: Benno Lossin <lossin@kernel.org>

---
Cheers,
Benno

> ---
>  rust/kernel/prelude.rs | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
Re: [PATCH] rust: prelude: re-export `core::mem::{align,size}_of{,_val}`
Posted by Alexandre Courbot 2 months ago
On Sat Aug 2, 2025 at 1:17 AM JST, Miguel Ojeda wrote:
> Rust 1.80.0 added:
>
>     align_of
>     align_of_val
>     size_of
>     size_of_val
>
> from `core::mem` to the prelude [1].
>
> For similar reasons, and to minimize potential confusion when code may
> work in later versions but not in our current minimum, add it to our
> prelude too.
>
> Link: https://github.com/rust-lang/rust/pull/123168 [1]
> Link: https://lore.kernel.org/rust-for-linux/CANiq72kOLYR2A95o0ji2mDmEqOKh9e9_60zZKmgF=vZmsW6DRg@mail.gmail.com/ [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Nice to have these more readily accessible!

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Re: [PATCH] rust: prelude: re-export `core::mem::{align,size}_of{,_val}`
Posted by Andreas Hindborg 2 months ago
"Miguel Ojeda" <ojeda@kernel.org> writes:

> Rust 1.80.0 added:
>
>     align_of
>     align_of_val
>     size_of
>     size_of_val
>
> from `core::mem` to the prelude [1].
>
> For similar reasons, and to minimize potential confusion when code may
> work in later versions but not in our current minimum, add it to our
> prelude too.
>
> Link: https://github.com/rust-lang/rust/pull/123168 [1]
> Link: https://lore.kernel.org/rust-for-linux/CANiq72kOLYR2A95o0ji2mDmEqOKh9e9_60zZKmgF=vZmsW6DRg@mail.gmail.com/ [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>


Best regards,
Andreas Hindborg
Re: [PATCH] rust: prelude: re-export `core::mem::{align,size}_of{,_val}`
Posted by Miguel Ojeda 3 weeks, 6 days ago
On Fri, Aug 1, 2025 at 6:18 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Rust 1.80.0 added:
>
>     align_of
>     align_of_val
>     size_of
>     size_of_val
>
> from `core::mem` to the prelude [1].
>
> For similar reasons, and to minimize potential confusion when code may
> work in later versions but not in our current minimum, add it to our
> prelude too.
>
> Link: https://github.com/rust-lang/rust/pull/123168 [1]
> Link: https://lore.kernel.org/rust-for-linux/CANiq72kOLYR2A95o0ji2mDmEqOKh9e9_60zZKmgF=vZmsW6DRg@mail.gmail.com/ [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

Applied to `rust-next` -- thanks everyone!

Cheers,
Miguel