Move OS-dependent parts of std::io to alloc#152918
Move OS-dependent parts of std::io to alloc#152918a1phyr wants to merge 4 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 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.
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 |
This comment has been minimized.
This comment has been minimized.
|
Can this get a perf run please? |
can you split out all the removal of links and stuff into a separate commit? that way it's easy to see what was removed and makes it much easier ro add them all back later since you can start by reverting just that commit. |
|
Yes I can do that. I'm probably the one who will do the revert in the next PR anyway :) |
This comment has been minimized.
This comment has been minimized.
…r=Mark-Simulacrum Move `std::io::ErrorKind` to `core::io` ACP: rust-lang/libs-team#755 Tracking issue: rust-lang#154046 Related: rust-lang#152918 ## Description I consider rust-lang#154046 to be really important for `no_std`, but I'm concerned rust-lang#152918 might be too controversial. As an alternative, I'd like to propose starting small with `ErrorKind`, since it can be moved somewhat trivially. It has no dependencies on functionality in `std`, no platform specific behaviour, and could provide an excellent bridging point for `no_std` IO libraries. Since `std::io::Error` implements `From<ErrorKind>`, libraries could write functions which return `Result<T, core::io::ErrorKind>`, and therefore be usable in `std`-using libraries with the `?` operator. For that reason, I'd consider this to be a worthwhile change even if the rest of `std::io` couldn't be moved to `core`/`alloc`, and entirely compatible with any efforts to make such a change in the future. ## Notes * This is my first PR against Rust, please let me know if there's anything I should be doing that I have not done. I tried reading through the library contributors guide but I'm sure I've missed _something_. * No AI tooling of any kind was used in the creation of this PR. * I believe it's appropriate that this be a part of the linked tracking issue, but please let me know if that's not the case!
…r=Mark-Simulacrum Move `std::io::ErrorKind` to `core::io` ACP: rust-lang/libs-team#755 Tracking issue: rust-lang#154046 Related: rust-lang#152918 ## Description I consider rust-lang#154046 to be really important for `no_std`, but I'm concerned rust-lang#152918 might be too controversial. As an alternative, I'd like to propose starting small with `ErrorKind`, since it can be moved somewhat trivially. It has no dependencies on functionality in `std`, no platform specific behaviour, and could provide an excellent bridging point for `no_std` IO libraries. Since `std::io::Error` implements `From<ErrorKind>`, libraries could write functions which return `Result<T, core::io::ErrorKind>`, and therefore be usable in `std`-using libraries with the `?` operator. For that reason, I'd consider this to be a worthwhile change even if the rest of `std::io` couldn't be moved to `core`/`alloc`, and entirely compatible with any efforts to make such a change in the future. ## Notes * This is my first PR against Rust, please let me know if there's anything I should be doing that I have not done. I tried reading through the library contributors guide but I'm sure I've missed _something_. * No AI tooling of any kind was used in the creation of this PR. * I believe it's appropriate that this be a part of the linked tracking issue, but please let me know if that's not the case!
…r=Mark-Simulacrum Move `std::io::ErrorKind` to `core::io` ACP: rust-lang/libs-team#755 Tracking issue: rust-lang#154046 Related: rust-lang#152918 ## Description I consider rust-lang#154046 to be really important for `no_std`, but I'm concerned rust-lang#152918 might be too controversial. As an alternative, I'd like to propose starting small with `ErrorKind`, since it can be moved somewhat trivially. It has no dependencies on functionality in `std`, no platform specific behaviour, and could provide an excellent bridging point for `no_std` IO libraries. Since `std::io::Error` implements `From<ErrorKind>`, libraries could write functions which return `Result<T, core::io::ErrorKind>`, and therefore be usable in `std`-using libraries with the `?` operator. For that reason, I'd consider this to be a worthwhile change even if the rest of `std::io` couldn't be moved to `core`/`alloc`, and entirely compatible with any efforts to make such a change in the future. ## Notes * This is my first PR against Rust, please let me know if there's anything I should be doing that I have not done. I tried reading through the library contributors guide but I'm sure I've missed _something_. * No AI tooling of any kind was used in the creation of this PR. * I believe it's appropriate that this be a part of the linked tracking issue, but please let me know if that's not the case!
Rollup merge of #154654 - bushrat011899:core_io_error_kind, r=Mark-Simulacrum Move `std::io::ErrorKind` to `core::io` ACP: rust-lang/libs-team#755 Tracking issue: #154046 Related: #152918 ## Description I consider #154046 to be really important for `no_std`, but I'm concerned #152918 might be too controversial. As an alternative, I'd like to propose starting small with `ErrorKind`, since it can be moved somewhat trivially. It has no dependencies on functionality in `std`, no platform specific behaviour, and could provide an excellent bridging point for `no_std` IO libraries. Since `std::io::Error` implements `From<ErrorKind>`, libraries could write functions which return `Result<T, core::io::ErrorKind>`, and therefore be usable in `std`-using libraries with the `?` operator. For that reason, I'd consider this to be a worthwhile change even if the rest of `std::io` couldn't be moved to `core`/`alloc`, and entirely compatible with any efforts to make such a change in the future. ## Notes * This is my first PR against Rust, please let me know if there's anything I should be doing that I have not done. I tried reading through the library contributors guide but I'm sure I've missed _something_. * No AI tooling of any kind was used in the creation of this PR. * I believe it's appropriate that this be a part of the linked tracking issue, but please let me know if that's not the case!
This comment has been minimized.
This comment has been minimized.
This is a separated commit to be easy to reverse later.
|
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. |
Up on this! Also friendly ping @jhpratt, when do you think that you will have time to review this? |
|
I can take a look later, but note that I did reassign reviewers a bit ago :) For perf, I'll start a run if I don't see anything obvious. |
View all comments
ACP: rust-lang/libs-team#755
Tracking issue: #154046
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.