Re: [PATCH v5 02/20] rust: io: add missing safety requirement in `IoCapable` methods

From: Gary Guo

Date: Fri Jul 03 2026 - 08:42:43 EST


On Fri Jul 3, 2026 at 3:57 AM BST, Alexandre Courbot wrote:
> 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?

That's correct.

Best,
Gary