Skip to content

Move std::io::buffered to alloc::io - #158547

Merged
rust-bors[bot] merged 11 commits into
rust-lang:mainfrom
bushrat011899:alloc_io_buffered
Jul 21, 2026
Merged

Move std::io::buffered to alloc::io#158547
rust-bors[bot] merged 11 commits into
rust-lang:mainfrom
bushrat011899:alloc_io_buffered

Conversation

@bushrat011899

@bushrat011899 bushrat011899 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

View all comments

ACP: rust-lang/libs-team#755
Tracking issue: #154046
Split From: #156527
Blocked On: #158546

Description

Moves std::io::BufReader/BufWriter/LineWriter/etc. to alloc::io. This is effectively a direct cut and paste. Blocked on #158546.


Notes

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 29, 2026
@rustbot

rustbot commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

r? @JohnTitor

rustbot has assigned @JohnTitor.
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 13 candidates
  • Random selection from 6 candidates

@rustbot rustbot added 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. labels Jun 29, 2026
@bushrat011899

Copy link
Copy Markdown
Contributor Author

@rustbot blocked

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 29, 2026
@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@bushrat011899
bushrat011899 force-pushed the alloc_io_buffered branch 2 times, most recently from dd63a8f to bc8b452 Compare July 3, 2026 03:48
@rustbot

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

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

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 20, 2026
Move `std::io::buffered` to `alloc::io`
@rust-bors

rust-bors Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: b404afe (b404afe496973d61ac2deb36a68e7664b110decd)
Base parent: 14ead7d (14ead7d3d509f50efe9afb84673e65885dfd4d07)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (b404afe): comparison URL.

Overall result: no relevant changes - 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

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

Max RSS (memory usage)

Results (primary 2.9%, secondary 0.7%)

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

mean range count
Regressions ❌
(primary)
6.6% [6.6%, 6.6%] 1
Regressions ❌
(secondary)
5.9% [4.6%, 7.2%] 4
Improvements ✅
(primary)
-0.9% [-0.9%, -0.9%] 1
Improvements ✅
(secondary)
-4.5% [-6.5%, -3.1%] 4
All ❌✅ (primary) 2.9% [-0.9%, 6.6%] 2

Cycles

Results (primary -0.5%)

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

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

Binary size

Results (primary 0.0%, secondary 0.0%)

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

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

