Skip to content

Commit

Permalink
transmute should also assume non-null pointers
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
scottmcm authored and gitbot committed Mar 6, 2025
1 parent e6ca050 commit 59bd3f1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/slice/iter/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ macro_rules! if_zst {
$zst_body
} else {
// SAFETY: for non-ZSTs, the type invariant ensures it cannot be null
let $end = unsafe { *(&raw const $this.end_or_len).cast::<NonNull<T>>() };
let $end = unsafe { mem::transmute::<*const T, NonNull<T>>($this.end_or_len) };
$other_body
}
}};
Expand Down

0 comments on commit 59bd3f1

Please sign in to comment.