about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-12-20 11:17:47 +0000
committerbors <bors@rust-lang.org>2019-12-20 11:17:47 +0000
commit6b561b4917e803c4be4ca44d8e552b680cb9e380 (patch)
treefed1db0704735b342d9dec0223eddda023ee514c /src/liballoc
parent696735f71b4408302ba166d148e9d474c51416d2 (diff)
parent3a336c48c3e115ea13c53fc117b95bd9f66f1658 (diff)
downloadrust-6b561b4917e803c4be4ca44d8e552b680cb9e380.tar.gz
rust-6b561b4917e803c4be4ca44d8e552b680cb9e380.zip
Auto merge of #67449 - Centril:rollup-04hvg57, r=Centril
Rollup of 7 pull requests

Successful merges:

 - #66755 (Remove a const-if-hack in RawVec)
 - #67127 (Use structured suggestion for disambiguating method calls)
 - #67219 (Fix up Command Debug output when arg0 is specified.)
 - #67285 (Indicate origin of where type parameter for uninferred types )
 - #67328 (Remove now-redundant range check on u128 -> f32 casts)
 - #67367 (Move command line option definitions into a dedicated file)
 - #67442 (Remove `SOCK_CLOEXEC` dummy variable on platforms that don't use it.)

Failed merges:

r? @ghost
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/lib.rs1
-rw-r--r--src/liballoc/raw_vec.rs21
2 files changed, 4 insertions, 18 deletions
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index 0137275bc15..be46e632be4 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -85,6 +85,7 @@
 #![feature(const_generic_impls_guard)]
 #![feature(const_generics)]
 #![feature(const_in_array_repeat_expressions)]
+#![feature(const_if_match)]
 #![feature(cow_is_borrowed)]
 #![feature(dispatch_from_dyn)]
 #![feature(core_intrinsics)]
diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs
index ee75fc288fe..3201c702abb 100644
--- a/src/liballoc/raw_vec.rs
+++ b/src/liballoc/raw_vec.rs
@@ -52,15 +52,12 @@ impl<T, A: Alloc> RawVec<T, A> {
     /// Like `new`, but parameterized over the choice of allocator for
     /// the returned `RawVec`.
     pub const fn new_in(a: A) -> Self {
-        // `!0` is `usize::MAX`. This branch should be stripped at compile time.
-        // FIXME(mark-i-m): use this line when `if`s are allowed in `const`:
-        //let cap = if mem::size_of::<T>() == 0 { !0 } else { 0 };
+        let cap = if mem::size_of::<T>() == 0 { core::usize::MAX } else { 0 };
 
         // `Unique::empty()` doubles as "unallocated" and "zero-sized allocation".
         RawVec {
             ptr: Unique::empty(),
-            // FIXME(mark-i-m): use `cap` when ifs are allowed in const
-            cap: [0, !0][(mem::size_of::<T>() == 0) as usize],
+            cap,
             a,
         }
     }
@@ -132,19 +129,7 @@ impl<T> RawVec<T, Global> {
     /// `RawVec` with capacity `usize::MAX`. Useful for implementing
     /// delayed allocation.
     pub const fn new() -> Self {
-        // FIXME(Centril): Reintegrate this with `fn new_in` when we can.
-
-        // `!0` is `usize::MAX`. This branch should be stripped at compile time.
-        // FIXME(mark-i-m): use this line when `if`s are allowed in `const`:
-        //let cap = if mem::size_of::<T>() == 0 { !0 } else { 0 };
-
-        // `Unique::empty()` doubles as "unallocated" and "zero-sized allocation".
-        RawVec {
-            ptr: Unique::empty(),
-            // FIXME(mark-i-m): use `cap` when ifs are allowed in const
-            cap: [0, !0][(mem::size_of::<T>() == 0) as usize],
-            a: Global,
-        }
+        Self::new_in(Global)
     }
 
     /// Creates a `RawVec` (on the system heap) with exactly the