Skip to content

clarify pointer add/sub function safety concerns #55060

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 2 commits into from
Oct 15, 2018
Merged

Conversation

jannic
Copy link
Contributor

@jannic jannic commented Oct 14, 2018

Ralf Jung made the same changes to the offset functions' documentation
in commit fb08915. As add/sub just call offset, the same limitation
applies here, as well.

I did not copy the whole explanation ("In particular, the resulting pointer may not be used to access a different allocated object [...]") because I'd consider that as being too repetitive. The documentation of add/sub already refers to the offset function, so people interested in the details can look it up, there.
But changing 'an object' to 'the same object' is a small change which improves clarity a lot.

@rust-highfive
Copy link
Contributor

r? @joshtriplett

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 14, 2018
@@ -1255,7 +1255,7 @@ impl<T: ?Sized> *const T {
/// Behavior:
///
/// * Both the starting and resulting pointer must be either in bounds or one
/// byte past the end of an allocated object.
/// byte past the end of *the same* allocated object.
Copy link
Member

Choose a reason for hiding this comment

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

The emphasis here feels unnecessary; it only makes sense in the context of a patch, not in the context of the resulting changed text.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The emphasis was copied from identical sentences on the offset functions. Shall I remove it there, as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the emphases in doc comments on offset() in a separate commit.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I missed that!

It's not that important, but thanks for updating those for consistency as well,

@@ -1312,7 +1312,7 @@ impl<T: ?Sized> *const T {
/// Behavior:
///
/// * Both the starting and resulting pointer must be either in bounds or one
/// byte past the end of an allocated object.
/// byte past the end of *the same* allocated object.
Copy link
Member

Choose a reason for hiding this comment

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

Likewise.

@@ -1893,7 +1893,7 @@ impl<T: ?Sized> *mut T {
/// Behavior:
///
/// * Both the starting and resulting pointer must be either in bounds or one
/// byte past the end of an allocated object.
/// byte past the end of *the same* allocated object.
Copy link
Member

Choose a reason for hiding this comment

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

Likewise.

@@ -1950,7 +1950,7 @@ impl<T: ?Sized> *mut T {
/// Behavior:
///
/// * Both the starting and resulting pointer must be either in bounds or one
/// byte past the end of an allocated object.
/// byte past the end of *the same* allocated object.
Copy link
Member

Choose a reason for hiding this comment

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

Likewise.

Ralf Jung made the same changes to the offset functions' documentation
in commit fb08915. As add/sub just call offset, the same limitation
applies here, as well.

Removed emphasis on review request by @joshtriplett
During review of the previous commit, @joshtriplett noticed that
the emphasis on 'the same' is unnecessary. For consistency, remove it
on the offset() functions, as well.
@joshtriplett
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Oct 14, 2018

📌 Commit 6cc84ac 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 Oct 14, 2018
Manishearth added a commit to Manishearth/rust that referenced this pull request Oct 15, 2018
clarify pointer add/sub function safety concerns

Ralf Jung made the same changes to the offset functions' documentation
in commit fb08915. As add/sub just call offset, the same limitation
applies here, as well.

I did not copy the whole explanation ("In particular, the resulting pointer may *not* be used to access a different allocated object [...]") because I'd consider that as being too repetitive. The documentation of add/sub already refers to the offset function, so people interested in the details can look it up, there.
But changing 'an object' to 'the same object' is a small change which improves clarity a lot.
bors added a commit that referenced this pull request Oct 15, 2018
Rollup of 11 pull requests

Successful merges:

 - #54820 (Closes #54538: `unused_patterns` lint)
 - #54963 (Cleanup rustc/session)
 - #54991 (add test for #23189)
 - #55025 (Add missing lifetime fragment specifier to error message.)
 - #55047 (doc: make core::fmt::Error example more simple)
 - #55048 (Don't collect to vectors where unnecessary)
 - #55060 (clarify pointer add/sub function safety concerns)
 - #55062 (Make EvalContext::step public again)
 - #55066 (Fix incorrect link in println! documentation)
 - #55081 (Deduplicate tests)
 - #55088 (Update rustc documentation link)

Failed merges:

r? @ghost
@bors bors merged commit 6cc84ac into rust-lang:master Oct 15, 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.

4 participants