Skip to content

Commit

Permalink
Fix MIRI error in inout_buf.rs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nico-abram committed Mar 30, 2022
1 parent 7241c0f commit 022082e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions inout/src/inout_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit 022082e

Please sign in to comment.