Skip to content

Move std::io::ErrorKind to core::io#154654

Open
bushrat011899 wants to merge 3 commits intorust-lang:mainfrom
bushrat011899:core_io_error_kind
Open

Move std::io::ErrorKind to core::io#154654
bushrat011899 wants to merge 3 commits intorust-lang:mainfrom
bushrat011899:core_io_error_kind

Conversation

@bushrat011899
Copy link
Copy Markdown

@bushrat011899 bushrat011899 commented Apr 1, 2026

View all comments

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!

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 1, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 1, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 8 candidates

@rustbot rustbot added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Apr 1, 2026
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bushrat011899 bushrat011899 force-pushed the core_io_error_kind branch 2 times, most recently from 8faa574 to 0ef55d6 Compare April 1, 2026 02:22
@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-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bushrat011899 bushrat011899 force-pushed the core_io_error_kind branch 2 times, most recently from 94753ea to b0ce24e Compare April 1, 2026 04:53
@a1phyr
Copy link
Copy Markdown
Contributor

a1phyr commented Apr 1, 2026

I'm concerned #152918 might be too controversial.

It may be controversial, but it has been accepted in principle by libs-teams, so it should be fine.

@bushrat011899
Copy link
Copy Markdown
Author

I'm concerned #152918 might be too controversial.

It may be controversial, but it has been accepted in principle by libs-teams, so it should be fine.

I hope so! I really want your PR to land. Regardless of whether it does, this is a good follow-up to go further at basically no cost.

@lygstate
Copy link
Copy Markdown
Contributor

lygstate commented Apr 1, 2026

looks good to me

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 4, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 4, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added O-unix Operating system: Unix-like O-windows Operating system: Windows labels Apr 5, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bushrat011899
Copy link
Copy Markdown
Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 7, 2026
pub mod char;
pub mod ffi;
#[unstable(feature = "core_io_borrowed_buf", issue = "117693")]
#[unstable(feature = "core_io", issue = "154046")]
Copy link
Copy Markdown
Member

@Mark-Simulacrum Mark-Simulacrum Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View changes since the review

Hm, I suspect we should stabilize the module existing (while leaving everything in it unstable). Otherwise it's annoying for everyone downstream to need two feature gates, and I think it's highly likely we do in fact want the module long-term.

Let me nominate #154046 for libs-api so they can decide if that seems reasonable.

Copy link
Copy Markdown
Author

@bushrat011899 bushrat011899 Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that would need to be done in a different PR, and this rebased if/when that's merged?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on this comment I'm merging io_error_kind_in_core into core_io. As a followup, it may be worth removing the core_io_borrowed_buf feature entirely, and using the read_buf feature std::io uses for BorrowedBuf and BorrowedCursor instead. That would still require two features to use borrowed buffers from core, but one of those is already required to use it from std anyway, so I think not too bad.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 11, 2026
@bushrat011899
Copy link
Copy Markdown
Author

@rustbot blocked

Marking as blocked until the module core::io is stabilised. Without its stabilisation, there is an unfortunate interaction between a features enabling core::io::ErrorKind and core::io::BorrowedBuf.

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 12, 2026
Certain links will not be valid when moved into `core::io`
* Checking exhaustion will no longer be possible for `repr_bitpacked`. Moving `kind_from_prim` into an associated function, and setting it up to be moved into `core::io` as well.
* `ErrorKind::as_str` is private, but it's only usage is trivially replaced with `Display::fmt`
* The features io_error_inprogress, io_error_more, and io_error_uncategorized will all need to be enabled
Move `std::io::ErrorKind` to `core::io`
* Update `rustdoc-html` tests for the new path
* Add `core_io` feature to control stability. This replaces the use of `core_io_borrowed_buf` on the `core::io` module itself.
* Re-export `core::io::ErrorKind` in `std::io::error`
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 14, 2026

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.

@bushrat011899
Copy link
Copy Markdown
Author

@rustbot ready
See this comment regarding the choice to use core_io to gate core::io and core::io::ErrorKind.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Apr 14, 2026
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 O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants