-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Conversation
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. |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"file handle"
There was a problem hiding this comment.
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.
There was a problem hiding this 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. |
There was a problem hiding this comment.
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 ..."
Comments fixed. |
@bors r+ rollup |
@joshtriplett: 🔑 Insufficient privileges: not in try users |
@joshtriplett: 🔑 Insufficient privileges: Not in reviewers |
@bors r=joshtriplett rollup |
📌 Commit ec90597 has been approved by |
Add a warning to File about mutability. Fixes rust-lang#47708.
Add a warning to File about mutability. Fixes rust-lang#47708.
Fixes #47708.