Skip to content

[WIP]: Move std::io into alloc and core #156527

Draft
bushrat011899 wants to merge 16 commits into
rust-lang:mainfrom
bushrat011899:core_io_test_merge
Draft

[WIP]: Move std::io into alloc and core #156527
bushrat011899 wants to merge 16 commits into
rust-lang:mainfrom
bushrat011899:core_io_test_merge

Conversation

@bushrat011899
Copy link
Copy Markdown
Contributor

@bushrat011899 bushrat011899 commented May 13, 2026

View all comments

ACP: rust-lang/libs-team#755
Tracking issue: #154046
Blocked on: #155625
Blocked on: #155849

Description

Moves as much of std::io into core::io and alloc::io as practically possible. Work In Progress until the prerequisite PRs are merged. Likely has documentation issues that will need to be resolved. Will almost certainly be split into smaller PRs as +/- 5000 LoC is a bit much for a single PR IMO.


Notes

  • No AI tooling of any kind was used during the creation of this PR.

@rustbot rustbot added O-unix Operating system: Unix-like S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 13, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Comment thread library/std/src/io/mod.rs Outdated
Comment thread library/std/src/sys/stdio/unix.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

- Unsafe core must be documented.
- Types from dependencies must be inlined.
- These types are only used within `core` so `pub` must be replaced with `pub(crate)`.
Viewing internals wont be possible from `std` once moved into `core`.
Adjust `Error` documentation

`core` is more restrictive with documentation quality and linking to other items.

Methods that will be implemented through incoherence must also be explicitly linked.
Personal preference that will be used for another module in a later commit. Purely stylistic.
They'll be moved into `core` but must be accessible from `std`.
Incoherence is required to define inherit methods on `Error` from `alloc` and `std` once it is moved into `core`. This is required because:

1. `Box` is part of `Error`'s public API and that is only accessible from `alloc`.
2. `RawOsError` methods must ensure the `OsFunctions` atomic pointer is appropriately set, which can only be done from `std`.
Required to allow `std` access from `core`
This allows `Error` to be moved into `core` while still retaining the ability to store custom error data. This may have performance implications!
Stored in a `static` `AtomicPtr` to allow definition in `core` and setting in `std`. Should be replaced with Externally Implemented Items (EII) or similar once stable.
Now that `Error` lives in `core::io`, doc links to it from `core` can be simplified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-unix Operating system: Unix-like S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants