Skip to content
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

docs: improve std::fs::read doc #114448

Merged
merged 1 commit into from
Sep 1, 2023
Merged

Conversation

SteveLauC
Copy link
Contributor

What does this PR do

  1. Rephrase a confusing sentence in the document of std::fs::read()

Closes #114432

cc @Dexus0 @saethlin

@rustbot
Copy link
Collaborator

rustbot commented Aug 4, 2023

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@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 Aug 4, 2023
@gurry
Copy link
Contributor

gurry commented Aug 4, 2023

Perhaps we should do more here and also explain what is so special about io::ErrorKind::Interrupted. What will happen if io::ErrorKind::Interrupted is encountered as opposed to errors "other than io::ErrorKind::Interrupted"? Why do we even bring up this error kind here?

As a reader the intent of this whole sentence is not clear to me.

@SteveLauC
Copy link
Contributor Author

SteveLauC commented Aug 4, 2023

Perhaps we should do more here and also explain:

What is so special about io::ErrorKind::Interrupted? Why do we even bring up this error kind here?

Agree, IMO, any error that could be constructed from Error::from_raw_os_error(an_errno_that_could_be_returned_from_the_read_syscall) can potentially happen, Interrupted(EINTR) is just one of them

@gurry
Copy link
Contributor

gurry commented Aug 4, 2023

I see. If that is the case, why do we say it can throw errors other than Interrupted? Why not just say it can throw any error that could be constructed from Error::from_raw_os_error(an_errno_that_could_be_returned_from_the_read_syscall) (of course word that in a more user-friendly way).

Comment on lines 236 to 237
/// Also, while reading, an error of a kind other than [`io::ErrorKind::Interrupted`]
/// can be returned if it is encountered.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Also, while reading, an error of a kind other than [`io::ErrorKind::Interrupted`]
/// can be returned if it is encountered.
/// Reading from the file handles [`io::ErrorKind::Interrupted`] with automatic retries. See [`io::Read`] documentation for details.

https://doc.rust-lang.org/nightly/std/io/trait.Read.html#errors-1 has some further discussion of this -- just a suggestion on possible text here, I think this reads better than both master and the PR proposal. But happy to merge some other form.

Let's also update the similar text on line ~274.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done:)

Dexus0

This comment was marked as duplicate.

@@ -233,8 +233,8 @@ pub struct DirBuilder {
/// This function will return an error if `path` does not already exist.
/// Other errors may also be returned according to [`OpenOptions::open`].
///
/// It will also return an error if it encounters while reading an error
/// of a kind other than [`io::ErrorKind::Interrupted`].
/// Reading from the file handles [`io::ErrorKind::Interrupted`] with automatic
Copy link

Choose a reason for hiding this comment

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

Suggested change
/// Reading from the file handles [`io::ErrorKind::Interrupted`] with automatic
/// While reading from the file, handles [`io::ErrorKind::Interrupted`] with automatic

Copy link

Choose a reason for hiding this comment

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

This makes more sense to me.

Copy link

Choose a reason for hiding this comment

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

My suggestion seems a wee bit confusing without the next line for context...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What about adding a subject to the sentence:

While reading from the file, this function handles [io::ErrorKind::Interrupted] with automatic retries. See [io::Read] documentation for details.

Copy link

Choose a reason for hiding this comment

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

Seems good to me.

@SteveLauC
Copy link
Contributor Author

I just pushed the new code comment, ping me if you need me to squash the commits

@Mark-Simulacrum
Copy link
Member

r=me with commits squashed

@Dexus0
Copy link

Dexus0 commented Aug 31, 2023

r=me with commits squashed

@SteveLauC

@SteveLauC
Copy link
Contributor Author

r=me with commits squashed

@SteveLauC

Does this instruction mean that I need to squash my commits? I thought it can be done automatically

@saethlin
Copy link
Member

saethlin commented Sep 1, 2023

You need to squash your commits. GitHub can do it automatically if you merge via GitHub but the Rust organization does not use GitHub to merge commits. Rust uses an implementation of the same concept behind GitHub merge queues- you only merge if the merged state would pass the tests. Which means you must test merges one-at-a-time. Here's the queue for this repo: https://bors.rust-lang.org/queue/rust

People say "r=me with..." to indicate that anyone else with review permissions can send this off to the merge queue when the thing is done.

@SteveLauC
Copy link
Contributor Author

You need to squash your commits. GitHub can do it automatically if you merge via GitHub but the Rust organization does not use GitHub to merge commits. Rust uses an implementation of the same concept behind GitHub merge queues- you only merge if the merged state would pass the tests. Which means you must test merges one-at-a-time. Here's the queue for this repo: https://bors.rust-lang.org/queue/rust

People say "r=me with..." to indicate that anyone else with review permissions can send this off to the merge queue when the thing is done.

Commits squashed, thanks for you detaild explanation:)

@saethlin
Copy link
Member

saethlin commented Sep 1, 2023

@bors r=Mark-Simulacrum rollup=always

@bors
Copy link
Contributor

bors commented Sep 1, 2023

📌 Commit 0e270b1 has been approved by Mark-Simulacrum

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 Sep 1, 2023
@bors
Copy link
Contributor

bors commented Sep 1, 2023

⌛ Testing commit 0e270b1 with merge dc348db...

@bors
Copy link
Contributor

bors commented Sep 1, 2023

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing dc348db to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 1, 2023
@bors bors merged commit dc348db into rust-lang:master Sep 1, 2023
11 checks passed
@rustbot rustbot added this to the 1.74.0 milestone Sep 1, 2023
@SteveLauC SteveLauC deleted the std_fs_read_doc branch September 1, 2023 07:10
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (dc348db): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.3% [1.3%, 1.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.5% [-2.4%, -0.4%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.8% [-2.4%, 1.3%] 4

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 631.304s -> 632.086s (0.12%)
Artifact size: 316.42 MiB -> 316.25 MiB (-0.06%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

Confusing sentence about errors in fs::read
8 participants