Re: [PATCH v4 01/20] rust: io: add dynamically-sized `Region` type
From: Miguel Ojeda
Date: Sat Jun 13 2026 - 06:06:00 EST
On Thu, Jun 11, 2026 at 6:28 PM Gary Guo <gary@xxxxxxxxxxx> wrote:
>
> + /// Create a raw mutable pointer from given base address and size.
> + ///
> + /// The alignment of `base` is checked, and `size` is checked against the minimum size specified
> + /// via const generics.
> + #[inline]
> + pub fn ptr_try_from_raw_parts_mut(base: *mut u8, size: usize) -> Result<*mut Self> {
> + if size < SIZE || base.align_offset(4) != 0 || !size.is_multiple_of(4) {
> + return Err(EINVAL);
> + }
> +
> + Ok(Self::ptr_from_raw_parts_mut(base, size))
> + }
Hmm... I wonder if, at least for the `try_` one, we should have `//
INVARIANT:` on top of the `Ok`, since we at least checked that part.
> +// Stable since Rust 1.87.0.
> +#![feature(unsigned_is_multiple_of)]
It indeed appears available without changes since Rust 1.82.0 <= MSRV.
Acked-by: Miguel Ojeda <ojeda@xxxxxxxxxx>
I think Danilo asked for the Acked-by back in the first version but
you dropped it since the patch changed, so here it is again :)
Thanks!
Cheers,
Miguel