Skip to content

Commit 8e42f01

Browse files
authored
Rollup merge of rust-lang#55060 - jannic:patch-1, r=joshtriplett
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.
2 parents 2e8b61d + 6cc84ac commit 8e42f01

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/libcore/ptr.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ impl<T: ?Sized> *const T {
10371037
/// Behavior:
10381038
///
10391039
/// * Both the starting and resulting pointer must be either in bounds or one
1040-
/// byte past the end of *the same* allocated object.
1040+
/// byte past the end of the same allocated object.
10411041
///
10421042
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
10431043
///
@@ -1255,7 +1255,7 @@ impl<T: ?Sized> *const T {
12551255
/// Behavior:
12561256
///
12571257
/// * Both the starting and resulting pointer must be either in bounds or one
1258-
/// byte past the end of an allocated object.
1258+
/// byte past the end of the same allocated object.
12591259
///
12601260
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
12611261
///
@@ -1312,7 +1312,7 @@ impl<T: ?Sized> *const T {
13121312
/// Behavior:
13131313
///
13141314
/// * Both the starting and resulting pointer must be either in bounds or one
1315-
/// byte past the end of an allocated object.
1315+
/// byte past the end of the same allocated object.
13161316
///
13171317
/// * The computed offset cannot exceed `isize::MAX` **bytes**.
13181318
///
@@ -1657,7 +1657,7 @@ impl<T: ?Sized> *mut T {
16571657
/// Behavior:
16581658
///
16591659
/// * Both the starting and resulting pointer must be either in bounds or one
1660-
/// byte past the end of *the same* allocated object.
1660+
/// byte past the end of the same allocated object.
16611661
///
16621662
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
16631663
///
@@ -1893,7 +1893,7 @@ impl<T: ?Sized> *mut T {
18931893
/// Behavior:
18941894
///
18951895
/// * Both the starting and resulting pointer must be either in bounds or one
1896-
/// byte past the end of an allocated object.
1896+
/// byte past the end of the same allocated object.
18971897
///
18981898
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
18991899
///
@@ -1950,7 +1950,7 @@ impl<T: ?Sized> *mut T {
19501950
/// Behavior:
19511951
///
19521952
/// * Both the starting and resulting pointer must be either in bounds or one
1953-
/// byte past the end of an allocated object.
1953+
/// byte past the end of the same allocated object.
19541954
///
19551955
/// * The computed offset cannot exceed `isize::MAX` **bytes**.
19561956
///

0 commit comments

Comments
 (0)