Re: [PATCH 1/4] rust: types: add `ForeignOwnable::PointedTo`
From: Alice Ryhl
Date: Thu Feb 06 2025 - 07:18:47 EST
On Fri, Jan 31, 2025 at 2:32 PM Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote:
>
> From: Tamir Duberstein <tamird@xxxxxxxxx>
>
> Allow implementors to specify the foreign pointer type; this exposes
> information about the pointed-to type such as its alignment.
>
> This requires the trait to be `unsafe` since it is now possible for
> implementors to break soundness by returning a misaligned pointer.
>
> Encoding the pointer type in the trait (and avoiding pointer casts)
> allows the compiler to check that implementors return the correct
> pointer type. This is preferable to directly encoding the alignment in
> the trait using a constant as the compiler would be unable to check it.
>
> Reviewed-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
> Signed-off-by: Tamir Duberstein <tamird@xxxxxxxxx>
> Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
I would have gone a different route with this API, but I won't block it.
Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>