Auto merge of #126557 - GrigorenkoPV:vec_track_caller, r=joboet · qinheping/verify-rust-std@d6318f3 (original) (raw)

`@@ -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());

`

`@@ -570,6 +572,7 @@ impl VecDeque {

`

570

572

`#[inline]

`

571

573

`#[stable(feature = "rust1", since = "1.0.0")]

`

572

574

`#[must_use]

`

``

575

`+

#[track_caller]

`

573

576

`pub fn with_capacity(capacity: usize) -> VecDeque {

`

574

577

`Self::with_capacity_in(capacity, Global)

`

575

578

`}

`

`@@ -625,6 +628,7 @@ impl<T, A: Allocator> VecDeque<T, A> {

`

625

628

`/// let deque: VecDeque = VecDeque::with_capacity(10);

`

626

629

```` /// ```


`627`

`630`

`#[unstable(feature = "allocator_api", issue = "32838")]

`

``

`631`

`+

#[track_caller]

`

`628`

`632`

`pub fn with_capacity_in(capacity: usize, alloc: A) -> VecDeque<T, A> {

`

`629`

`633`

`VecDeque { head: 0, len: 0, buf: RawVec::with_capacity_in(capacity, alloc) }

`

`630`

`634`

`}

`

`@@ -789,6 +793,7 @@ impl<T, A: Allocator> VecDeque<T, A> {

`

`789`

`793`

`///

`

`790`

`794`

`` /// [`reserve`]: VecDeque::reserve

``

`791`

`795`

`#[stable(feature = "rust1", since = "1.0.0")]

`

``

`796`

`+

#[track_caller]

`

`792`

`797`

`pub fn reserve_exact(&mut self, additional: usize) {

`

`793`

`798`

`let new_cap = self.len.checked_add(additional).expect("capacity overflow");

`

`794`

`799`

`let old_cap = self.capacity();

`

`@@ -818,6 +823,7 @@ impl<T, A: Allocator> VecDeque<T, A> {

`

`818`

`823`

`/// assert!(buf.capacity() >= 11);

`

`819`

`824`

```` /// ```

820

825

`#[stable(feature = "rust1", since = "1.0.0")]

`

``

826

`+

#[track_caller]

`

821

827

`pub fn reserve(&mut self, additional: usize) {

`

822

828

`let new_cap = self.len.checked_add(additional).expect("capacity overflow");

`

823

829

`let old_cap = self.capacity();

`

`@@ -949,6 +955,7 @@ impl<T, A: Allocator> VecDeque<T, A> {

`

949

955

`/// assert!(buf.capacity() >= 4);

`

950

956

```` /// ```


`951`

`957`

`#[stable(feature = "deque_extras_15", since = "1.5.0")]

`

``

`958`

`+

#[track_caller]

`

`952`

`959`

`pub fn shrink_to_fit(&mut self) {

`

`953`

`960`

`self.shrink_to(0);

`

`954`

`961`

`}

`

`@@ -974,6 +981,7 @@ impl<T, A: Allocator> VecDeque<T, A> {

`

`974`

`981`

`/// assert!(buf.capacity() >= 4);

`

`975`

`982`

```` /// ```

976

983

`#[stable(feature = "shrink_to", since = "1.56.0")]

`

``

984

`+

#[track_caller]

`

977

985

`pub fn shrink_to(&mut self, min_capacity: usize) {

`

978

986

`let target_cap = min_capacity.max(self.len);

`

979

987

``

`@@ -1740,6 +1748,7 @@ impl<T, A: Allocator> VecDeque<T, A> {

`

1740

1748

`/// assert_eq!(d.front(), Some(&2));

`

1741

1749

```` /// ```


`1742`

`1750`

`#[stable(feature = "rust1", since = "1.0.0")]

`

``

`1751`

`+

#[track_caller]

`

`1743`

`1752`

`pub fn push_front(&mut self, value: T) {

`

`1744`

`1753`

`if self.is_full() {

`

`1745`

`1754`

`self.grow();

`

`@@ -1767,6 +1776,7 @@ impl<T, A: Allocator> VecDeque<T, A> {

`

`1767`

`1776`

```` /// ```

1768

1777

`#[stable(feature = "rust1", since = "1.0.0")]

`

1769

1778

`#[rustc_confusables("push", "put", "append")]

`

``

1779

`+

#[track_caller]

`

1770

1780

`pub fn push_back(&mut self, value: T) {

`

1771

1781

`if self.is_full() {

`

1772

1782

`self.grow();

`

`@@ -1876,6 +1886,7 @@ impl<T, A: Allocator> VecDeque<T, A> {

`

1876

1886

`/// assert_eq!(vec_deque, &['a', 'd', 'b', 'c']);

`

1877

1887

```` /// ```


`1878`

`1888`

`#[stable(feature = "deque_extras_15", since = "1.5.0")]

`

``

`1889`

`+

#[track_caller]

`

`1879`

`1890`

`pub fn insert(&mut self, index: usize, value: T) {

`

`1880`

`1891`

`assert!(index <= self.len(), "index out of bounds");

`

`1881`

`1892`

`if self.is_full() {

`

`@@ -1979,6 +1990,7 @@ impl<T, A: Allocator> VecDeque<T, A> {

`

`1979`

`1990`

`#[inline]

`

`1980`

`1991`

`` #[must_use = "use `.truncate()` if you don't need the other half"]

``

`1981`

`1992`

`#[stable(feature = "split_off", since = "1.4.0")]

`

``

`1993`

`+

#[track_caller]

`

`1982`

`1994`

