Skip to content

Commit 9853d04

Browse files
committed
guarantee that char and u32 are ABI-compatible
1 parent 96aed5c commit 9853d04

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

core/src/primitive_docs.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ mod prim_never {}
330330
/// the future ("reserved"); some will never be a character ("noncharacters"); and some may be given
331331
/// different meanings by different users ("private use").
332332
///
333-
/// `char` is guaranteed to have the same size and alignment as `u32` on all
333+
/// `char` is guaranteed to have the same size, alignment, and function call ABI as `u32` on all
334334
/// platforms.
335335
/// ```
336336
/// use std::alloc::Layout;
@@ -1557,6 +1557,7 @@ mod prim_ref {}
15571557
/// Pointee>::Metadata`).
15581558
/// - `usize` is ABI-compatible with the `uN` integer type of the same size, and likewise `isize` is
15591559
/// ABI-compatible with the `iN` integer type of the same size.
1560+
/// - `char` is ABI-compatible with `u32`.
15601561
/// - Any two `fn` (function pointer) types are ABI-compatible with each other if they have the same
15611562
/// ABI string or the ABI string only differs in a trailing `-unwind`, independent of the rest of
15621563
/// their signature. (This means you can pass `fn()` to a function expecting `fn(i32)`, and the
@@ -1585,9 +1586,9 @@ mod prim_ref {}
15851586
/// since it is not portable and not a stable guarantee.
15861587
///
15871588
/// Noteworthy cases of types *not* being ABI-compatible in general are:
1588-
/// * `bool` vs `u8`, and `i32` vs `u32`: on some targets, the calling conventions for these types
1589-
/// differ in terms of what they guarantee for the remaining bits in the register that are not
1590-
/// used by the value.
1589+
/// * `bool` vs `u8`, `i32` vs `u32`, `char` vs `i32`: on some targets, the calling conventions for
1590+
/// these types differ in terms of what they guarantee for the remaining bits in the register that
1591+
/// are not used by the value.
15911592
/// * `i32` vs `f32` are not compatible either, as has already been mentioned above.
15921593
/// * `struct Foo(u32)` and `u32` are not compatible (without `repr(transparent)`) since structs are
15931594
/// aggregate types and often passed in a different way than primitives like `i32`.

0 commit comments

Comments
 (0)