[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 03/10] rust/irq: Add a helper to convert [InterruptSource] to
From: |
Zhao Liu |
Subject: |
Re: [PATCH 03/10] rust/irq: Add a helper to convert [InterruptSource] to [*mut IRQState] |
Date: |
Fri, 7 Feb 2025 15:44:40 +0800 |
On Fri, Feb 07, 2025 at 03:10:53PM +0800, Zhao Liu wrote:
> Date: Fri, 7 Feb 2025 15:10:53 +0800
> From: Zhao Liu <zhao1.liu@intel.com>
> Subject: Re: [PATCH 03/10] rust/irq: Add a helper to convert
> [InterruptSource] to [*mut IRQState]
>
> On Wed, Jan 29, 2025 at 11:51:02AM +0100, Paolo Bonzini wrote:
> > Date: Wed, 29 Jan 2025 11:51:02 +0100
> > From: Paolo Bonzini <pbonzini@redhat.com>
> > Subject: Re: [PATCH 03/10] rust/irq: Add a helper to convert
> > [InterruptSource] to [*mut IRQState]
> >
> > On Sat, Jan 25, 2025 at 1:32 PM Zhao Liu <zhao1.liu@intel.com> wrote:
> > >
> > > This is useful to hanlde InterruptSource slice and pass it to C
> > > bindings.
> > >
> > > Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> >
> > This may be a bad suggestion, after all. clippy complains that you're
> > casting &[*mut IRQState] to mutable (https://rust-lang.github.io/rust-
> > clippy/master/#as_ptr_cast_mut).
> >
> > I can think of two solutions:
> >
> > 1) add #[allow(clippy::as_ptr_cast_mut)] and explain with a comment
> >
> > // Casting to *mut *mut IRQState is valid, because
> > // the source slice `pins` uses interior mutability.
> >
I agree it's the best to use interior mutability.
Just to confirm, I check with `cargo +nightly clippy` but it doesn't
complain about this case. Should I switch to another version of clippy
when I do such check? (currently I'm using v0.1.63 clippy as well, to
match rustc.)
Thanks,
Zhao