File tree Expand file tree Collapse file tree 4 files changed +7
-7
lines changed Expand file tree Collapse file tree 4 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -1043,9 +1043,9 @@ where
1043
1043
1044
1044
impl < T > Drop for MergeHole < T > {
1045
1045
fn drop ( & mut self ) {
1046
- // `T` is not a zero-sized type, so it's okay to divide by its size.
1047
- let len = ( self . end . addr ( ) - self . start . addr ( ) ) / mem:: size_of :: < T > ( ) ;
1046
+ // `T` is not a zero-sized type, and these are pointers into a slice's elements.
1048
1047
unsafe {
1048
+ let len = self . end . offset_from ( self . start ) as usize ;
1049
1049
ptr:: copy_nonoverlapping ( self . start , self . dest , len) ;
1050
1050
}
1051
1051
}
Original file line number Diff line number Diff line change @@ -294,17 +294,17 @@ fn is_ascii(s: &[u8]) -> bool {
294
294
// Paranoia check about alignment, since we're about to do a bunch of
295
295
// unaligned loads. In practice this should be impossible barring a bug in
296
296
// `align_offset` though.
297
- debug_assert_eq ! ( ( word_ptr. addr( ) ) % mem:: align_of:: <usize >( ) , 0 ) ;
297
+ debug_assert_eq ! ( word_ptr. addr( ) % mem:: align_of:: <usize >( ) , 0 ) ;
298
298
299
299
// Read subsequent words until the last aligned word, excluding the last
300
300
// aligned word by itself to be done in tail check later, to ensure that
301
301
// tail is always one `usize` at most to extra branch `byte_pos == len`.
302
302
while byte_pos < len - USIZE_SIZE {
303
303
debug_assert ! (
304
304
// Sanity check that the read is in bounds
305
- ( word_ptr. addr( ) + USIZE_SIZE ) <= ( start. wrapping_add ( len ) . addr ( ) ) &&
305
+ ( word_ptr. addr( ) + USIZE_SIZE ) <= start. addr ( ) . wrapping_add ( len ) &&
306
306
// And that our assumptions about `byte_pos` hold.
307
- ( word_ptr. addr( ) ) - ( start. addr( ) ) == byte_pos
307
+ ( word_ptr. addr( ) - start. addr( ) ) == byte_pos
308
308
) ;
309
309
310
310
// SAFETY: We know `word_ptr` is properly aligned (because of
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ macro_rules! len {
20
20
if size == 0 {
21
21
// This _cannot_ use `unchecked_sub` because we depend on wrapping
22
22
// to represent the length of long ZST slice iterators.
23
- ( $self. end. addr( ) ) . wrapping_sub( start. as_ptr( ) . addr( ) )
23
+ $self. end. addr( ) . wrapping_sub( start. as_ptr( ) . addr( ) )
24
24
} else {
25
25
// We know that `start <= end`, so can do better than `offset_from`,
26
26
// which needs to deal in signed. By setting appropriate flags here
Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ impl Repr {
136
136
let p = Box :: into_raw ( b) . cast :: < u8 > ( ) ;
137
137
// Should only be possible if an allocator handed out a pointer with
138
138
// wrong alignment.
139
- debug_assert_eq ! ( ( p. addr( ) & TAG_MASK ) , 0 ) ;
139
+ debug_assert_eq ! ( p. addr( ) & TAG_MASK , 0 ) ;
140
140
// Note: We know `TAG_CUSTOM <= size_of::<Custom>()` (static_assert at
141
141
// end of file), and both the start and end of the expression must be
142
142
// valid without address space wraparound due to `Box`'s semantics.
You can’t perform that action at this time.
0 commit comments