Re: [PATCH v7] rust: transmute: Add methods for FromBytes trait

From: Benno Lossin
Date: Wed Jun 18 2025 - 15:29:58 EST


On Mon Jun 16, 2025 at 11:23 PM CEST, Miguel Ojeda wrote:
> On Mon, Jun 16, 2025 at 11:11 PM Christian
> <christiansantoslima21@xxxxxxxxx> wrote:
>>
>> I mean, using something like `use core::mem;` globally since we use a
>> lot of core stuff and so, it would make the code less verbose just
>> importing size_of, align_of and etc.
>
> Do you mean adding some more `core` bits to the `kernel` prelude?
> Yeah, we are always considering which ones to add -- if you want to
> propose particular ones, then it can be discussed of course. Perhaps
> in Zulip?
>
> However, since these are macros, unless we get a proper custom prelude
> feature in the compiler (which we requested a long time ago), we
> probably want to still to refer to everything in full, even if it is
> in the `kernel` prelude.

Yes, the prelude won't have precedence over locally defined items. So if
someone does

mod core {}

your_macro_that_uses_core!(); // <-- will error with `core::mem` not existing



However in this particular case it seems like that the macro
`impl_frombytes` is a local to this file. In that case it might be fine
to rely on imports from the scope.

---
Cheers,
Benno