Skip to content

Commit

Permalink
Rollup merge of rust-lang#63013 - nivkner:ffi-safe-slice, r=sfackler
Browse files Browse the repository at this point in the history
add `repr(transparent)` to `IoSliceMut` where missing

tried using `IoSliceMut` in FFI, got `improper_ctypes` warning.

according to the docs: `IoSliceMut` is  "guaranteed to be ABI compatible with the `iovec` type" so it should be usable in FFI.
`IoSlice` is also `repr(transparent)` for every platform where these types contain `iovec`-like types.
vxworks also has `IoSliceMut` as transparent so its not even consistently one or the other.

no comment about this next to the types or in the PR that introduced the types, so assuming this was just missed.

r? @sfackler
  • Loading branch information
Mark-Simulacrum committed Jul 27, 2019
2 parents 19f69af + d7b2110 commit cc55284
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/libstd/sys/unix/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ impl<'a> IoSlice<'a> {
}
}

#[repr(transparent)]
pub struct IoSliceMut<'a> {
vec: iovec,
_p: PhantomData<&'a mut [u8]>,
Expand Down
1 change: 1 addition & 0 deletions src/libstd/sys/wasi/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ impl<'a> IoSlice<'a> {
}
}

#[repr(transparent)]
pub struct IoSliceMut<'a> {
vec: __wasi_iovec_t,
_p: PhantomData<&'a mut [u8]>,
Expand Down
1 change: 1 addition & 0 deletions src/libstd/sys/windows/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ impl<'a> IoSlice<'a> {
}
}

#[repr(transparent)]
pub struct IoSliceMut<'a> {
vec: c::WSABUF,
_p: PhantomData<&'a mut [u8]>,
Expand Down

0 comments on commit cc55284

Please sign in to comment.