@@ -57,13 +57,13 @@ use core::default::Default;
57
57
use core:: fmt;
58
58
use core:: hash:: { self , Hash } ;
59
59
use core:: iter:: { repeat, FromIterator , IntoIterator } ;
60
- use core:: marker:: { self , ContravariantLifetime , InvariantType } ;
60
+ use core:: marker:: PhantomData ;
61
61
use core:: mem;
62
- use core:: nonzero:: NonZero ;
63
62
use core:: num:: { Int , UnsignedInt } ;
64
63
use core:: ops:: { Index , IndexMut , Deref , Add } ;
65
64
use core:: ops;
66
65
use core:: ptr;
66
+ use core:: ptr:: Unique ;
67
67
use core:: raw:: Slice as RawSlice ;
68
68
use core:: slice;
69
69
use core:: usize;
@@ -137,10 +137,9 @@ use core::usize;
137
137
#[ unsafe_no_drop_flag]
138
138
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
139
139
pub struct Vec < T > {
140
- ptr : NonZero < * mut T > ,
140
+ ptr : Unique < T > ,
141
141
len : usize ,
142
142
cap : usize ,
143
- _own : marker:: PhantomData < T > ,
144
143
}
145
144
146
145
unsafe impl < T : Send > Send for Vec < T > { }
@@ -249,10 +248,9 @@ impl<T> Vec<T> {
249
248
pub unsafe fn from_raw_parts ( ptr : * mut T , length : usize ,
250
249
capacity : usize ) -> Vec < T > {
251
250
Vec {
252
- ptr : NonZero :: new ( ptr) ,
251
+ ptr : Unique :: new ( ptr) ,
253
252
len : length,
254
253
cap : capacity,
255
- _own : marker:: PhantomData ,
256
254
}
257
255
}
258
256
@@ -373,7 +371,7 @@ impl<T> Vec<T> {
373
371
self . len * mem:: size_of :: < T > ( ) ,
374
372
mem:: min_align_of :: < T > ( ) ) as * mut T ;
375
373
if ptr. is_null ( ) { :: alloc:: oom ( ) }
376
- self . ptr = NonZero :: new ( ptr) ;
374
+ self . ptr = Unique :: new ( ptr) ;
377
375
}
378
376
self . cap = self . len ;
379
377
}
@@ -655,7 +653,7 @@ impl<T> Vec<T> {
655
653
unsafe {
656
654
let ptr = alloc_or_realloc ( * self . ptr , old_size, size) ;
657
655
if ptr. is_null ( ) { :: alloc:: oom ( ) }
658
- self . ptr = NonZero :: new ( ptr) ;
656
+ self . ptr = Unique :: new ( ptr) ;
659
657
}
660
658
self . cap = max ( self . cap , 2 ) * 2 ;
661
659
}
@@ -756,7 +754,7 @@ impl<T> Vec<T> {
756
754
Drain {
757
755
ptr : begin,
758
756
end : end,
759
- marker : ContravariantLifetime ,
757
+ marker : PhantomData ,
760
758
}
761
759
}
762
760
}
@@ -871,6 +869,8 @@ impl<T> Vec<T> {
871
869
end_t : unsafe { start. offset ( offset) } ,
872
870
start_u : start as * mut U ,
873
871
end_u : start as * mut U ,
872
+
873
+ _marker : PhantomData ,
874
874
} ;
875
875
// start_t
876
876
// start_u
@@ -967,8 +967,7 @@ impl<T> Vec<T> {
967
967
let mut pv = PartialVecZeroSized :: < T , U > {
968
968
num_t : vec. len ( ) ,
969
969
num_u : 0 ,
970
- marker_t : InvariantType ,
971
- marker_u : InvariantType ,
970
+ marker : PhantomData ,
972
971
} ;
973
972
unsafe { mem:: forget ( vec) ; }
974
973
@@ -1226,7 +1225,7 @@ impl<T> Vec<T> {
1226
1225
unsafe {
1227
1226
let ptr = alloc_or_realloc ( * self . ptr , self . cap * mem:: size_of :: < T > ( ) , size) ;
1228
1227
if ptr. is_null ( ) { :: alloc:: oom ( ) }
1229
- self . ptr = NonZero :: new ( ptr) ;
1228
+ self . ptr = Unique :: new ( ptr) ;
1230
1229
}
1231
1230
self . cap = capacity;
1232
1231
}
@@ -1779,10 +1778,10 @@ impl<T> Drop for IntoIter<T> {
1779
1778
#[ unsafe_no_drop_flag]
1780
1779
#[ unstable( feature = "collections" ,
1781
1780
reason = "recently added as part of collections reform 2" ) ]
1782
- pub struct Drain < ' a , T > {
1781
+ pub struct Drain < ' a , T : ' a > {
1783
1782
ptr : * const T ,
1784
1783
end : * const T ,
1785
- marker : ContravariantLifetime < ' a > ,
1784
+ marker : PhantomData < & ' a T > ,
1786
1785
}
1787
1786
1788
1787
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -1867,9 +1866,9 @@ impl<'a, T> Drop for Drain<'a, T> {
1867
1866
1868
1867
/// Wrapper type providing a `&Vec<T>` reference via `Deref`.
1869
1868
#[ unstable( feature = "collections" ) ]
1870
- pub struct DerefVec < ' a , T > {
1869
+ pub struct DerefVec < ' a , T : ' a > {
1871
1870
x : Vec < T > ,
1872
- l : ContravariantLifetime < ' a >
1871
+ l : PhantomData < & ' a T > ,
1873
1872
}
1874
1873
1875
1874
#[ unstable( feature = "collections" ) ]
@@ -1897,7 +1896,7 @@ pub fn as_vec<'a, T>(x: &'a [T]) -> DerefVec<'a, T> {
1897
1896
unsafe {
1898
1897
DerefVec {
1899
1898
x : Vec :: from_raw_parts ( x. as_ptr ( ) as * mut T , x. len ( ) , x. len ( ) ) ,
1900
- l : ContravariantLifetime :: < ' a >
1899
+ l : PhantomData ,
1901
1900
}
1902
1901
}
1903
1902
}
@@ -1921,6 +1920,8 @@ struct PartialVecNonZeroSized<T,U> {
1921
1920
end_u : * mut U ,
1922
1921
start_t : * mut T ,
1923
1922
end_t : * mut T ,
1923
+
1924
+ _marker : PhantomData < U > ,
1924
1925
}
1925
1926
1926
1927
/// An owned, partially type-converted vector of zero-sized elements.
@@ -1930,8 +1931,7 @@ struct PartialVecNonZeroSized<T,U> {
1930
1931
struct PartialVecZeroSized < T , U > {
1931
1932
num_t : usize ,
1932
1933
num_u : usize ,
1933
- marker_t : InvariantType < T > ,
1934
- marker_u : InvariantType < U > ,
1934
+ marker : PhantomData < :: core:: cell:: Cell < ( T , U ) > > ,
1935
1935
}
1936
1936
1937
1937
#[ unsafe_destructor]
0 commit comments