Move OS-dependent parts of std::io to alloc#152918
Move OS-dependent parts of std::io to alloc#152918a1phyr wants to merge 3 commits intorust-lang:mainfrom
std::io to alloc#152918Conversation
|
r? @jhpratt rustbot has assigned @jhpratt. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
319bd3c to
0989265
Compare
This comment has been minimized.
This comment has been minimized.
|
I have a idea, that move iovec into struct iovec {
iov_base: *mut c_void,
iov_len: usize,
}for windows/UEFI, use struct iovec {
iov_len: c_ulong,
iov_base: *mut c_void,
}and for RawOsError, it's can also defined in core:ffi as
|
|
It would possible indeed. I think that what we'll do will depend on T-libs team preference. |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
To make rustdoc happy, I had to remove a bunch a links in |
|
@rustbot reroll |
A specific plan should be proposed as an ACP before starting too much work, there are tradeoffs and alternatives that need to be discussed and accepted by the libs-api team. @rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
|
As someone who maintains my own set of no- However, as potentially justifying to the prior call for discussion before moving forward, I'm unclear on the role of OS-specific code in |
This is the first (and the hardest) part of a plan to move most of
std::iotoalloc.This PR has three commits:
alloc::ffiwithno_rcandno_syncbecause they where annoying me.io::Errortoalloc.Errorfrom raw OS errors is restricted tostdvia incoherent impls.allocis set at runtime bystdwhen creatingErrorfrom raw OS errors (so no linking required, and not dependent of how Rust code is started). Can be moved to externally implementable one day.IoSliceandIoSliceMutto alloc (required byReadandWrite, exact layout depend on the OS).alloc, but do not link to anything either.I expect the introduction of OS-dependent code to
allocquite controversial, but please note that this PR does not expose anything OS-dependent toallocusers.Also this PR abuses the fact that
tidydoes not warn oncfg_select!inalloclike it does for#[cfg()]😈The rest of
std::iothat can move should do so easily (obviously not things like stdio,IsTerminal, pipes, etc), except maybe forio::copywhich has OS-dependent specialization. If this get merged, I will make a follup-up PR with all all this. In the meantime, a PR containing only the hard parts will avoid perpetual conflicts and rebases.Some questions
Why not
core?Well this could be tried in the future. The main issue is that
Readdirectly usesVec.Why not new
Read/Writetraits?Why about not having them and make the existing one work for everyone?
Previous discussion (far larger than these few links)
Cc #48331
Prior try to move
Errortocore(notalloc): #116685Prior discussion on this specific plan: https://internals.rust-lang.org/t/a-plan-to-move-most-of-std-io-to-alloc/23678/9
Many
#![no_std]crates reimplementingstd::io:embedded-iocore2and its forksciborium-io.