Skip to content

Commit cc55284

Browse files
Rollup merge of rust-lang#63013 - nivkner:ffi-safe-slice, r=sfackler
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
2 parents 19f69af + d7b2110 commit cc55284

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

src/libstd/sys/unix/io.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ impl<'a> IoSlice<'a> {
2929
}
3030
}
3131

32+
#[repr(transparent)]
3233
pub struct IoSliceMut<'a> {
3334
vec: iovec,
3435
_p: PhantomData<&'a mut [u8]>,

src/libstd/sys/wasi/io.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ impl<'a> IoSlice<'a> {
2929
}
3030
}
3131

32+
#[repr(transparent)]
3233
pub struct IoSliceMut<'a> {
3334
vec: __wasi_iovec_t,
3435
_p: PhantomData<&'a mut [u8]>,

src/libstd/sys/windows/io.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ impl<'a> IoSlice<'a> {
2929
}
3030
}
3131

32+
#[repr(transparent)]
3233
pub struct IoSliceMut<'a> {
3334
vec: c::WSABUF,
3435
_p: PhantomData<&'a mut [u8]>,

0 commit comments

Comments
 (0)