`pub fn split_off(&mut self, at: usize) -> Self

`

`1983`

`1995`

`where

`

`1984`

`1996`

`A: Clone,

`

`@@ -2045,6 +2057,7 @@ impl<T, A: Allocator> VecDeque<T, A> {

`

`2045`

`2057`

```` /// ```

2046

2058

`#[inline]

`

2047

2059

`#[stable(feature = "append", since = "1.4.0")]

`

``

2060

`+

#[track_caller]

`

2048

2061

`pub fn append(&mut self, other: &mut Self) {

`

2049

2062

`if T::IS_ZST {

`

2050

2063

`self.len = self.len.checked_add(other.len).expect("capacity overflow");

`

`@@ -2167,6 +2180,7 @@ impl<T, A: Allocator> VecDeque<T, A> {

`

2167

2180

`// be called in cold paths.

`

2168

2181

`// This may panic or abort

`

2169

2182

`#[inline(never)]

`

``

2183

`+

#[track_caller]

`

2170

2184

`fn grow(&mut self) {

`

2171

2185

`// Extend or possibly remove this assertion when valid use-cases for growing the

`

2172

2186

`// buffer without it being full emerge

`

`@@ -2205,6 +2219,7 @@ impl<T, A: Allocator> VecDeque<T, A> {

`

2205

2219

`/// assert_eq!(buf, [5, 10, 101, 102, 103]);

`

2206

2220

```` /// ```


`2207`

`2221`

`#[stable(feature = "vec_resize_with", since = "1.33.0")]

`

``

`2222`

`+

#[track_caller]

`

`2208`

`2223`

`pub fn resize_with(&mut self, new_len: usize, generator: impl FnMut() -> T) {

`

`2209`

`2224`

`let len = self.len;

`

`2210`

`2225`

``

`@@ -2751,6 +2766,7 @@ impl<T: Clone, A: Allocator> VecDeque<T, A> {

`

`2751`

`2766`

`/// assert_eq!(buf, [5, 10, 20, 20, 20]);

`

`2752`

`2767`

```` /// ```

2753

2768

`#[stable(feature = "deque_extras", since = "1.16.0")]

`

``

2769

`+

#[track_caller]

`

2754

2770

`pub fn resize(&mut self, new_len: usize, value: T) {

`

2755

2771

`if new_len > self.len() {

`

2756

2772

`let extra = new_len - self.len();

`

`@@ -2870,6 +2886,7 @@ impl<T, A: Allocator> IndexMut for VecDeque<T, A> {

`

2870

2886

``

2871

2887

`#[stable(feature = "rust1", since = "1.0.0")]

`

2872

2888

`impl FromIterator for VecDeque {

`

``

2889

`+

#[track_caller]

`

2873

2890

`fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> VecDeque {

`

2874

2891

`SpecFromIter::spec_from_iter(iter.into_iter())

`

2875

2892

`}

`

`@@ -2909,16 +2926,19 @@ impl<'a, T, A: Allocator> IntoIterator for &'a mut VecDeque<T, A> {

`

2909

2926

``

2910

2927

`#[stable(feature = "rust1", since = "1.0.0")]

`

2911

2928

`impl<T, A: Allocator> Extend for VecDeque<T, A> {

`

``

2929

`+

#[track_caller]

`

2912

2930

`fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {

`

2913

2931

` <Self as SpecExtend<T, I::IntoIter>>::spec_extend(self, iter.into_iter());

`

2914

2932

`}

`

2915

2933

``

2916

2934

`#[inline]

`

``

2935

`+

#[track_caller]

`

2917

2936

`fn extend_one(&mut self, elem: T) {

`

2918

2937

`self.push_back(elem);

`

2919

2938

`}

`

2920

2939

``

2921

2940

`#[inline]

`

``

2941

`+

#[track_caller]

`

2922

2942

`fn extend_reserve(&mut self, additional: usize) {

`

2923

2943

`self.reserve(additional);

`

2924

2944

`}

`

`@@ -2934,16 +2954,19 @@ impl<T, A: Allocator> Extend for VecDeque<T, A> {

`

2934

2954

``

2935

2955

`#[stable(feature = "extend_ref", since = "1.2.0")]

`

2936

2956

`impl<'a, T: 'a + Copy, A: Allocator> Extend<&'a T> for VecDeque<T, A> {

`

``

2957

`+

#[track_caller]

`

2937

2958

`fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) {

`

2938

2959

`self.spec_extend(iter.into_iter());

`

2939

2960

`}

`

2940

2961

``

2941

2962

`#[inline]

`

``

2963

`+

#[track_caller]

`

2942

2964

`fn extend_one(&mut self, &elem: &'a T) {

`

2943

2965

`self.push_back(elem);

`

2944

2966

`}

`

2945

2967

``

2946

2968

`#[inline]

`

``

2969

`+

#[track_caller]

`

2947

2970

`fn extend_reserve(&mut self, additional: usize) {

`

2948

2971

`self.reserve(additional);

`

2949

2972

`}

`

`@@ -3041,6 +3064,7 @@ impl<T, const N: usize> From<[T; N]> for VecDeque {

`

3041

3064

`/// let deq2: VecDeque<_> = [1, 2, 3, 4].into();

`

3042

3065

`/// assert_eq!(deq1, deq2);

`

3043

3066

```` /// ```

````

``

3067

`+

#[track_caller]

`

3044

3068

`fn from(arr: [T; N]) -> Self {

`

3045

3069

`let mut deq = VecDeque::with_capacity(N);

`

3046

3070

`let arr = ManuallyDrop::new(arr);

`