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
This commit is contained in:
Matthias Krüger
2025-09-15 06:03:48 +02:00
committed by GitHub

View File

@@ -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];