From 3fea7cc7da6dadd2012af3f42f870e204470e479 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Wed, 18 Oct 2023 09:14:31 -0700 Subject: [PATCH 1/2] Guarantee that `char` has the same size and alignment as `u32` --- library/core/src/primitive_docs.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index 380a21b376bde..9914225367ce6 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -283,7 +283,7 @@ mod prim_never {} /// `char` type. For technical reasons, there is additional, separate /// documentation in [the `std::char` module](char/index.html) as well. /// -/// # Validity +/// # Validity and Layout /// /// A `char` is a '[Unicode scalar value]', which is any '[Unicode code point]' /// other than a [surrogate code point]. This has a fixed numerical definition: @@ -330,6 +330,9 @@ mod prim_never {} /// ("noncharacters"); and some may be given different meanings by different /// users ("private use"). /// +/// `char` is guaranteed to have the same size and alignment as `u32` on all +/// platforms. +/// /// [Unicode code point]: https://www.unicode.org/glossary/#code_point /// [Unicode scalar value]: https://www.unicode.org/glossary/#unicode_scalar_value /// [non-exhaustive match]: ../book/ch06-02-match.html#matches-are-exhaustive From c278bc1f8188a956dd94a1c173c46b70cb0b43a3 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Wed, 25 Oct 2023 08:26:07 -0700 Subject: [PATCH 2/2] Update library/core/src/primitive_docs.rs Co-authored-by: scottmcm --- library/core/src/primitive_docs.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index 9914225367ce6..1adb3807171a4 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -332,6 +332,10 @@ mod prim_never {} /// /// `char` is guaranteed to have the same size and alignment as `u32` on all /// platforms. +/// ``` +/// use std::alloc::Layout; +/// assert_eq!(Layout::new::(), Layout::new::()); +/// ``` /// /// [Unicode code point]: https://www.unicode.org/glossary/#code_point /// [Unicode scalar value]: https://www.unicode.org/glossary/#unicode_scalar_value