[PATCH 01/10] rust: xarray: minor formatting fixes

Andreas Hindborg posted 10 patches 2 months ago
There is a newer version of this series
[PATCH 01/10] rust: xarray: minor formatting fixes
Posted by Andreas Hindborg 2 months ago
Fix formatting in xarray module to comply with kernel coding
guidelines:

- Update use clauses to use vertical layout with each import on its
  own line.
- Add trailing empty comments to preserve formatting and prevent
  rustfmt from collapsing imports.
- Break long assert_eq! statement in documentation across multiple
  lines for better readability.

Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
---
 rust/kernel/xarray.rs | 36 +++++++++++++++++++++++++++++-------
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/rust/kernel/xarray.rs b/rust/kernel/xarray.rs
index a49d6db288458..88625c9abf4ef 100644
--- a/rust/kernel/xarray.rs
+++ b/rust/kernel/xarray.rs
@@ -4,14 +4,33 @@
 //!
 //! C header: [`include/linux/xarray.h`](srctree/include/linux/xarray.h)
 
-use crate::{
-    alloc, bindings, build_assert,
-    error::{Error, Result},
+use core::{
+    iter,
+    marker::PhantomData,
+    pin::Pin,
+    ptr::NonNull, //
+};
+use kernel::{
+    alloc,
+    bindings,
+    build_assert, //
+    error::{
+        Error,
+        Result, //
+    },
     ffi::c_void,
-    types::{ForeignOwnable, NotThreadSafe, Opaque},
+    types::{
+        ForeignOwnable,
+        NotThreadSafe,
+        Opaque, //
+    },
+};
+use pin_init::{
+    pin_data,
+    pin_init,
+    pinned_drop,
+    PinInit, //
 };
-use core::{iter, marker::PhantomData, pin::Pin, ptr::NonNull};
-use pin_init::{pin_data, pin_init, pinned_drop, PinInit};
 
 /// An array which efficiently maps sparse integer indices to owned objects.
 ///
@@ -44,7 +63,10 @@
 /// *guard.get_mut(0).unwrap() = 0xffff;
 /// assert_eq!(guard.get(0).copied(), Some(0xffff));
 ///
-/// assert_eq!(guard.store(0, beef, GFP_KERNEL)?.as_deref().copied(), Some(0xffff));
+/// assert_eq!(
+///     guard.store(0, beef, GFP_KERNEL)?.as_deref().copied(),
+///     Some(0xffff)
+/// );
 /// assert_eq!(guard.get(0).copied(), Some(0xbeef));
 ///
 /// guard.remove(0);

-- 
2.51.2
Re: [PATCH 01/10] rust: xarray: minor formatting fixes
Posted by Gary Guo 2 weeks, 2 days ago
On Wed Dec 3, 2025 at 10:26 PM GMT, Andreas Hindborg wrote:
> Fix formatting in xarray module to comply with kernel coding
> guidelines:
> 
> - Update use clauses to use vertical layout with each import on its
>   own line.
> - Add trailing empty comments to preserve formatting and prevent
>   rustfmt from collapsing imports.
> - Break long assert_eq! statement in documentation across multiple
>   lines for better readability.
> 
> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>

Reviewed-by: Gary Guo <gary@garyguo.net>

> ---
>  rust/kernel/xarray.rs | 36 +++++++++++++++++++++++++++++-------
>  1 file changed, 29 insertions(+), 7 deletions(-)
Re: [PATCH 01/10] rust: xarray: minor formatting fixes
Posted by Tamir Duberstein 1 month, 1 week ago
On Wed, Dec 3, 2025 at 5:28 PM Andreas Hindborg <a.hindborg@kernel.org> wrote:
>
> Fix formatting in xarray module to comply with kernel coding
> guidelines:
>
> - Update use clauses to use vertical layout with each import on its
>   own line.
> - Add trailing empty comments to preserve formatting and prevent
>   rustfmt from collapsing imports.
> - Break long assert_eq! statement in documentation across multiple
>   lines for better readability.
>
> Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
> ---
>  rust/kernel/xarray.rs | 36 +++++++++++++++++++++++++++++-------
>  1 file changed, 29 insertions(+), 7 deletions(-)
>
> diff --git a/rust/kernel/xarray.rs b/rust/kernel/xarray.rs
> index a49d6db288458..88625c9abf4ef 100644
> --- a/rust/kernel/xarray.rs
> +++ b/rust/kernel/xarray.rs
> @@ -4,14 +4,33 @@
>  //!
>  //! C header: [`include/linux/xarray.h`](srctree/include/linux/xarray.h)
>
> -use crate::{
> -    alloc, bindings, build_assert,
> -    error::{Error, Result},
> +use core::{
> +    iter,
> +    marker::PhantomData,
> +    pin::Pin,
> +    ptr::NonNull, //
> +};
> +use kernel::{
> +    alloc,
> +    bindings,
> +    build_assert, //
> +    error::{
> +        Error,
> +        Result, //
> +    },
>      ffi::c_void,
> -    types::{ForeignOwnable, NotThreadSafe, Opaque},
> +    types::{
> +        ForeignOwnable,
> +        NotThreadSafe,
> +        Opaque, //
> +    },
> +};
> +use pin_init::{
> +    pin_data,
> +    pin_init,
> +    pinned_drop,
> +    PinInit, //
>  };
> -use core::{iter, marker::PhantomData, pin::Pin, ptr::NonNull};
> -use pin_init::{pin_data, pin_init, pinned_drop, PinInit};
>
>  /// An array which efficiently maps sparse integer indices to owned objects.
>  ///
> @@ -44,7 +63,10 @@
>  /// *guard.get_mut(0).unwrap() = 0xffff;
>  /// assert_eq!(guard.get(0).copied(), Some(0xffff));
>  ///
> -/// assert_eq!(guard.store(0, beef, GFP_KERNEL)?.as_deref().copied(), Some(0xffff));
> +/// assert_eq!(
> +///     guard.store(0, beef, GFP_KERNEL)?.as_deref().copied(),
> +///     Some(0xffff)
> +/// );
>  /// assert_eq!(guard.get(0).copied(), Some(0xbeef));
>  ///
>  /// guard.remove(0);
>
> --
> 2.51.2
>
>

Reviewed-by: Tamir Duberstein <tamird@gmail.com>
Re: [PATCH 01/10] rust: xarray: minor formatting fixes
Posted by Tamir Duberstein 1 month, 1 week ago
On Mon, Dec 29, 2025 at 10:56 AM Tamir Duberstein <tamird@gmail.com> wrote:
>
> On Wed, Dec 3, 2025 at 5:28 PM Andreas Hindborg <a.hindborg@kernel.org> wrote:
> >
> > Fix formatting in xarray module to comply with kernel coding
> > guidelines:
> >
> > - Update use clauses to use vertical layout with each import on its
> >   own line.
> > - Add trailing empty comments to preserve formatting and prevent
> >   rustfmt from collapsing imports.
> > - Break long assert_eq! statement in documentation across multiple
> >   lines for better readability.
> >
> > Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
> > ---
> >  rust/kernel/xarray.rs | 36 +++++++++++++++++++++++++++++-------
> >  1 file changed, 29 insertions(+), 7 deletions(-)
> >
> > diff --git a/rust/kernel/xarray.rs b/rust/kernel/xarray.rs
> > index a49d6db288458..88625c9abf4ef 100644
> > --- a/rust/kernel/xarray.rs
> > +++ b/rust/kernel/xarray.rs
> > @@ -4,14 +4,33 @@
> >  //!
> >  //! C header: [`include/linux/xarray.h`](srctree/include/linux/xarray.h)
> >
> > -use crate::{
> > -    alloc, bindings, build_assert,
> > -    error::{Error, Result},
> > +use core::{
> > +    iter,
> > +    marker::PhantomData,
> > +    pin::Pin,
> > +    ptr::NonNull, //
> > +};
> > +use kernel::{
> > +    alloc,
> > +    bindings,
> > +    build_assert, //
> > +    error::{
> > +        Error,
> > +        Result, //
> > +    },
> >      ffi::c_void,
> > -    types::{ForeignOwnable, NotThreadSafe, Opaque},
> > +    types::{
> > +        ForeignOwnable,
> > +        NotThreadSafe,
> > +        Opaque, //
> > +    },
> > +};
> > +use pin_init::{
> > +    pin_data,
> > +    pin_init,
> > +    pinned_drop,
> > +    PinInit, //
> >  };
> > -use core::{iter, marker::PhantomData, pin::Pin, ptr::NonNull};
> > -use pin_init::{pin_data, pin_init, pinned_drop, PinInit};
> >
> >  /// An array which efficiently maps sparse integer indices to owned objects.
> >  ///
> > @@ -44,7 +63,10 @@
> >  /// *guard.get_mut(0).unwrap() = 0xffff;
> >  /// assert_eq!(guard.get(0).copied(), Some(0xffff));
> >  ///
> > -/// assert_eq!(guard.store(0, beef, GFP_KERNEL)?.as_deref().copied(), Some(0xffff));
> > +/// assert_eq!(
> > +///     guard.store(0, beef, GFP_KERNEL)?.as_deref().copied(),
> > +///     Some(0xffff)
> > +/// );
> >  /// assert_eq!(guard.get(0).copied(), Some(0xbeef));
> >  ///
> >  /// guard.remove(0);
> >
> > --
> > 2.51.2
> >
> >
>
> Reviewed-by: Tamir Duberstein <tamird@gmail.com>

Acked-by: Tamir Duberstein <tamird@gmail.com>