Bootstrap: 485.673s -> 485.443s (-0.05%)
Artifact size: 391.74 MiB -> 392.41 MiB (0.17%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 20, 2026
@clarfonthey

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 6ef1cf3 has been approved by clarfonthey

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 20, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 20, 2026
…=clarfonthey

Move `std::io::buffered` to `alloc::io`

ACP: rust-lang/libs-team#755
Tracking issue: rust-lang#154046
Split From: rust-lang#156527
~~Blocked On: rust-lang#158546

## Description

Moves `std::io::BufReader`/`BufWriter`/`LineWriter`/etc. to `alloc::io`. This is effectively a direct cut and paste. Blocked on rust-lang#158546.

---

## Notes

* No AI tooling of any kind was used during the creation of this PR.
* Please see rust-lang#154046 (comment) for a review order and broader context for this PR.
rust-bors Bot pushed a commit that referenced this pull request Jul 21, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #159582 (Sync from portable simd 2026 07 20)
 - #157270 (ergonomic_clones_dotuse_capture_by_ref: Capture upvar by ref for `.use` in non-move closures)
 - #158496 (Move `check_rustc_pub_transparent` into the attribute parser)
 - #158547 (Move `std::io::buffered` to `alloc::io`)
 - #159505 (make rustdoc::bare_urls strip trailing periods from url)
 - #159578 (Extract coroutine closure helper functions)
 - #159613 (Set the rustc lib path for unstable-book-gen)
rust-bors Bot pushed a commit that referenced this pull request Jul 21, 2026
Rollup of 14 pull requests

Successful merges:

 - #159307 (Improve cross-namespace name diagnostics)
 - #159543 (Remove extra semicolons in parsing item lists)
 - #157270 (ergonomic_clones_dotuse_capture_by_ref: Capture upvar by ref for `.use` in non-move closures)
 - #158496 (Move `check_rustc_pub_transparent` into the attribute parser)
 - #158547 (Move `std::io::buffered` to `alloc::io`)
 - #158808 (Filter host libstdc++ ABI flag in rustc_llvm cross builds)
 - #159362 (Add regression test for #120328)
 - #159472 (Support creating float constants in rustc_public mir)
 - #159505 (make rustdoc::bare_urls strip trailing periods from url)
 - #159568 (Suggest close compiler options)
 - #159578 (Extract coroutine closure helper functions)
 - #159601 (Make `TokenTreeCursor` private)
 - #159613 (Set the rustc lib path for unstable-book-gen)
 - #159616 (Clarify the comment about stage1/stage2 discrepancy in input-stats test)
@rust-bors
rust-bors Bot merged commit 3425124 into rust-lang:main Jul 21, 2026
14 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 21, 2026
rust-timer added a commit that referenced this pull request Jul 21, 2026
Rollup merge of #158547 - bushrat011899:alloc_io_buffered, r=clarfonthey

Move `std::io::buffered` to `alloc::io`

ACP: rust-lang/libs-team#755
Tracking issue: #154046
Split From: #156527
~~Blocked On: #158546

## Description

Moves `std::io::BufReader`/`BufWriter`/`LineWriter`/etc. to `alloc::io`. This is effectively a direct cut and paste. Blocked on #158546.

---

## Notes

* No AI tooling of any kind was used during the creation of this PR.
* Please see #154046 (comment) for a review order and broader context for this PR.
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Jul 22, 2026
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#159307 (Improve cross-namespace name diagnostics)
 - rust-lang/rust#159543 (Remove extra semicolons in parsing item lists)
 - rust-lang/rust#157270 (ergonomic_clones_dotuse_capture_by_ref: Capture upvar by ref for `.use` in non-move closures)
 - rust-lang/rust#158496 (Move `check_rustc_pub_transparent` into the attribute parser)
 - rust-lang/rust#158547 (Move `std::io::buffered` to `alloc::io`)
 - rust-lang/rust#158808 (Filter host libstdc++ ABI flag in rustc_llvm cross builds)
 - rust-lang/rust#159362 (Add regression test for rust-lang/rust#120328)
 - rust-lang/rust#159472 (Support creating float constants in rustc_public mir)
 - rust-lang/rust#159505 (make rustdoc::bare_urls strip trailing periods from url)
 - rust-lang/rust#159568 (Suggest close compiler options)
 - rust-lang/rust#159578 (Extract coroutine closure helper functions)
 - rust-lang/rust#159601 (Make `TokenTreeCursor` private)
 - rust-lang/rust#159613 (Set the rustc lib path for unstable-book-gen)
 - rust-lang/rust#159616 (Clarify the comment about stage1/stage2 discrepancy in input-stats test)
fs-rachel added a commit to fs-rachel/rust that referenced this pull request Jul 29, 2026
rust-lang#158547 moved `std::io::BufWriter` to
`alloc::io::BufWriter`. That allows it to be used in `no-std` configurations,
and in particular on platforms where unwinding isn't supported.

However one of the doc tests uses `catch_unwind`, which fails on platforms
which cannot unwind. Fix this by copying the magic incantation from a similar
doctest in library/core/src/range.rs
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 29, 2026
… r=clarfonthey

Mark a doctest as requiring unwinding

rust-lang#158547 moved `std::io::BufWriter` to `alloc::io::BufWriter`. That allows it to be used in `no-std` configurations, and in particular on platforms where unwinding isn't supported.

However one of the doc tests uses `catch_unwind`, which fails on platforms which cannot unwind. Fix this by copying the magic incantation from a similar doctest in library/core/src/range.rs
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 29, 2026
… r=clarfonthey

Mark a doctest as requiring unwinding

rust-lang#158547 moved `std::io::BufWriter` to `alloc::io::BufWriter`. That allows it to be used in `no-std` configurations, and in particular on platforms where unwinding isn't supported.

However one of the doc tests uses `catch_unwind`, which fails on platforms which cannot unwind. Fix this by copying the magic incantation from a similar doctest in library/core/src/range.rs
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 29, 2026
… r=clarfonthey

Mark a doctest as requiring unwinding

rust-lang#158547 moved `std::io::BufWriter` to `alloc::io::BufWriter`. That allows it to be used in `no-std` configurations, and in particular on platforms where unwinding isn't supported.

However one of the doc tests uses `catch_unwind`, which fails on platforms which cannot unwind. Fix this by copying the magic incantation from a similar doctest in library/core/src/range.rs
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 30, 2026
… r=clarfonthey

Mark a doctest as requiring unwinding

rust-lang#158547 moved `std::io::BufWriter` to `alloc::io::BufWriter`. That allows it to be used in `no-std` configurations, and in particular on platforms where unwinding isn't supported.

However one of the doc tests uses `catch_unwind`, which fails on platforms which cannot unwind. Fix this by copying the magic incantation from a similar doctest in library/core/src/range.rs
rust-timer added a commit that referenced this pull request Jul 30, 2026
Rollup merge of #160151 - fs-rachel:unwind-in-alloc-doctest, r=clarfonthey

Mark a doctest as requiring unwinding

#158547 moved `std::io::BufWriter` to `alloc::io::BufWriter`. That allows it to be used in `no-std` configurations, and in particular on platforms where unwinding isn't supported.

However one of the doc tests uses `catch_unwind`, which fails on platforms which cannot unwind. Fix this by copying the magic incantation from a similar doctest in library/core/src/range.rs
addiesh pushed a commit to addiesh/rust that referenced this pull request Jul 31, 2026
rust-lang#158547 moved `std::io::BufWriter` to
`alloc::io::BufWriter`. That allows it to be used in `no-std` configurations,
and in particular on platforms where unwinding isn't supported.

However one of the doc tests uses `catch_unwind`, which fails on platforms
which cannot unwind. Fix this by copying the magic incantation from a similar
doctest in library/core/src/range.rs
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 1, 2026
…als, r=clarfonthey

Move `std::io::copy` to `alloc::io`

ACP: rust-lang/libs-team#755
Tracking issue: rust-lang#154046
Split From: rust-lang#156527
~~Blocked On: rust-lang#158547

## Description

Moves `std::io::copy` into `alloc::io`. Blocked on rust-lang#158547.

This relies on specialization to allow `std` to provide optimised copy implementations for its types where appropriate. The exact technique involves defining a new trait, `alloc::io::SpecCopy`:

```rust
#[doc(hidden)]
#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
#[rustc_specialization_trait]
pub trait SpecCopy: Read {
    /// Attempt to copy from this reader to the provided writer using a specialized
    /// process.
    fn copy<R: Read + ?Sized, W: Write + ?Sized>(
        _reader: &mut R,
        _writer: &mut W,
    ) -> Result<CopyState>;
}
```

Since optimised copying requires both the reader and writer to support the operation between each other, we can choose one of them to be the implementer of the copy algorithm, and delegate specialization to it. In this case, I've chosen the reader to be the provider of the specialized copy implementation arbitrarily. Note that the `SpecCopy::copy` function is generic over the reader specifically to allow wrappers like `Take<R>` to be visible to the implementation of `copy`.

Because this introduces a new layer of specialization to `io::copy`, I think this PR should be benchmarked to make sure performance characteristics aren't too different. I am expecting compilation time to be slightly worse, since there's just more specialization happening, but the actual code run _should_ be the same.

---

## Notes

* No AI tooling of any kind was used during the creation of this PR.
* Please see rust-lang#154046 (comment) for a review order and broader context for this PR.
rust-timer added a commit that referenced this pull request Aug 1, 2026
Rollup merge of #158548 - bushrat011899:alloc_io_copy_internals, r=clarfonthey

Move `std::io::copy` to `alloc::io`

ACP: rust-lang/libs-team#755
Tracking issue: #154046
Split From: #156527
~~Blocked On: #158547

## Description

Moves `std::io::copy` into `alloc::io`. Blocked on #158547.

This relies on specialization to allow `std` to provide optimised copy implementations for its types where appropriate. The exact technique involves defining a new trait, `alloc::io::SpecCopy`:

```rust
#[doc(hidden)]
#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")]
#[rustc_specialization_trait]
pub trait SpecCopy: Read {
    /// Attempt to copy from this reader to the provided writer using a specialized
    /// process.
    fn copy<R: Read + ?Sized, W: Write + ?Sized>(
        _reader: &mut R,
        _writer: &mut W,
    ) -> Result<CopyState>;
}
```

Since optimised copying requires both the reader and writer to support the operation between each other, we can choose one of them to be the implementer of the copy algorithm, and delegate specialization to it. In this case, I've chosen the reader to be the provider of the specialized copy implementation arbitrarily. Note that the `SpecCopy::copy` function is generic over the reader specifically to allow wrappers like `Take<R>` to be visible to the implementation of `copy`.

Because this introduces a new layer of specialization to `io::copy`, I think this PR should be benchmarked to make sure performance characteristics aren't too different. I am expecting compilation time to be slightly worse, since there's just more specialization happening, but the actual code run _should_ be the same.

---

## Notes

* No AI tooling of any kind was used during the creation of this PR.
* Please see #154046 (comment) for a review order and broader context for this PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants