Skip to content

Commit 30122e9

Browse files
ecstatic-morseRalfJung
authored andcommitted
Fix off-by-one error when specifying a valid range
1 parent 6f7338b commit 30122e9

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/libcore/intrinsics.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -980,11 +980,11 @@ extern "rust-intrinsic" {
980980
///
981981
/// * Both `src` and `dst` must be properly aligned.
982982
///
983-
/// * `src.offset(count)` must be [valid]. In other words, the region of
983+
/// * `src.offset(count-1)` must be [valid]. In other words, the region of
984984
/// memory which begins at `src` and has a length of `count *
985985
/// size_of::<T>()` bytes must belong to a single, live allocation.
986986
///
987-
/// * `dst.offset(count)` must be [valid]. In other words, the region of
987+
/// * `dst.offset(count-1)` must be [valid]. In other words, the region of
988988
/// memory which begins at `dst` and has a length of `count *
989989
/// size_of::<T>()` bytes must belong to a single, live allocation.
990990
///
@@ -1068,11 +1068,11 @@ extern "rust-intrinsic" {
10681068
///
10691069
/// * Both `src` and `dst` must be properly aligned.
10701070
///
1071-
/// * `src.offset(count)` must be [valid]. In other words, the region of
1071+
/// * `src.offset(count-1)` must be [valid]. In other words, the region of
10721072
/// memory which begins at `src` and has a length of `count *
10731073
/// size_of::<T>()` bytes must belong to a single, live allocation.
10741074
///
1075-
/// * `dst.offset(count)` must be [valid]. In other words, the region of
1075+
/// * `dst.offset(count-1)` must be [valid]. In other words, the region of
10761076
/// memory which begins at `dst` and has a length of `count *
10771077
/// size_of::<T>()` bytes must belong to a single, live allocation.
10781078
///
@@ -1118,7 +1118,7 @@ extern "rust-intrinsic" {
11181118
///
11191119
/// * `dst` must be [valid].
11201120
///
1121-
/// * `dst.offset(count)` must be [valid]. In other words, the region of
1121+
/// * `dst.offset(count-1)` must be [valid]. In other words, the region of
11221122
/// memory which begins at `dst` and has a length of `count *
11231123
/// size_of::<T>()` bytes must belong to a single, live allocation.
11241124
///

src/libcore/ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,11 @@ pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
237237
///
238238
/// * Both `x` and `y` must be properly aligned.
239239
///
240-
/// * `x.offset(count)` must be [valid]. In other words, the region of memory
240+
/// * `x.offset(count-1)` must be [valid]. In other words, the region of memory
241241
/// which begins at `x` and has a length of `count * size_of::<T>()` bytes
242242
/// must belong to a single, live allocation.
243243
///
244-
/// * `y.offset(count)` must be [valid]. In other words, the region of memory
244+
/// * `y.offset(count-1)` must be [valid]. In other words, the region of memory
245245
/// which begins at `y` and has a length of `count * size_of::<T>()` bytes
246246
/// must belong to a single, live allocation.
247247
///

0 commit comments

Comments
 (0)