Skip to content

Commit b1a7983

Browse files
committed
more general approach of hedging against library updates
1 parent ee09160 commit b1a7983

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

library/core/src/primitive_docs.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1545,8 +1545,8 @@ mod prim_ref {}
15451545
/// `NonNull<T>` are all ABI-compatible with each other.
15461546
/// - Any two `fn()` types with the same `extern` ABI string are ABI-compatible with each other.
15471547
/// - Any two 1-ZST types (types with size 0 and alignment 1) are ABI-compatible.
1548-
/// - A `repr(transparent)` type `T` that has no private fields and is not `#[non_exhaustive]` is
1549-
/// ABI-compatible with its unique non-1-ZST field (if there is such a field).
1548+
/// - A `repr(transparent)` type `T` is ABI-compatible with its unique non-1-ZST field (if there is
1549+
/// such a field).
15501550
/// - `i32` is ABI-compatible with `NonZeroI32`, and similar for all other integer types with their
15511551
/// matching `NonZero*` type.
15521552
/// - If `T` is guaranteed to be subject to the [null pointer
@@ -1560,6 +1560,13 @@ mod prim_ref {}
15601560
/// the remaining bits in the register that are not used by the value. `i32` vs `f32` has already
15611561
/// been mentioned above.
15621562
///
1563+
/// Note that these rules describe when two completely known types are ABI-compatible. When
1564+
/// considering ABI compatibility of a type declared in another crate (including the standard
1565+
/// library), consider that any type that has a private field or the `#[non_exhaustive]` attribute
1566+
/// may change its layout as a non-breaking update unless documented otherwise -- so for instance,
1567+
/// even if such a type is a 1-ZST or `repr(transparent)` right now, this might change with any
1568+
/// library version change.
1569+
///
15631570
/// ### Trait implementations
15641571
///
15651572
/// In this documentation the shorthand `fn (T₁, T₂, …, Tₙ)` is used to represent non-variadic

library/std/src/primitive_docs.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1545,8 +1545,8 @@ mod prim_ref {}
15451545
/// `NonNull<T>` are all ABI-compatible with each other.
15461546
/// - Any two `fn()` types with the same `extern` ABI string are ABI-compatible with each other.
15471547
/// - Any two 1-ZST types (types with size 0 and alignment 1) are ABI-compatible.
1548-
/// - A `repr(transparent)` type `T` that has no private fields and is not `#[non_exhaustive]` is
1549-
/// ABI-compatible with its unique non-1-ZST field (if there is such a field).
1548+
/// - A `repr(transparent)` type `T` is ABI-compatible with its unique non-1-ZST field (if there is
1549+
/// such a field).
15501550
/// - `i32` is ABI-compatible with `NonZeroI32`, and similar for all other integer types with their
15511551
/// matching `NonZero*` type.
15521552
/// - If `T` is guaranteed to be subject to the [null pointer
@@ -1560,6 +1560,13 @@ mod prim_ref {}
15601560
/// the remaining bits in the register that are not used by the value. `i32` vs `f32` has already
15611561
/// been mentioned above.
15621562
///
1563+
/// Note that these rules describe when two completely known types are ABI-compatible. When
1564+
/// considering ABI compatibility of a type declared in another crate (including the standard
1565+
/// library), consider that any type that has a private field or the `#[non_exhaustive]` attribute
1566+
/// may change its layout as a non-breaking update unless documented otherwise -- so for instance,
1567+
/// even if such a type is a 1-ZST or `repr(transparent)` right now, this might change with any
1568+
/// library version change.
1569+
///
15631570
/// ### Trait implementations
15641571
///
15651572
/// In this documentation the shorthand `fn (T₁, T₂, …, Tₙ)` is used to represent non-variadic

0 commit comments

Comments
 (0)