From 87ae4dbf5cc1e81db845c659583aa489d532ae8c Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Fri, 12 Sep 2025 14:41:26 -0500 Subject: [PATCH] Improve `core::ptr` coverage --- library/coretests/tests/ptr.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/coretests/tests/ptr.rs b/library/coretests/tests/ptr.rs index f8774833d0a54..4d5138d539b95 100644 --- a/library/coretests/tests/ptr.rs +++ b/library/coretests/tests/ptr.rs @@ -489,6 +489,14 @@ fn is_aligned() { assert_ne!(ptr.is_aligned_to(8), ptr.wrapping_add(1).is_aligned_to(8)); } +#[test] +#[should_panic = "is_aligned_to: align is not a power-of-two"] +fn invalid_is_aligned() { + let data = 42; + let ptr: *const i32 = &data; + assert!(ptr.is_aligned_to(3)); +} + #[test] fn offset_from() { let mut a = [0; 5];