@@ -52,15 +52,12 @@ impl<T, A: Alloc> RawVec<T, A> {
5252 /// Like `new`, but parameterized over the choice of allocator for
5353 /// the returned `RawVec`.
5454 pub const fn new_in ( a : A ) -> Self {
55- // `!0` is `usize::MAX`. This branch should be stripped at compile time.
56- // FIXME(mark-i-m): use this line when `if`s are allowed in `const`:
57- //let cap = if mem::size_of::<T>() == 0 { !0 } else { 0 };
55+ let cap = if mem:: size_of :: < T > ( ) == 0 { core:: usize:: MAX } else { 0 } ;
5856
5957 // `Unique::empty()` doubles as "unallocated" and "zero-sized allocation".
6058 RawVec {
6159 ptr : Unique :: empty ( ) ,
62- // FIXME(mark-i-m): use `cap` when ifs are allowed in const
63- cap : [ 0 , !0 ] [ ( mem:: size_of :: < T > ( ) == 0 ) as usize ] ,
60+ cap,
6461 a,
6562 }
6663 }
@@ -132,19 +129,7 @@ impl<T> RawVec<T, Global> {
132129 /// `RawVec` with capacity `usize::MAX`. Useful for implementing
133130 /// delayed allocation.
134131 pub const fn new ( ) -> Self {
135- // FIXME(Centril): Reintegrate this with `fn new_in` when we can.
136-
137- // `!0` is `usize::MAX`. This branch should be stripped at compile time.
138- // FIXME(mark-i-m): use this line when `if`s are allowed in `const`:
139- //let cap = if mem::size_of::<T>() == 0 { !0 } else { 0 };
140-
141- // `Unique::empty()` doubles as "unallocated" and "zero-sized allocation".
142- RawVec {
143- ptr : Unique :: empty ( ) ,
144- // FIXME(mark-i-m): use `cap` when ifs are allowed in const
145- cap : [ 0 , !0 ] [ ( mem:: size_of :: < T > ( ) == 0 ) as usize ] ,
146- a : Global ,
147- }
132+ Self :: new_in ( Global )
148133 }
149134
150135 /// Creates a `RawVec` (on the system heap) with exactly the
0 commit comments