On Mon, Apr 8, 2024 at 11:19 AM Miguel Ojeda <miguel.ojeda.sandonis@xxxxxxxxx> wrote: > > On Mon, Apr 8, 2024 at 9:54 AM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote: > > > > From bindgen's point of view, this constant is just an integer literal > > with no type information. So I don't see how we can expect it to > > always be generated as a usize? > > In the case of `PAGE_SIZE`, there is type information (`size_t`), > since it comes from the constant helper: > > const size_t RUST_CONST_HELPER_PAGE_SIZE = PAGE_SIZE; > > For the other one, `PAGE_SHIFT`, there is also type information > (`int`), but bindgen currently picks a type based on the value for > those (but ideally/eventually bindgen should respect it instead). > > So for the former, the allow and the cast are not needed since we are > already handling it explicitly. And for the latter, if we want to have > it as `usize`, we should have the cast but not the allow, because now > it does `u32`, but if it respected the type, it would be `c_int` or > `i32`. So either way we would need the cast. Good point. Will fix this for next version. Alice