From 022082ed364e927427c75dfb3ecd29a163eae602 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Mar 2022 00:23:40 -0300 Subject: [PATCH] Fix MIRI error in inout_buf.rs See https://github.com/rust-lang/unsafe-code-guidelines/issues/133 Calling as_mut_ptr creates a unique reference, and as_ptr a shared reference. These 2 conflict, and one invalidates the other. Both ptr need to be reborrows of or be basically the same pointer. --- inout/src/inout_buf.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inout/src/inout_buf.rs b/inout/src/inout_buf.rs index 0ab1b8dc..398fe793 100644 --- a/inout/src/inout_buf.rs +++ b/inout/src/inout_buf.rs @@ -18,9 +18,10 @@ pub struct InOutBuf<'inp, 'out, T> { impl<'a, T> From<&'a mut [T]> for InOutBuf<'a, 'a, T> { #[inline(always)] fn from(buf: &'a mut [T]) -> Self { + let out_ptr = buf.as_mut_ptr(); Self { - in_ptr: buf.as_ptr(), - out_ptr: buf.as_mut_ptr(), + in_ptr: out_ptr, + out_ptr: out_ptr, len: buf.len(), _pd: PhantomData, }