Skip to content

Commit 022082e

Browse files
committed
Fix MIRI error in inout_buf.rs
See rust-lang/unsafe-code-guidelines#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.
1 parent 7241c0f commit 022082e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

inout/src/inout_buf.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ pub struct InOutBuf<'inp, 'out, T> {
1818
impl<'a, T> From<&'a mut [T]> for InOutBuf<'a, 'a, T> {
1919
#[inline(always)]
2020
fn from(buf: &'a mut [T]) -> Self {
21+
let out_ptr = buf.as_mut_ptr();
2122
Self {
22-
in_ptr: buf.as_ptr(),
23-
out_ptr: buf.as_mut_ptr(),
23+
in_ptr: out_ptr,
24+
out_ptr: out_ptr,
2425
len: buf.len(),
2526
_pd: PhantomData,
2627
}

0 commit comments

Comments
 (0)