Skip to content

Commit 90ea93b

Browse files
committed
track_caller for slice length assertions
1 parent c7a30c8 commit 90ea93b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

library/core/src/slice/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -3076,6 +3076,7 @@ impl<T> [T] {
30763076
/// [`copy_from_slice`]: slice::copy_from_slice
30773077
/// [`split_at_mut`]: slice::split_at_mut
30783078
#[stable(feature = "clone_from_slice", since = "1.7.0")]
3079+
#[track_caller]
30793080
pub fn clone_from_slice(&mut self, src: &[T])
30803081
where
30813082
T: Clone,
@@ -3139,6 +3140,7 @@ impl<T> [T] {
31393140
/// [`split_at_mut`]: slice::split_at_mut
31403141
#[doc(alias = "memcpy")]
31413142
#[stable(feature = "copy_from_slice", since = "1.9.0")]
3143+
#[track_caller]
31423144
pub fn copy_from_slice(&mut self, src: &[T])
31433145
where
31443146
T: Copy,
@@ -3259,6 +3261,7 @@ impl<T> [T] {
32593261
///
32603262
/// [`split_at_mut`]: slice::split_at_mut
32613263
#[stable(feature = "swap_with_slice", since = "1.27.0")]
3264+
#[track_caller]
32623265
pub fn swap_with_slice(&mut self, other: &mut [T]) {
32633266
assert!(self.len() == other.len(), "destination and source slices have different lengths");
32643267
// SAFETY: `self` is valid for `self.len()` elements by definition, and `src` was
@@ -3581,6 +3584,7 @@ impl<T> CloneFromSpec<T> for [T]
35813584
where
35823585
T: Clone,
35833586
{
3587+
#[track_caller]
35843588
default fn spec_clone_from(&mut self, src: &[T]) {
35853589
assert!(self.len() == src.len(), "destination and source slices have different lengths");
35863590
// NOTE: We need to explicitly slice them to the same length
@@ -3598,6 +3602,7 @@ impl<T> CloneFromSpec<T> for [T]
35983602
where
35993603
T: Copy,
36003604
{
3605+
#[track_caller]
36013606
fn spec_clone_from(&mut self, src: &[T]) {
36023607
self.copy_from_slice(src);
36033608
}

0 commit comments

Comments
 (0)