@@ -242,8 +242,9 @@ unsafe impl<T> SliceIndex<[T]> for usize {
242
242
unsafe fn get_unchecked ( self , slice : * const [ T ] ) -> * const T {
243
243
assert_unsafe_precondition ! (
244
244
check_language_ub,
245
- "slice::get_unchecked requires that the index is within the slice" ,
246
- ( this: usize = self , len: usize = slice. len( ) ) => this < len
245
+ "slice::get_unchecked requires that the index is within the slice \
246
+ (index:{index}, len:{len})",
247
+ ( index: usize = self , len: usize = slice. len( ) ) => index < len
247
248
) ;
248
249
// SAFETY: the caller guarantees that `slice` is not dangling, so it
249
250
// cannot be longer than `isize::MAX`. They also guarantee that
@@ -261,8 +262,9 @@ unsafe impl<T> SliceIndex<[T]> for usize {
261
262
unsafe fn get_unchecked_mut ( self , slice : * mut [ T ] ) -> * mut T {
262
263
assert_unsafe_precondition ! (
263
264
check_library_ub,
264
- "slice::get_unchecked_mut requires that the index is within the slice" ,
265
- ( this: usize = self , len: usize = slice. len( ) ) => this < len
265
+ "slice::get_unchecked_mut requires that the index is within the slice \
266
+ (index:{index}, len:{len})",
267
+ ( index: usize = self , len: usize = slice. len( ) ) => index < len
266
268
) ;
267
269
// SAFETY: see comments for `get_unchecked` above.
268
270
unsafe { get_mut_noubcheck ( slice, self ) }
@@ -310,7 +312,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::IndexRange {
310
312
unsafe fn get_unchecked ( self , slice : * const [ T ] ) -> * const [ T ] {
311
313
assert_unsafe_precondition ! (
312
314
check_library_ub,
313
- "slice::get_unchecked requires that the index is within the slice" ,
315
+ "slice::get_unchecked requires that the index is within the slice \
316
+ (end:{end}, len:{len})",
314
317
( end: usize = self . end( ) , len: usize = slice. len( ) ) => end <= len
315
318
) ;
316
319
// SAFETY: the caller guarantees that `slice` is not dangling, so it
@@ -324,7 +327,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::IndexRange {
324
327
unsafe fn get_unchecked_mut ( self , slice : * mut [ T ] ) -> * mut [ T ] {
325
328
assert_unsafe_precondition ! (
326
329
check_library_ub,
327
- "slice::get_unchecked_mut requires that the index is within the slice" ,
330
+ "slice::get_unchecked_mut requires that the index is within the slice \
331
+ (end:{end}, len:{len})",
328
332
( end: usize = self . end( ) , len: usize = slice. len( ) ) => end <= len
329
333
) ;
330
334
@@ -389,7 +393,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
389
393
unsafe fn get_unchecked ( self , slice : * const [ T ] ) -> * const [ T ] {
390
394
assert_unsafe_precondition ! (
391
395
check_library_ub,
392
- "slice::get_unchecked requires that the range is within the slice" ,
396
+ "slice::get_unchecked requires that the range is within the slice \
397
+ (range:{start}..{end}, len:{len})",
393
398
(
394
399
start: usize = self . start,
395
400
end: usize = self . end,
@@ -413,7 +418,8 @@ unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
413
418
unsafe fn get_unchecked_mut ( self , slice : * mut [ T ] ) -> * mut [ T ] {
414
419
assert_unsafe_precondition ! (
415
420
check_library_ub,
416
- "slice::get_unchecked_mut requires that the range is within the slice" ,
421
+ "slice::get_unchecked_mut requires that the range is within the slice \
422
+ (range:{start}..{end}, len:{len})",
417
423
(
418
424
start: usize = self . start,
419
425
end: usize = self . end,
0 commit comments