Commit a68a6bef authored by Andreas Hindborg's avatar Andreas Hindborg Committed by Miguel Ojeda
Browse files

rust: types: require `ForeignOwnable::into_foreign` return non-null



The intended implementations of `ForeignOwnable` will not return null
pointers from `into_foreign`, as this would render the implementation of
`try_from_foreign` useless. Current users of `ForeignOwnable` rely on
`into_foreign` returning non-null pointers. So require `into_foreign` to
return non-null pointers.

Suggested-by: default avatarBenno Lossin <lossin@kernel.org>
Suggested-by: default avatarAlice Ryhl <aliceryhl@google.com>
Signed-off-by: default avatarAndreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: default avatarBenno Lossin <lossin@kernel.org>
Reviewed-by: default avatarAlice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20250612-pointed-to-v3-2-b009006d86a1@kernel.org


Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
parent 12717ebe
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ pub unsafe trait ForeignOwnable: Sized {
    /// # Guarantees
    ///
    /// - Minimum alignment of returned pointer is [`Self::FOREIGN_ALIGN`].
    /// - The returned pointer is not null.
    ///
    /// [`from_foreign`]: Self::from_foreign
    /// [`try_from_foreign`]: Self::try_from_foreign