File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -1591,7 +1591,6 @@ pub unsafe fn write_volatile<T>(dst: *mut T, src: T) {
1591
1591
///
1592
1592
/// Any questions go to @nagisa.
1593
1593
#[ lang = "align_offset" ]
1594
- #[ rustc_do_not_const_check] // hooked by const-eval
1595
1594
pub ( crate ) const unsafe fn align_offset < T : Sized > ( p : * const T , a : usize ) -> usize {
1596
1595
// FIXME(#75598): Direct use of these intrinsics improves codegen significantly at opt-level <=
1597
1596
// 1, where the method versions of these operations are not inlined.
@@ -1651,9 +1650,13 @@ pub(crate) const unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usiz
1651
1650
inverse & m_minus_one
1652
1651
}
1653
1652
1654
- let addr = p. addr ( ) ;
1655
1653
let stride = mem:: size_of :: < T > ( ) ;
1656
1654
1655
+ // SAFETY: At runtime, transmuting a pointer to `usize` is always safe, because they have the
1656
+ // same layout. During const eval, we hook this function to ensure that the pointer always has
1657
+ // an address (only the standard library can do this).
1658
+ let addr: usize = unsafe { mem:: transmute ( p) } ;
1659
+
1657
1660
// SAFETY: `a` is a power-of-two, therefore non-zero.
1658
1661
let a_minus_one = unsafe { unchecked_sub ( a, 1 ) } ;
1659
1662
You can’t perform that action at this time.
0 commit comments