@@ -103,6 +103,7 @@ pub struct VecDeque<
103
103
104
104
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
105
105
impl < T : Clone , A : Allocator + Clone > Clone for VecDeque < T , A > {
106
+ #[ track_caller]
106
107
fn clone ( & self ) -> Self {
107
108
let mut deq = Self :: with_capacity_in ( self . len ( ) , self . allocator ( ) . clone ( ) ) ;
108
109
deq. extend ( self . iter ( ) . cloned ( ) ) ;
@@ -113,6 +114,7 @@ impl<T: Clone, A: Allocator + Clone> Clone for VecDeque<T, A> {
113
114
///
114
115
/// This method is preferred over simply assigning `source.clone()` to `self`,
115
116
/// as it avoids reallocation if possible.
117
+ #[ track_caller]
116
118
fn clone_from ( & mut self , source : & Self ) {
117
119
self . clear ( ) ;
118
120
self . extend ( source. iter ( ) . cloned ( ) ) ;
@@ -490,6 +492,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
490
492
/// Frobs the head and tail sections around to handle the fact that we
491
493
/// just reallocated. Unsafe because it trusts old_capacity.
492
494
#[ inline]
495
+ #[ track_caller]
493
496
unsafe fn handle_capacity_increase ( & mut self , old_capacity : usize ) {
494
497
let new_capacity = self . capacity ( ) ;
495
498
debug_assert ! ( new_capacity >= old_capacity) ;
@@ -570,6 +573,7 @@ impl<T> VecDeque<T> {
570
573
#[ inline]
571
574
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
572
575
#[ must_use]
576
+ #[ track_caller]
573
577
pub fn with_capacity ( capacity : usize ) -> VecDeque < T > {
574
578
Self :: with_capacity_in ( capacity, Global )
575
579
}
@@ -625,6 +629,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
625
629
/// let deque: VecDeque<u32> = VecDeque::with_capacity(10);
626
630
/// ```
627
631
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
632
+ #[ track_caller]
628
633
pub fn with_capacity_in ( capacity : usize , alloc : A ) -> VecDeque < T , A > {
629
634
VecDeque { head : 0 , len : 0 , buf : RawVec :: with_capacity_in ( capacity, alloc) }
630
635
}
@@ -789,6 +794,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
789
794
///
790
795
/// [`reserve`]: VecDeque::reserve
791
796
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
797
+ #[ track_caller]
792
798
pub fn reserve_exact ( & mut self , additional : usize ) {
793
799
let new_cap = self . len . checked_add ( additional) . expect ( "capacity overflow" ) ;
794
800
let old_cap = self . capacity ( ) ;
@@ -818,6 +824,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
818
824
/// assert!(buf.capacity() >= 11);
819
825
/// ```
820
826
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
827
+ #[ track_caller]
821
828
pub fn reserve ( & mut self , additional : usize ) {
822
829
let new_cap = self . len . checked_add ( additional) . expect ( "capacity overflow" ) ;
823
830
let old_cap = self . capacity ( ) ;
@@ -949,6 +956,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
949
956
/// assert!(buf.capacity() >= 4);
950
957
/// ```
951
958
#[ stable( feature = "deque_extras_15" , since = "1.5.0" ) ]
959
+ #[ track_caller]
952
960
pub fn shrink_to_fit ( & mut self ) {
953
961
self . shrink_to ( 0 ) ;
954
962
}
@@ -974,6 +982,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
974
982
/// assert!(buf.capacity() >= 4);
975
983
/// ```
976
984
#[ stable( feature = "shrink_to" , since = "1.56.0" ) ]
985
+ #[ track_caller]
977
986
pub fn shrink_to ( & mut self , min_capacity : usize ) {
978
987
let target_cap = min_capacity. max ( self . len ) ;
979
988
@@ -1739,6 +1748,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
1739
1748
/// assert_eq!(d.front(), Some(&2));
1740
1749
/// ```
1741
1750
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1751
+ #[ track_caller]
1742
1752
pub fn push_front ( & mut self , value : T ) {
1743
1753
if self . is_full ( ) {
1744
1754
self . grow ( ) ;
@@ -1766,6 +1776,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
1766
1776
/// ```
1767
1777
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1768
1778
#[ rustc_confusables( "push" , "put" , "append" ) ]
1779
+ #[ track_caller]
1769
1780
pub fn push_back ( & mut self , value : T ) {
1770
1781
if self . is_full ( ) {
1771
1782
self . grow ( ) ;
@@ -1875,6 +1886,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
1875
1886
/// assert_eq!(vec_deque, &['a', 'd', 'b', 'c']);
1876
1887
/// ```
1877
1888
#[ stable( feature = "deque_extras_15" , since = "1.5.0" ) ]
1889
+ #[ track_caller]
1878
1890
pub fn insert ( & mut self , index : usize , value : T ) {
1879
1891
assert ! ( index <= self . len( ) , "index out of bounds" ) ;
1880
1892
if self . is_full ( ) {
@@ -1978,6 +1990,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
1978
1990
#[ inline]
1979
1991
#[ must_use = "use `.truncate()` if you don't need the other half" ]
1980
1992
#[ stable( feature = "split_off" , since = "1.4.0" ) ]
1993
+ #[ track_caller]
1981
1994
pub fn split_off ( & mut self , at : usize ) -> Self
1982
1995
where
1983
1996
A : Clone ,
@@ -2044,6 +2057,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
2044
2057
/// ```
2045
2058
#[ inline]
2046
2059
#[ stable( feature = "append" , since = "1.4.0" ) ]
2060
+ #[ track_caller]
2047
2061
pub fn append ( & mut self , other : & mut Self ) {
2048
2062
if T :: IS_ZST {
2049
2063
self . len = self . len . checked_add ( other. len ) . expect ( "capacity overflow" ) ;
@@ -2166,6 +2180,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
2166
2180
// be called in cold paths.
2167
2181
// This may panic or abort
2168
2182
#[ inline( never) ]
2183
+ #[ track_caller]
2169
2184
fn grow ( & mut self ) {
2170
2185
// Extend or possibly remove this assertion when valid use-cases for growing the
2171
2186
// buffer without it being full emerge
@@ -2204,6 +2219,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
2204
2219
/// assert_eq!(buf, [5, 10, 101, 102, 103]);
2205
2220
/// ```
2206
2221
#[ stable( feature = "vec_resize_with" , since = "1.33.0" ) ]
2222
+ #[ track_caller]
2207
2223
pub fn resize_with ( & mut self , new_len : usize , generator : impl FnMut ( ) -> T ) {
2208
2224
let len = self . len ;
2209
2225
@@ -2750,6 +2766,7 @@ impl<T: Clone, A: Allocator> VecDeque<T, A> {
2750
2766
/// assert_eq!(buf, [5, 10, 20, 20, 20]);
2751
2767
/// ```
2752
2768
#[ stable( feature = "deque_extras" , since = "1.16.0" ) ]
2769
+ #[ track_caller]
2753
2770
pub fn resize ( & mut self , new_len : usize , value : T ) {
2754
2771
if new_len > self . len ( ) {
2755
2772
let extra = new_len - self . len ( ) ;
@@ -2869,6 +2886,7 @@ impl<T, A: Allocator> IndexMut<usize> for VecDeque<T, A> {
2869
2886
2870
2887
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2871
2888
impl < T > FromIterator < T > for VecDeque < T > {
2889
+ #[ track_caller]
2872
2890
fn from_iter < I : IntoIterator < Item = T > > ( iter : I ) -> VecDeque < T > {
2873
2891
SpecFromIter :: spec_from_iter ( iter. into_iter ( ) )
2874
2892
}
@@ -2908,16 +2926,19 @@ impl<'a, T, A: Allocator> IntoIterator for &'a mut VecDeque<T, A> {
2908
2926
2909
2927
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2910
2928
impl < T , A : Allocator > Extend < T > for VecDeque < T , A > {
2929
+ #[ track_caller]
2911
2930
fn extend < I : IntoIterator < Item = T > > ( & mut self , iter : I ) {
2912
2931
<Self as SpecExtend < T , I :: IntoIter > >:: spec_extend ( self , iter. into_iter ( ) ) ;
2913
2932
}
2914
2933
2915
2934
#[ inline]
2935
+ #[ track_caller]
2916
2936
fn extend_one ( & mut self , elem : T ) {
2917
2937
self . push_back ( elem) ;
2918
2938
}
2919
2939
2920
2940
#[ inline]
2941
+ #[ track_caller]
2921
2942
fn extend_reserve ( & mut self , additional : usize ) {
2922
2943
self . reserve ( additional) ;
2923
2944
}
@@ -2933,16 +2954,19 @@ impl<T, A: Allocator> Extend<T> for VecDeque<T, A> {
2933
2954
2934
2955
#[ stable( feature = "extend_ref" , since = "1.2.0" ) ]
2935
2956
impl < ' a , T : ' a + Copy , A : Allocator > Extend < & ' a T > for VecDeque < T , A > {
2957
+ #[ track_caller]
2936
2958
fn extend < I : IntoIterator < Item = & ' a T > > ( & mut self , iter : I ) {
2937
2959
self . spec_extend ( iter. into_iter ( ) ) ;
2938
2960
}
2939
2961
2940
2962
#[ inline]
2963
+ #[ track_caller]
2941
2964
fn extend_one ( & mut self , & elem: & ' a T ) {
2942
2965
self . push_back ( elem) ;
2943
2966
}
2944
2967
2945
2968
#[ inline]
2969
+ #[ track_caller]
2946
2970
fn extend_reserve ( & mut self , additional : usize ) {
2947
2971
self . reserve ( additional) ;
2948
2972
}
@@ -3040,6 +3064,7 @@ impl<T, const N: usize> From<[T; N]> for VecDeque<T> {
3040
3064
/// let deq2: VecDeque<_> = [1, 2, 3, 4].into();
3041
3065
/// assert_eq!(deq1, deq2);
3042
3066
/// ```
3067
+ #[ track_caller]
3043
3068
fn from ( arr : [ T ; N ] ) -> Self {
3044
3069
let mut deq = VecDeque :: with_capacity ( N ) ;
3045
3070
let arr = ManuallyDrop :: new ( arr) ;
0 commit comments