diff options
| author | Kornel <kornel@geekhood.net> | 2021-12-15 08:48:26 +0000 |
|---|---|---|
| committer | Kornel <kornel@geekhood.net> | 2021-12-15 08:48:26 +0000 |
| commit | 084ea21f171dacef758817a9ee1c8e058af4effe (patch) | |
| tree | 52ea892f5ffdbb990962fbf8b48bd9f58c4799de | |
| parent | 195e931b02b69bbce1bcf4632f4e2d5603ef006b (diff) | |
| download | rust-084ea21f171dacef758817a9ee1c8e058af4effe.tar.gz rust-084ea21f171dacef758817a9ee1c8e058af4effe.zip | |
Track caller of slice split and swap
| -rw-r--r-- | library/core/src/slice/mod.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 7d5d70f1720..2f14de08dd2 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -583,6 +583,7 @@ impl<T> [T] { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_swap", issue = "83163")] #[inline] + #[track_caller] pub const fn swap(&mut self, a: usize, b: usize) { let _ = &self[a]; let _ = &self[b]; @@ -1499,6 +1500,7 @@ impl<T> [T] { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] + #[track_caller] pub fn split_at(&self, mid: usize) -> (&[T], &[T]) { assert!(mid <= self.len()); // SAFETY: `[ptr; mid]` and `[mid; len]` are inside `self`, which @@ -1529,6 +1531,7 @@ impl<T> [T] { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] + #[track_caller] pub fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T]) { assert!(mid <= self.len()); // SAFETY: `[ptr; mid]` and `[mid; len]` are inside `self`, which @@ -1668,6 +1671,7 @@ impl<T> [T] { /// ``` #[unstable(feature = "split_array", reason = "new API", issue = "90091")] #[inline] + #[track_caller] pub fn split_array_ref<const N: usize>(&self) -> (&[T; N], &[T]) { let (a, b) = self.split_at(N); // SAFETY: a points to [T; N]? Yes it's [T] of length N (checked by split_at) @@ -1699,6 +1703,7 @@ impl<T> [T] { /// ``` #[unstable(feature = "split_array", reason = "new API", issue = "90091")] #[inline] + #[track_caller] pub fn split_array_mut<const N: usize>(&mut self) -> (&mut [T; N], &mut [T]) { let (a, b) = self.split_at_mut(N); // SAFETY: a points to [T; N]? Yes it's [T] of length N (checked by split_at_mut) |
