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) {
15911591///
15921592/// Any questions go to @nagisa.
15931593#[ lang = "align_offset" ]
1594- #[ rustc_do_not_const_check] // hooked by const-eval
15951594pub ( crate ) const unsafe fn align_offset < T : Sized > ( p : * const T , a : usize ) -> usize {
15961595 // FIXME(#75598): Direct use of these intrinsics improves codegen significantly at opt-level <=
15971596 // 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
16511650 inverse & m_minus_one
16521651 }
16531652
1654- let addr = p. addr ( ) ;
16551653 let stride = mem:: size_of :: < T > ( ) ;
16561654
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+
16571660 // SAFETY: `a` is a power-of-two, therefore non-zero.
16581661 let a_minus_one = unsafe { unchecked_sub ( a, 1 ) } ;
16591662
You can’t perform that action at this time.
0 commit comments