Skip to content

Move IoSlice and IoSliceMut to core::io#155849

Open
bushrat011899 wants to merge 3 commits into
rust-lang:mainfrom
bushrat011899:io_slice_in_core
Open

Move IoSlice and IoSliceMut to core::io#155849
bushrat011899 wants to merge 3 commits into
rust-lang:mainfrom
bushrat011899:io_slice_in_core

Conversation

@bushrat011899
Copy link
Copy Markdown
Contributor

@bushrat011899 bushrat011899 commented Apr 27, 2026

View all comments

ACP: rust-lang/libs-team#755
Tracking issue: #154046
Related: #152918
Related: #155625

Description

Moves std::io::IoSlice and std::io::IoSliceMut into core::io. This is required for the Read and Write traits to be moved into alloc and/or core, as they contain stable methods which work with IO slices. Similar to #155574, this PR inlines the std::sys types required to create an ABI compatible type for the platforms where such compatibility is guaranteed.

Additionally, I've moved the relevant tests out of std::io::tests into coretests::io::io_slice.


Notes

  • This PR overlaps with Move OS-dependent parts of std::io to alloc #152918, but goes further than moving the IO slice types to alloc and instead moves them straight to core. Since these types have no interaction with allocation, and doing so will allow Write to move to core::io, I consider this a better home for these types.
  • Some discussion around the decision to not use a core::sys module can be found here.
  • I've renamed unsupported to generic to better reflect that IoSlice(Mut) is supported by all platforms, it just doesn't have a special ABI-compatible type. I don't want to imply that parts of core "don't work" depending on the target; IoSlice(Mut) works exactly as expected on all targets.
  • I've made pub items within each platform-specific representation pub(super) to highlight that everything within core::io::io_slice is an internal implementation detail not meant for any other part of the crate to be aware of.
  • No AI tooling of any kind was used during the creation of this PR.

@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 27, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 27, 2026

r? @jhpratt

rustbot has assigned @jhpratt.
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: @scottmcm, libs
  • @scottmcm, libs expanded to 7 candidates
  • Random selection from Mark-Simulacrum, jhpratt, scottmcm

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@lygstate
Copy link
Copy Markdown
Contributor

a long awating staff, thanks.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bushrat011899

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 12, 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.

- 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)`.
@bushrat011899
Copy link
Copy Markdown
Contributor Author

I've split this PR into 3 commits to better highlight how little actually changes in order to facilitate this move. For reviewers, I recommend going through each commit individually.

@jhpratt
Copy link
Copy Markdown
Member

jhpratt commented May 13, 2026

As a heads up, I am currently exploring Europe and won't be home for a couple more weeks. If you'd like a review before then, feel free to reroll.

@bushrat011899
Copy link
Copy Markdown
Contributor Author

bushrat011899 commented May 13, 2026

As a heads up, I am currently exploring Europe and won't be home for a couple more weeks. If you'd like a review before then, feel free to reroll.

Thanks for the heads up, hope you have a great time!

r? libs

@rustbot

This comment was marked as outdated.

@nia-e
Copy link
Copy Markdown
Member

nia-e commented May 13, 2026

I will probably also take a day or two before I can get to this, but given the stuff it's touching it's likely worth a perf run:

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 13, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 13, 2026
Move `IoSlice` and `IoSliceMut` to `core::io`
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 13, 2026

☀️ Try build successful (CI)
Build commit: 3b58d69 (3b58d695c0cd85a0de0390442cb7bbad84c6476e, parent: eab3d9776409dfb564130c3cd5f6ecacef3d3279)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (3b58d69): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
-0.3% [-0.3%, -0.3%] 2
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 1
All ❌✅ (primary) -0.3% [-0.3%, -0.3%] 2

Max RSS (memory usage)

Results (secondary -2.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.2% [-2.2%, -2.2%] 1
All ❌✅ (primary) - - 0

Cycles

Results (primary 2.5%, secondary 0.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
3.4% [2.8%, 4.2%] 5
Regressions ❌
(secondary)
3.4% [2.6%, 4.5%] 3
Improvements ✅
(primary)
-2.2% [-2.2%, -2.2%] 1
Improvements ✅
(secondary)
-3.7% [-4.7%, -2.7%] 2
All ❌✅ (primary) 2.5% [-2.2%, 4.2%] 6

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 509.956s -> 530.998s (4.13%)
Artifact size: 398.07 MiB -> 400.08 MiB (0.50%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants