Skip to content

docs: Small clarification on the usage of read_to_string and read_to_end trait methods #142102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2025

Conversation

kiseitai3
Copy link

@kiseitai3 kiseitai3 commented Jun 6, 2025

Small clarification on the usage of read_to_string and read_to_end trait methods. The goal is to make it clear that these trait methods will become locked up if attempting to read to the end of stdin (which is a bit non-sensical unless the other end closes the pipe).

Fixes: #141714

@rustbot
Copy link
Collaborator

rustbot commented Jun 6, 2025

r? @joboet

rustbot has assigned @joboet.
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

@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 6, 2025
@rustbot

This comment has been minimized.

@kiseitai3
Copy link
Author

This is follow up work on #141935. If possible, reassign to @tgross35. A mistake was made in the previous PR. I attempted a rebase and one thing led to another and the branch became a mess, so I killed the branch. That autoclosed the old PR, so I opened a new one with changes more in line with what Trevor asked.

Sorry, but I hope this PR is more like what is expected in this project.

@rust-log-analyzer

This comment has been minimized.

@tgross35
Copy link
Contributor

tgross35 commented Jun 6, 2025

If possible, reassign to @tgross35

I'll let you do this yourself for the experience :) you can request reviews by posting a comment, see rustbot's guidelines:

Use r? to explicitly pick a reviewer

@tgross35
Copy link
Contributor

tgross35 commented Jun 6, 2025

Also it looks like you accidentally picked up a submodule change here. There's about 1000 different ways to fix this but if you need a suggestion, I would do something like this:

# Reset to the point where your branch forked from `master`. The reset will get rid
# of your commit and mark all of the files as staged
git reset "$(git merge-base HEAD master)"

# Add the thing you care about
git add library/std

# Get ride of the unintentional changes
git restore src/doc

# Re-commit the files (now only what you care about) using 🪄 magic 🪄 to
# reuse the commit message you have now
git commit -C HEAD@{1}

# Update this PR
git push --force-with-lease

Also, you can always check exactly what your PR will look like before pushing with git diff "$(git merge-base HEAD master)", to avoid things like whatever bad luck you ran into with #141935 (comment).

(happy to help with git stuff if you have further questions)

@kiseitai3
Copy link
Author

kiseitai3 commented Jun 7, 2025

I'm not using git from the terminal. I am using it through RustRover and I assumed it had only picked up my modified file since I had not changed anything. However, I do see failure messages for what appear to be automatic attempts at running repository actions. I did not look closely since I have very little personal time for coding and I kinda wanted to move on with a milestone in my own personal project. I will need to correct that in my IDE settings. That's annoying.

I have used git in the terminal before so maybe that would have given me a clue. Maybe one of these days I will convert to Vim and embrace the terminal more (which is ironic considering I use the terminal 24/7 at work).

r? @tgross35

P.S. > Completely missed the docs changes getting picked up.

image

@rustbot rustbot assigned tgross35 and unassigned joboet Jun 7, 2025
@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 7, 2025
@kiseitai3 kiseitai3 force-pushed the 141714_stdin_read_to_string_docs branch from 6bc0f7f to 356d852 Compare June 7, 2025 02:22
@rustbot rustbot removed has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 7, 2025
@kiseitai3 kiseitai3 requested a review from tgross35 June 7, 2025 02:24
@tgross35
Copy link
Contributor

tgross35 commented Jun 9, 2025

This looks great to me, thank you for the changes! You don't need to mention me in the commit though, just describe what you did since it is your work :)

For the submodule thing - git usually marks submodules as unstaged changes if you don't update them when changing branches / rebasing / etc, so anything that does git add . or git commit -a to commit all files will pick them up even when you never touched the file. Just submodules being a bit annoying, unfortunately.

@kiseitai3
Copy link
Author

This looks great to me, thank you for the changes! You don't need to mention me in the commit though, just describe what you did since it is your work :)

For the submodule thing - git usually marks submodules as unstaged changes if you don't update them when changing branches / rebasing / etc, so anything that does git add . or git commit -a to commit all files will pick them up even when you never touched the file. Just submodules being a bit annoying, unfortunately.

I have learned quite a bit from you on git. Since I don't solely use git on the terminal or via IDEs, I don't have as deep experience with terminal git. I am going to save the instructions above to a cheatsheet to recover from bad commits in the future.

