@@ -1402,6 +1402,27 @@ impl<T: ?Sized> *const T {
14021402 /// };
14031403 /// ```
14041404 ///
1405+ /// Due to this behavior, it is possible that a runtime pointer derived from a compiletime
1406+ /// pointer is aligned, even if the compiletime pointer wasn't aligned.
1407+ ///
1408+ #[ cfg_attr( bootstrap, doc = "```ignore" ) ]
1409+ #[ cfg_attr( not( bootstrap) , doc = "```" ) ]
1410+ /// #![feature(pointer_is_aligned)]
1411+ /// #![feature(const_pointer_is_aligned)]
1412+ ///
1413+ /// // At compiletime, neither `CONST_PTR` nor `CONST_PTR + 1` is aligned.
1414+ /// const CONST_PTR: *const i32 = &42;
1415+ /// const _: () = assert!(!CONST_PTR.cast::<i64>().is_aligned());
1416+ /// const _: () = assert!(!CONST_PTR.wrapping_add(1).cast::<i64>().is_aligned());
1417+ ///
1418+ /// // At runtime, either `runtime_ptr` or `runtime_ptr + 1` is aligned.
1419+ /// let runtime_ptr = CONST_PTR;
1420+ /// assert_ne!(
1421+ /// runtime_ptr.cast::<i64>().is_aligned(),
1422+ /// runtime_ptr.wrapping_add(1).cast::<i64>().is_aligned(),
1423+ /// );
1424+ /// ```
1425+ ///
14051426 /// If a pointer is created from a fixed address, this function behaves the same during
14061427 /// runtime and compiletime.
14071428 ///
@@ -1492,6 +1513,27 @@ impl<T: ?Sized> *const T {
14921513 /// };
14931514 /// ```
14941515 ///
1516+ /// Due to this behavior, it is possible that a runtime pointer derived from a compiletime
1517+ /// pointer is aligned, even if the compiletime pointer wasn't aligned.
1518+ ///
1519+ #[ cfg_attr( bootstrap, doc = "```ignore" ) ]
1520+ #[ cfg_attr( not( bootstrap) , doc = "```" ) ]
1521+ /// #![feature(pointer_is_aligned)]
1522+ /// #![feature(const_pointer_is_aligned)]
1523+ ///
1524+ /// // At compiletime, neither `CONST_PTR` nor `CONST_PTR + 1` is aligned.
1525+ /// const CONST_PTR: *const i32 = &42;
1526+ /// const _: () = assert!(!CONST_PTR.is_aligned_to(8));
1527+ /// const _: () = assert!(!CONST_PTR.wrapping_add(1).is_aligned_to(8));
1528+ ///
1529+ /// // At runtime, either `runtime_ptr` or `runtime_ptr + 1` is aligned.
1530+ /// let runtime_ptr = CONST_PTR;
1531+ /// assert_ne!(
1532+ /// runtime_ptr.is_aligned_to(8),
1533+ /// runtime_ptr.wrapping_add(1).is_aligned_to(8),
1534+ /// );
1535+ /// ```
1536+ ///
14951537 /// If a pointer is created from a fixed address, this function behaves the same during
14961538 /// runtime and compiletime.
14971539 ///
0 commit comments