From 25b81024a50647cc364cc1a7ab6aa000fef4b915 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Thu, 7 Sep 2023 12:54:34 -0700 Subject: [PATCH 1/2] Guarantee that Layout::align returns a non-zero power of two --- library/core/src/alloc/layout.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/core/src/alloc/layout.rs b/library/core/src/alloc/layout.rs index 597303037345e..dcfb42759f367 100644 --- a/library/core/src/alloc/layout.rs +++ b/library/core/src/alloc/layout.rs @@ -130,6 +130,8 @@ impl Layout { } /// The minimum byte alignment for a memory block of this layout. + /// + /// The returned alignment is guaranteed to be a non-zero power of two. #[stable(feature = "alloc_layout", since = "1.28.0")] #[rustc_const_stable(feature = "const_alloc_layout_size_align", since = "1.50.0")] #[must_use = "this returns the minimum alignment, \ From a9b0966aa5593cf3419aae255b7ca8a85509e33e Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Thu, 12 Oct 2023 16:03:45 -0700 Subject: [PATCH 2/2] Update library/core/src/alloc/layout.rs Co-authored-by: David Tolnay --- library/core/src/alloc/layout.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/alloc/layout.rs b/library/core/src/alloc/layout.rs index dcfb42759f367..65946e09ff9ba 100644 --- a/library/core/src/alloc/layout.rs +++ b/library/core/src/alloc/layout.rs @@ -131,7 +131,7 @@ impl Layout { /// The minimum byte alignment for a memory block of this layout. /// - /// The returned alignment is guaranteed to be a non-zero power of two. + /// The returned alignment is guaranteed to be a power of two. #[stable(feature = "alloc_layout", since = "1.28.0")] #[rustc_const_stable(feature = "const_alloc_layout_size_align", since = "1.50.0")] #[must_use = "this returns the minimum alignment, \