@@ -107,6 +107,7 @@ pub struct VecDeque<
107
107
108
108
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
109
109
impl < T : Clone , A : Allocator + Clone > Clone for VecDeque < T , A > {
110
+ #[ track_caller]
110
111
fn clone ( & self ) -> Self {
111
112
let mut deq = Self :: with_capacity_in ( self . len ( ) , self . allocator ( ) . clone ( ) ) ;
112
113
deq. extend ( self . iter ( ) . cloned ( ) ) ;
@@ -117,6 +118,7 @@ impl<T: Clone, A: Allocator + Clone> Clone for VecDeque<T, A> {
117
118
///
118
119
/// This method is preferred over simply assigning `source.clone()` to `self`,
119
120
/// as it avoids reallocation if possible.
121
+ #[ track_caller]
120
122
fn clone_from ( & mut self , source : & Self ) {
121
123
self . clear ( ) ;
122
124
self . extend ( source. iter ( ) . cloned ( ) ) ;
@@ -480,6 +482,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
480
482
/// Frobs the head and tail sections around to handle the fact that we
481
483
/// just reallocated. Unsafe because it trusts old_capacity.
482
484
#[ inline]
485
+ #[ track_caller]
483
486
unsafe fn handle_capacity_increase ( & mut self , old_capacity : usize ) {
484
487
let new_capacity = self . capacity ( ) ;
485
488
debug_assert ! ( new_capacity >= old_capacity) ;
@@ -560,6 +563,7 @@ impl<T> VecDeque<T> {
560
563
#[ inline]
561
564
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
562
565
#[ must_use]
566
+ #[ track_caller]
563
567
pub fn with_capacity ( capacity : usize ) -> VecDeque < T > {
564
568
Self :: with_capacity_in ( capacity, Global )
565
569
}
@@ -615,6 +619,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
615
619
/// let deque: VecDeque<u32> = VecDeque::with_capacity(10);
616
620
/// ```
617
621
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
622
+ #[ track_caller]
618
623
pub fn with_capacity_in ( capacity : usize , alloc : A ) -> VecDeque < T , A > {
619
624
VecDeque { head : 0 , len : 0 , buf : RawVec :: with_capacity_in ( capacity, alloc) }
620
625
}
@@ -779,6 +784,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
779
784
///
780
785
/// [`reserve`]: VecDeque::reserve
781
786
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
787
+ #[ track_caller]
782
788
pub fn reserve_exact ( & mut self , additional : usize ) {
783
789
let new_cap = self . len . checked_add ( additional) . expect ( "capacity overflow" ) ;
784
790
let old_cap = self . capacity ( ) ;
@@ -808,6 +814,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
808
814
/// assert!(buf.capacity() >= 11);
809
815
/// ```
810
816
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
817
+ #[ track_caller]
811
818
pub fn reserve ( & mut self , additional : usize ) {
812
819
let new_cap = self . len . checked_add ( additional) . expect ( "capacity overflow" ) ;
813
820
let old_cap = self . capacity ( ) ;
@@ -939,6 +946,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
939
946
/// assert!(buf.capacity() >= 4);
940
947
/// ```
941
948
#[ stable( feature = "deque_extras_15" , since = "1.5.0" ) ]
949
+ #[ track_caller]
942
950
pub fn shrink_to_fit ( & mut self ) {
943
951
self . shrink_to ( 0 ) ;
944
952
}
@@ -964,6 +972,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
964
972
/// assert!(buf.capacity() >= 4);
965
973
/// ```
966
974
#[ stable( feature = "shrink_to" , since = "1.56.0" ) ]
975
+ #[ track_caller]
967
976
pub fn shrink_to ( & mut self , min_capacity : usize ) {
968
977
let target_cap = min_capacity. max ( self . len ) ;
969
978
@@ -1729,6 +1738,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
1729
1738
/// assert_eq!(d.front(), Some(&2));
1730
1739
/// ```
1731
1740
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1741
+ #[ track_caller]
1732
1742
pub fn push_front ( & mut self , value : T ) {
1733
1743
if self . is_full ( ) {
1734
1744
self . grow ( ) ;
@@ -1756,6 +1766,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
1756
1766
/// ```
1757
1767
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1758
1768
#[ rustc_confusables( "push" , "put" , "append" ) ]
1769
+ #[ track_caller]
1759
1770
pub fn push_back ( & mut self , value : T ) {
1760
1771
if self . is_full ( ) {
1761
1772
self . grow ( ) ;
@@ -1865,6 +1876,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
1865
1876
/// assert_eq!(vec_deque, &['a', 'd', 'b', 'c']);
1866
1877
/// ```
1867
1878
#[ stable( feature = "deque_extras_15" , since = "1.5.0" ) ]
1879
+ #[ track_caller]
1868
1880
pub fn insert ( & mut self , index : usize , value : T ) {
1869
1881
assert ! ( index <= self . len( ) , "index out of bounds" ) ;
1870
1882
if self . is_full ( ) {
@@ -1968,6 +1980,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
1968
1980
#[ inline]
1969
1981
#[ must_use = "use `.truncate()` if you don't need the other half" ]
1970
1982
#[ stable( feature = "split_off" , since = "1.4.0" ) ]
1983
+ #[ track_caller]
1971
1984
pub fn split_off ( & mut self , at : usize ) -> Self
1972
1985
where
1973
1986
A : Clone ,
@@ -2034,6 +2047,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
2034
2047
/// ```
2035
2048
#[ inline]
2036
2049
#[ stable( feature = "append" , since = "1.4.0" ) ]
2050
+ #[ track_caller]
2037
2051
pub fn append ( & mut self , other : & mut Self ) {
2038
2052
if T :: IS_ZST {
2039
2053
self . len = self . len . checked_add ( other. len ) . expect ( "capacity overflow" ) ;
@@ -2156,6 +2170,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
2156
2170
// be called in cold paths.
2157
2171
// This may panic or abort
2158
2172
#[ inline( never) ]
2173
+ #[ track_caller]
2159
2174
fn grow ( & mut self ) {
2160
2175
// Extend or possibly remove this assertion when valid use-cases for growing the
2161
2176
// buffer without it being full emerge
@@ -2194,6 +2209,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
2194
2209
/// assert_eq!(buf, [5, 10, 101, 102, 103]);
2195
2210
/// ```
2196
2211
#[ stable( feature = "vec_resize_with" , since = "1.33.0" ) ]
2212
+ #[ track_caller]
2197
2213
pub fn resize_with ( & mut self , new_len : usize , generator : impl FnMut ( ) -> T ) {
2198
2214
let len = self . len ;
2199
2215
@@ -2740,6 +2756,7 @@ impl<T: Clone, A: Allocator> VecDeque<T, A> {
2740
2756
/// assert_eq!(buf, [5, 10, 20, 20, 20]);
2741
2757
/// ```
2742
2758
#[ stable( feature = "deque_extras" , since = "1.16.0" ) ]
2759
+ #[ track_caller]
2743
2760
pub fn resize ( & mut self , new_len : usize , value : T ) {
2744
2761
if new_len > self . len ( ) {
2745
2762
let extra = new_len - self . len ( ) ;
@@ -2859,6 +2876,7 @@ impl<T, A: Allocator> IndexMut<usize> for VecDeque<T, A> {
2859
2876
2860
2877
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2861
2878
impl < T > FromIterator < T > for VecDeque < T > {
2879
+ #[ track_caller]
2862
2880
fn from_iter < I : IntoIterator < Item = T > > ( iter : I ) -> VecDeque < T > {
2863
2881
SpecFromIter :: spec_from_iter ( iter. into_iter ( ) )
2864
2882
}
@@ -2898,33 +2916,39 @@ impl<'a, T, A: Allocator> IntoIterator for &'a mut VecDeque<T, A> {
2898
2916
2899
2917
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2900
2918
impl < T , A : Allocator > Extend < T > for VecDeque < T , A > {
2919
+ #[ track_caller]
2901
2920
fn extend < I : IntoIterator < Item = T > > ( & mut self , iter : I ) {
2902
2921
<Self as SpecExtend < T , I :: IntoIter > >:: spec_extend ( self , iter. into_iter ( ) ) ;
2903
2922
}
2904
2923
2905
2924
#[ inline]
2925
+ #[ track_caller]
2906
2926
fn extend_one ( & mut self , elem : T ) {
2907
2927
self . push_back ( elem) ;
2908
2928
}
2909
2929
2910
2930
#[ inline]
2931
+ #[ track_caller]
2911
2932
fn extend_reserve ( & mut self , additional : usize ) {
2912
2933
self . reserve ( additional) ;
2913
2934
}
2914
2935
}
2915
2936
2916
2937
#[ stable( feature = "extend_ref" , since = "1.2.0" ) ]
2917
2938
impl < ' a , T : ' a + Copy , A : Allocator > Extend < & ' a T > for VecDeque < T , A > {
2939
+ #[ track_caller]
2918
2940
fn extend < I : IntoIterator < Item = & ' a T > > ( & mut self , iter : I ) {
2919
2941
self . spec_extend ( iter. into_iter ( ) ) ;
2920
2942
}
2921
2943
2922
2944
#[ inline]
2945
+ #[ track_caller]
2923
2946
fn extend_one ( & mut self , & elem: & ' a T ) {
2924
2947
self . push_back ( elem) ;
2925
2948
}
2926
2949
2927
2950
#[ inline]
2951
+ #[ track_caller]
2928
2952
fn extend_reserve ( & mut self , additional : usize ) {
2929
2953
self . reserve ( additional) ;
2930
2954
}
@@ -3014,6 +3038,7 @@ impl<T, const N: usize> From<[T; N]> for VecDeque<T> {
3014
3038
/// let deq2: VecDeque<_> = [1, 2, 3, 4].into();
3015
3039
/// assert_eq!(deq1, deq2);
3016
3040
/// ```
3041
+ #[ track_caller]
3017
3042
fn from ( arr : [ T ; N ] ) -> Self {
3018
3043
let mut deq = VecDeque :: with_capacity ( N ) ;
3019
3044
let arr = ManuallyDrop :: new ( arr) ;
0 commit comments