Re: [PATCH v7 05/10] rust: bitmap: add contiguous area operations
"Alexandre Courbot" <[email protected]>
| Newsgroups | dev.linux.lists.nova-gpu,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel,org.kernel.vger.rust-for-linux |
|---|---|
| Message-ID | <[email protected]> |
On Fri Aug 21, 2026 at 5:31 PM JST, Miguel Ojeda wrote: > On Fri, Aug 21, 2026 at 10:11 AM Alexandre Courbot <[email protected]> wrote: >> >> Mutating methods should definitely keep that check, but for querying >> this looks like a legitimate way to use the API. > > If there is a need to use the API in a certain way (and there is no > other intended/"better" way to do something), then yeah. > > Otherwise, having `debug_assert!`s or similar are more than welcome. I think there are two kinds of operations to distinguish here: - Setting/clearing a bit, which can be thought of as an array access operation. These are accepted to panic in Rust, so it makes sense that the bitmap methods do the same. There is a side-effect expected, if it cannot be performed then something has to report it. - Look for a bit/group of bits that match a certain condition. These operations don't have any side-effect, so IMHO it is fine to say that there are no bits set after `start` if `start >= self.len()`. I'm not super fond of the different behavior introduced by CONFIG_RUST_BITMAP_HARDENED. We don't have a fallback in Rust to silently not set an array element if its index is invalid - we only have panicking and checked variants. Bitmaps should not be different. Fixing this (if that's desired) is beyond this patchset, but maybe we can at least make the `next*` operations avoid that.