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

Add a warning to File about mutability. #48273

Merged
merged 2 commits into from
Feb 18, 2018
Merged

Add a warning to File about mutability. #48273

merged 2 commits into from
Feb 18, 2018

Conversation

alercah
Copy link
Contributor

@alercah alercah commented Feb 16, 2018

Fixes #47708.

@rust-highfive
Copy link
Collaborator

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

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 16, 2018
@sfackler
Copy link
Member

LGTM, but letting one of the docs folks r+.

src/libstd/fs.rs Outdated
/// Note that, although read and write methods require a `&mut File`, because
/// of the interfaces for [`Read`] and [`Write`], it is still possible to
/// modify a file through a `&File`, either through methods that take `&File`
/// or by retrieving a raw OS filehandle and modifying the file that way.
Copy link
Member

Choose a reason for hiding this comment

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

"file handle"

Copy link
Member

Choose a reason for hiding this comment

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

Or "underlying OS object", since on Linux it'd be a file descriptor.

Copy link
Member

@joshtriplett joshtriplett left a comment

Choose a reason for hiding this comment

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

This looks great to me, and I'm glad to see these kinds of clarifying comments that help people understand the high-level semantics around what they're trying to do.

I posted one note about grammar, but otherwise I'd love to see this merged. Thanks!

src/libstd/fs.rs Outdated
/// or by retrieving a raw OS filehandle and modifying the file that way.
/// Additionally, many operating systems allow concurrent modification of files
/// by different processes. Care should be taken not to assume that holding a
/// `&File` means that the file will not change.
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit of a nitpick, but could you please phrase this in active voice?

"..., the holder of a &File can still modify that file, either through methods ..."

"... Avoid assuming that holding a &File means ..."

@alercah
Copy link
Contributor Author

alercah commented Feb 17, 2018

Comments fixed.

@joshtriplett
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Feb 17, 2018

@joshtriplett: 🔑 Insufficient privileges: not in try users

@bors
Copy link
Contributor

bors commented Feb 17, 2018

@joshtriplett: 🔑 Insufficient privileges: Not in reviewers

@sfackler
Copy link
Member

@bors r=joshtriplett rollup

@bors
Copy link
Contributor

bors commented Feb 17, 2018

📌 Commit ec90597 has been approved by joshtriplett

@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 Feb 17, 2018
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Feb 17, 2018
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Feb 18, 2018
bors added a commit that referenced this pull request Feb 18, 2018
Rollup of 6 pull requests

- Successful merges: #48194, #48273, #48274, #48275, #48282, #48312
- Failed merges:
@bors bors merged commit ec90597 into rust-lang:master Feb 18, 2018
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants