From 31d03e7356ec86d0640f1a2534ae1d10175f3e93 Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Tue, 16 Jun 2026 10:02:54 -0400 Subject: [PATCH 1/2] Distinguish `repr(C)` ZSTs from others in ABI compatibility rules --- library/core/src/primitive_docs.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index c6fbe52ee887b..7c09359fe496f 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -1841,7 +1841,14 @@ mod prim_ref {} /// call will be valid ABI-wise. The callee receives the result of transmuting the function pointer /// from `fn()` to `fn(i32)`; that transmutation is itself a well-defined operation, it's just /// almost certainly UB to later call that function pointer.) -/// - Any two types with size 0 and alignment 1 are ABI-compatible. +/// - Any two types fulfilling all the following conditions are ABI-compatible; +/// such types are said to have "trivial ABI": +/// - Size 0 +/// - Alignment 1 +/// - Not `repr(C)` +/// - Not a `repr(transparent)` wrapper around a type that fails to satisfy these conditions +/// - A `repr(transparent)` type is ABI-compatible with its unique field that does not have trivial ABI +/// (as defined above). If there is no such field, the type has trivial ABI. /// - A `repr(transparent)` type `T` is ABI-compatible with its unique non-trivial field, i.e., the /// unique field that doesn't have size 0 and alignment 1 (if there is such a field). /// - `i32` is ABI-compatible with `NonZero`, and similar for all other integer types. From 34de188f14dbd6190a8e83c2bd05d904f56ccb3d Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Fri, 19 Jun 2026 14:54:37 -0400 Subject: [PATCH 2/2] Make most arrays non-trivial --- library/core/src/primitive_docs.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index 7c09359fe496f..7946c3bcefdb0 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -1847,6 +1847,7 @@ mod prim_ref {} /// - Alignment 1 /// - Not `repr(C)` /// - Not a `repr(transparent)` wrapper around a type that fails to satisfy these conditions +/// - Not an array whose element type fails to satisfy these conditions /// - A `repr(transparent)` type is ABI-compatible with its unique field that does not have trivial ABI /// (as defined above). If there is no such field, the type has trivial ABI. /// - A `repr(transparent)` type `T` is ABI-compatible with its unique non-trivial field, i.e., the