Skip to content

Commit 9526ce6

Browse files
committed
improve comment wording
1 parent 5c33a56 commit 9526ce6

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

compiler/rustc_const_eval/src/interpret/validity.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
434434
found_bytes: has.bytes()
435435
},
436436
);
437-
// Make sure this is non-null. (ZST references can be dereferenceable and null.)
437+
// Make sure this is non-null. We checked dereferenceability above, but if `size` is zero
438+
// that does not imply non-null.
438439
if self.ecx.scalar_may_be_null(Scalar::from_maybe_pointer(place.ptr(), self.ecx))? {
439440
throw_validation_failure!(self.path, NullPtr { ptr_kind })
440441
}

library/core/src/intrinsics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ extern "rust-intrinsic" {
14841484
/// # Safety
14851485
///
14861486
/// If the computed offset is non-zero, then both the starting and resulting pointer must be
1487-
/// either in bounds or one byte past the end of an allocated object. If either pointer is out
1487+
/// either in bounds or at the end of an allocated object. If either pointer is out
14881488
/// of bounds or arithmetic overflow occurs then any further use of the returned value will
14891489
/// result in undefined behavior.
14901490
///
@@ -1502,7 +1502,7 @@ extern "rust-intrinsic" {
15021502
/// # Safety
15031503
///
15041504
/// Unlike the `offset` intrinsic, this intrinsic does not restrict the
1505-
/// resulting pointer to point into or one byte past the end of an allocated
1505+
/// resulting pointer to point into or at the end of an allocated
15061506
/// object, and it wraps with two's complement arithmetic. The resulting
15071507
/// value is not necessarily valid to be used to actually access memory.
15081508
///

library/core/src/ptr/const_ptr.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,8 @@ impl<T: ?Sized> *const T {
465465
/// If any of the following conditions are violated, the result is Undefined
466466
/// Behavior:
467467
///
468-
/// * If the computed offset is non-zero, then both the starting and resulting pointer must be
469-
/// either in bounds or one byte past the end of the same [allocated object].
468+
/// * If the computed offset, **in bytes**, is non-zero, then both the starting and resulting
469+
/// pointer must be either in bounds or at the end of the same [allocated object].
470470
/// (If it is zero, then the function is always well-defined.)
471471
///
472472
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
@@ -952,8 +952,8 @@ impl<T: ?Sized> *const T {
952952
/// If any of the following conditions are violated, the result is Undefined
953953
/// Behavior:
954954
///
955-
/// * If the computed offset is non-zero, then both the starting and resulting pointer must be
956-
/// either in bounds or one byte past the end of the same [allocated object].
955+
/// * If the computed offset, **in bytes**, is non-zero, then both the starting and resulting
956+
/// pointer must be either in bounds or at the end of the same [allocated object].
957957
/// (If it is zero, then the function is always well-defined.)
958958
///
959959
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
@@ -1037,8 +1037,8 @@ impl<T: ?Sized> *const T {
10371037
/// If any of the following conditions are violated, the result is Undefined
10381038
/// Behavior:
10391039
///
1040-
/// * If the computed offset is non-zero, then both the starting and resulting pointer must be
1041-
/// either in bounds or one byte past the end of the same [allocated object].
1040+
/// * If the computed offset, **in bytes**, is non-zero, then both the starting and resulting
1041+
/// pointer must be either in bounds or at the end of the same [allocated object].
10421042
/// (If it is zero, then the function is always well-defined.)
10431043
///
10441044
/// * The computed offset cannot exceed `isize::MAX` **bytes**.

library/core/src/ptr/mut_ptr.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,8 @@ impl<T: ?Sized> *mut T {
480480
/// If any of the following conditions are violated, the result is Undefined
481481
/// Behavior:
482482
///
483-
/// * If the computed offset is non-zero, then both the starting and resulting pointer must be
484-
/// either in bounds or one byte past the end of the same [allocated object].
483+
/// * If the computed offset, **in bytes**, is non-zero, then both the starting and resulting
484+
/// pointer must be either in bounds or at the end of the same [allocated object].
485485
/// (If it is zero, then the function is always well-defined.)
486486
///
487487
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
@@ -1096,8 +1096,8 @@ impl<T: ?Sized> *mut T {
10961096
/// If any of the following conditions are violated, the result is Undefined
10971097
/// Behavior:
10981098
///
1099-
/// * If the computed offset is non-zero, then both the starting and resulting pointer must be
1100-
/// either in bounds or one byte past the end of the same [allocated object].
1099+
/// * If the computed offset, **in bytes**, is non-zero, then both the starting and resulting
1100+
/// pointer must be either in bounds or at the end of the same [allocated object].
11011101
/// (If it is zero, then the function is always well-defined.)
11021102
///
11031103
/// * The computed offset, **in bytes**, cannot overflow an `isize`.
@@ -1181,8 +1181,8 @@ impl<T: ?Sized> *mut T {
11811181
/// If any of the following conditions are violated, the result is Undefined
11821182
/// Behavior:
11831183
///
1184-
/// * If the computed offset is non-zero, then both the starting and resulting pointer must be
1185-
/// either in bounds or one byte past the end of the same [allocated object].
1184+
/// * If the computed offset, **in bytes**, is non-zero, then both the starting and resulting
1185+
/// pointer must be either in bounds or at the end of the same [allocated object].
11861186
/// (If it is zero, then the function is always well-defined.)
11871187
///
11881188
/// * The computed offset cannot exceed `isize::MAX` **bytes**.

0 commit comments

Comments
 (0)