about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-09-15 06:03:48 +0200
committerGitHub <noreply@github.com>2025-09-15 06:03:48 +0200
commit32c045ecd1984d065f23b83080ad052d4e45896c (patch)
tree82a52d366156c1455cdf554fd92c8a6c801668d4
parentb82698b50388d35b7c6a0bc0a532444792f14477 (diff)
parent87ae4dbf5cc1e81db845c659583aa489d532ae8c (diff)
downloadrust-32c045ecd1984d065f23b83080ad052d4e45896c.tar.gz
rust-32c045ecd1984d065f23b83080ad052d4e45896c.zip
Rollup merge of #146488 - ferrocene:pvdrz/improve-ptr-coverage, r=Mark-Simulacrum
Improve `core::ptr` coverage

This PR improves the `core::ptr` coverage by adding a new test to `coretests` for the `<*const T>::is_aligned_to` method.

r? libs
-rw-r--r--library/coretests/tests/ptr.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/library/coretests/tests/ptr.rs b/library/coretests/tests/ptr.rs
index f8774833d0a..4d5138d539b 100644
--- a/library/coretests/tests/ptr.rs
+++ b/library/coretests/tests/ptr.rs
@@ -490,6 +490,14 @@ fn is_aligned() {
 }
 
 #[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];
     let ptr1: *mut i32 = &mut a[1];