Skip to content

Commit 70f0c91

Browse files
authored
Rollup merge of #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 d213e2f + d7b2110 commit 70f0c91

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

src/libstd/sys/unix/io.rs

+1
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

+1
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

+1
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)