Thank you!

P.S. > I wish I was compiler designer smart. Impressive work you all have done. With that said, my hope is to make Rust core to my development so maybe I will get more chances to contribute in the future.

@tgross35 tgross35 force-pushed the 141714_stdin_read_to_string_docs branch from 356d852 to 7d7fedb Compare June 10, 2025 05:11
@tgross35
Copy link
Contributor

Recovering from bad commits becomes mandatory learning at some point 😆

P.S. > I wish I was compiler designer smart.

You are, you just made your first contribution to a rather impressive project :) Welcome and thank you for the persistence here!

I force pushed your branch to make the commit message match this PR's title, so with that:

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jun 10, 2025

📌 Commit 7d7fedb has been approved by tgross35

It is now in the queue for this repository.

@bors bors 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 Jun 10, 2025
fmease added a commit to fmease/rust that referenced this pull request Jun 10, 2025
…ing_docs, r=tgross35

docs: Small clarification on the usage of read_to_string and read_to_end trait methods

Small clarification on the usage of read_to_string and read_to_end trait methods. The goal is to make it clear that these trait methods will become locked up if attempting to read to the end of stdin (which is a bit non-sensical unless the other end closes the pipe).

Fixes: rust-lang#141714
bors added a commit that referenced this pull request Jun 10, 2025
Rollup of 14 pull requests

Successful merges:

 - #134442 (Specify the behavior of `file!`)
 - #134841 (Look at proc-macro attributes when encountering unknown attribute)
 - #140372 (Exhaustively handle parsed attributes in CheckAttr)
 - #140766 (Stabilize keylocker)
 - #141642 (Note the version and PR of removed features when using it)
 - #141909 (Add central execution context to bootstrap)
 - #141992 (use `#[naked]` for `__rust_probestack`)
 - #142102 (docs: Small clarification on the usage of read_to_string and read_to_end trait methods)
 - #142124 (Allow transmute casts in pre-runtime-MIR)
 - #142240 (deduplicate the rest of AST walker functions)
 - #142258 (platform-support.md: Mention specific Linux kernel version or later)
 - #142262 (Mark `core::slice::memchr` as `#[doc(hidden)]`)
 - #142271 (compiler: fn ptrs should hit different lints based on ABI)
 - #142288 (const_eval: fix some outdated comments)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jun 10, 2025
Rollup of 16 pull requests

Successful merges:

 - #134442 (Specify the behavior of `file!`)
 - #140372 (Exhaustively handle parsed attributes in CheckAttr)
 - #140766 (Stabilize keylocker)
 - #141642 (Note the version and PR of removed features when using it)
 - #141818 (Don't create .msi installer for gnullvm hosts)
 - #141909 (Add central execution context to bootstrap)
 - #141992 (use `#[naked]` for `__rust_probestack`)
 - #142101 (core::ptr: deduplicate more method docs)
 - #142102 (docs: Small clarification on the usage of read_to_string and read_to_end trait methods)
 - #142124 (Allow transmute casts in pre-runtime-MIR)
 - #142240 (deduplicate the rest of AST walker functions)
 - #142258 (platform-support.md: Mention specific Linux kernel version or later)
 - #142262 (Mark `core::slice::memchr` as `#[doc(hidden)]`)
 - #142271 (compiler: fn ptrs should hit different lints based on ABI)
 - #142275 (rustdoc: Refractor `clean_ty_generics`)
 - #142288 (const_eval: fix some outdated comments)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 590f630 into rust-lang:master Jun 10, 2025
10 checks passed
@rustbot rustbot added this to the 1.89.0 milestone Jun 10, 2025
rust-timer added a commit that referenced this pull request Jun 10, 2025
Rollup merge of #142102 - kiseitai3:141714_stdin_read_to_string_docs, r=tgross35

docs: Small clarification on the usage of read_to_string and read_to_end trait methods

Small clarification on the usage of read_to_string and read_to_end trait methods. The goal is to make it clear that these trait methods will become locked up if attempting to read to the end of stdin (which is a bit non-sensical unless the other end closes the pipe).

Fixes: #141714
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.

Cannot read from STDIN with read_to_string if reading before piping Rust program writes to STDOUT in another Rust program
6 participants