From 5f9aca7e74ca901cd6e3fad6dbc6a5a14f160ea1 Mon Sep 17 00:00:00 2001 From: RustyYato Date: Fri, 5 Dec 2025 12:24:31 -0700 Subject: [PATCH] Add `#[inline]` to `Layout::is_size_align_valid` add Alignment::new_unchecked::precondition_check to allowlist --- library/core/src/alloc/layout.rs | 1 + tests/codegen-units/item-collection/opaque-return-impls.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/library/core/src/alloc/layout.rs b/library/core/src/alloc/layout.rs index 73d929fbc7f48..a4e25b8734a97 100644 --- a/library/core/src/alloc/layout.rs +++ b/library/core/src/alloc/layout.rs @@ -65,6 +65,7 @@ impl Layout { } } + #[inline] const fn is_size_align_valid(size: usize, align: usize) -> bool { let Some(align) = Alignment::new(align) else { return false }; if size > Self::max_size_for_align(align) { diff --git a/tests/codegen-units/item-collection/opaque-return-impls.rs b/tests/codegen-units/item-collection/opaque-return-impls.rs index 1659b62175b78..d54951b933fdb 100644 --- a/tests/codegen-units/item-collection/opaque-return-impls.rs +++ b/tests/codegen-units/item-collection/opaque-return-impls.rs @@ -47,6 +47,7 @@ pub fn foo2() -> Box { //~ MONO_ITEM fn std::alloc::Global::alloc_impl //~ MONO_ITEM fn std::boxed::Box::::new //~ MONO_ITEM fn std::alloc::Layout::from_size_align_unchecked::precondition_check +//~ MONO_ITEM fn std::ptr::Alignment::new_unchecked::precondition_check //~ MONO_ITEM fn std::ptr::NonNull::::new_unchecked::precondition_check struct Counter {