Skip to content

Add std::io::cursor::WriteThroughCursor#158537

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
bushrat011899:std_io_write_through_cursor
Jul 6, 2026
Merged

Add std::io::cursor::WriteThroughCursor#158537
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
bushrat011899:std_io_write_through_cursor

Conversation

@bushrat011899

@bushrat011899 bushrat011899 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

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

Description

Used to work around Cursor not being a fundamental type when implementing Write for Cursor<Vec<u8>> and other alloc types once Cursor and Write are both located in core. Please refer to #156527 for further context.


Notes

@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 Jun 29, 2026
@rustbot

rustbot commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

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 13 candidates
  • Random selection from 6 candidates

@clarfonthey

Copy link
Copy Markdown
Contributor

So, I'm not sure this PR itself is worthwhile separating from #158541, since it appears that you move this trait into core in that PR. Moving isn't tracked very well in git, especially when things aren't absolute file renames, and so I'm kind of inclined to just say that this should be part of that PR instead of this one.

That is also the largest PR of the bunch post-split, and I wonder if it should be further split up into parts, rather than this being the only "part" split off of it.

@bushrat011899

Copy link
Copy Markdown
Contributor Author

I've started a conversation about this matter on Zulip since it's probably better suited for workshopping a solution. Linking here for transparency.

Comment thread library/std/src/io/cursor.rs

#[stable(feature = "cursor_mut_vec", since = "1.25.0")]
impl<A> Write for Cursor<&mut Vec<u8, A>>
impl<A> WriteThroughCursor for &mut Vec<u8, A>

@clarfonthey clarfonthey Jul 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So, main concern is this unfortunately isn't going to be shown under the implementations for Write, and I'm not really sure what the best way to deal with that is. rustdoc doesn't really seem to have a method to create "fake" impls for docs only, so maybe there should be some kind of issue tracking a way to deal with this.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah I think there would need to be some kind of "flatten" feature for listing implementations. Ignoring instability for a moment, adding this trait would hide the Write implementations for:

  • Cursor<&mut Vec<u8, A>> where A: Allocator
  • Cursor<Vec<u8, A>> where A: Allocator
  • Cursor<Box<[u8], A>> where A: Allocator

And would instead show:

  • Cursor<T> where T: WriteThroughCursor

Which would require users to visit WriteThroughCursor to see it is implemented for:

  • &mut Vec<u8, A>
  • Vec<u8, A>
  • Box<[u8], A>

Ideally, we could do something like:

#[doc(flatten = "T")]
impl<T: WriteThroughCursor> Write for Cursor<T> { /* ... */ }

To recreate the original flat documentation.

@bushrat011899 bushrat011899 force-pushed the std_io_write_through_cursor branch from 86ea27a to bb3669b Compare July 3, 2026 02:03
@Mark-Simulacrum

Copy link
Copy Markdown
Member

r? @clarfonthey (happy to take the review but as you mentioned elsewhere might make sense to batch-review a bunch of these PRs)

Used to work around `Cursor` not being a fundamental type when implementing `Write` for `Cursor<Vec<u8>>` and other `alloc` types once `Cursor` and `Write` are both located in `core`.
@bushrat011899 bushrat011899 force-pushed the std_io_write_through_cursor branch from bb3669b to cae0245 Compare July 6, 2026 09:40
@rustbot

rustbot commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

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.

@clarfonthey

Copy link
Copy Markdown
Contributor

I think that the discussion from Zulip was compelling enough that we can merge this separately; essentially, this technically changes the behaviour of implementations and can be useful for bisection in case of issues, even though the actual code will show up as completely moved on diffs.

Given that this does not conflict with other core::io changes:

@bors r+ rollup=iffy

Marking as rollup=iffy mostly for visibility with the other core::io changes. While this and #158540 shouldn't conflict, not sure this should be added to the rollup if the other one which already includes that PR fails.

@rust-bors

rust-bors Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

📌 Commit cae0245 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 6, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 6, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #156976 (enable eager `param_env` norm in new solver)
 - #158537 (Add `std::io::cursor::WriteThroughCursor`)
 - #158540 (Move `std::io::Seek` to `core::io`)
 - #157820 (consider subtyping when checking if an infer var is sized)
 - #158505 (Update POSIX edition links)
 - #158853 (Fix typo for link on nto-qnx.md)
 - #157466 (Better error message when bare type in impl parameter list)
 - #157966 (Emit a suggestion to cast the never type into a concrete type when it fails to satisfy an `impl Trait` bound)
 - #158381 (Expose debug scope of statement and terminator in rustc_public)
 - #158405 (rustc_target: Add ARMv8-M related target features)
 - #158770 (Weaken guarantee for `From<legacy::RangeInclusive> for RangeInclusive`)
 - #158820 (Fix rustdoc ICE on deprecated note in inlined re-export chain)
@rust-bors rust-bors Bot merged commit dc5cd65 into rust-lang:main Jul 6, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 6, 2026
rust-timer added a commit that referenced this pull request Jul 6, 2026
Rollup merge of #158537 - bushrat011899:std_io_write_through_cursor, r=clarfonthey

Add `std::io::cursor::WriteThroughCursor`

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

## Description

Used to work around `Cursor` not being a fundamental type when implementing `Write` for `Cursor<Vec<u8>>` and other `alloc` types once `Cursor` and `Write` are both located in `core`. Please refer to #156527 for further context.

---

## 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.

4 participants