Re: [PATCH v5 02/20] rust: io: add missing safety requirement in `IoCapable` methods
From: Alexandre Courbot
Date: Thu Jul 02 2026 - 22:58:46 EST
On Fri Jun 26, 2026 at 11:45 PM JST, Gary Guo wrote:
<...>
> @@ -309,7 +312,11 @@ pub trait Io {
> // Always inline to optimize out error path of `build_assert`.
> #[inline(always)]
> fn io_addr_assert<U>(&self, offset: usize) -> usize {
> - build_assert!(offset_valid::<U>(offset, Self::Target::MIN_SIZE));
> + // We cannot check alignment with `offset_valid` using `self.addr()`. So set 0 for it and
> + // ensure alignment by checking that the alignment of `U` is smaller or equal to the
> + // alignment of `Self::Target`.
> + const_assert!(Alignment::of::<U>().as_usize() <= Self::Target::MIN_ALIGN.as_usize());
With `Region::MIN_ALIGN` being `4`, my understanding is that this will
make `read64` and other infallible 64-bit accessors unusable on untyped
I/O regions?