Skip to content

Commit 7babfc5

Browse files
wmstacktheemathas
andcommitted
Remove unneeded transmute
Co-authored-by: Tim (Theemathas) Chirananthavat <[email protected]>
1 parent f9afc04 commit 7babfc5

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

library/core/src/slice/iter/macros.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -482,16 +482,13 @@ macro_rules! iterator {
482482
return func(None);
483483
}
484484
} else {
485-
// SAFETY: by type invariant, the `end_or_len` field is always
486-
// non-null for a non-ZST pointee. (This transmute ensures we
487-
// get `!nonnull` metadata on the load of the field.)
488-
if ptr == crate::intrinsics::transmute::<$ptr, NonNull<T>>(end_or_len) {
485+
if ptr.as_ptr() == end_or_len {
489486
return func(None);
490487
}
491488
}
492489
// SAFETY: Now that we know it wasn't empty
493490
// we can give out a reference to it.
494-
let tmp = {ptr}.$into_ref();
491+
let tmp = ptr.$into_ref();
495492
func(Some(&tmp))
496493
}
497494
}

0 commit comments

Comments
 (0)