Skip to content

Commit 74c0eea

Browse files
committed
Auto merge of rust-lang#136735 - scottmcm:transmute-nonnull, r=oli-obk
`transmute` should also assume non-null pointers Previously it only did integer-ABI things, but this way it does data pointers too. That gives more information in general to the backend, and allows slightly simplifying one of the helpers in slice iterators.
2 parents 30de706 + 8ea18d8 commit 74c0eea

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/src/slice/iter/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ macro_rules! if_zst {
3030
$zst_body
3131
} else {
3232
// SAFETY: for non-ZSTs, the type invariant ensures it cannot be null
33-
let $end = unsafe { *(&raw const $this.end_or_len).cast::<NonNull<T>>() };
33+
let $end = unsafe { mem::transmute::<*const T, NonNull<T>>($this.end_or_len) };
3434
$other_body
3535
}
3636
}};

0 commit comments

Comments
 (0)