@@ -3868,6 +3868,18 @@ impl<T> [T] {
38683868 } else {
38693869 let ( left, rest) = self . split_at ( offset) ;
38703870 let ( us_len, ts_len) = rest. align_to_offsets :: < U > ( ) ;
3871+ // Inform Miri that we want to consider the "middle" pointer to be suitably aligned.
3872+ #[ cfg( miri) ]
3873+ {
3874+ extern "Rust" {
3875+ pub fn miri_promise_symbolic_alignment ( ptr : * const ( ) , align : usize ) ;
3876+ }
3877+
3878+ // SAFETY: this call is always safe.
3879+ unsafe {
3880+ miri_promise_symbolic_alignment ( rest. as_ptr ( ) . cast ( ) , mem:: align_of :: < U > ( ) ) ;
3881+ }
3882+ }
38713883 // SAFETY: now `rest` is definitely aligned, so `from_raw_parts` below is okay,
38723884 // since the caller guarantees that we can transmute `T` to `U` safely.
38733885 unsafe {
@@ -3938,6 +3950,21 @@ impl<T> [T] {
39383950 let ( us_len, ts_len) = rest. align_to_offsets :: < U > ( ) ;
39393951 let rest_len = rest. len ( ) ;
39403952 let mut_ptr = rest. as_mut_ptr ( ) ;
3953+ // Inform Miri that we want to consider the "middle" pointer to be suitably aligned.
3954+ #[ cfg( miri) ]
3955+ {
3956+ extern "Rust" {
3957+ pub fn miri_promise_symbolic_alignment ( ptr : * const ( ) , align : usize ) ;
3958+ }
3959+
3960+ // SAFETY: this call is always safe.
3961+ unsafe {
3962+ miri_promise_symbolic_alignment (
3963+ mut_ptr. cast ( ) as * const ( ) ,
3964+ mem:: align_of :: < U > ( ) ,
3965+ ) ;
3966+ }
3967+ }
39413968 // We can't use `rest` again after this, that would invalidate its alias `mut_ptr`!
39423969 // SAFETY: see comments for `align_to`.
39433970 unsafe {
0 commit comments