]> git.lizzy.rs Git - rust.git/commitdiff
Merge remote-tracking branch 'upstream/master' into box-alloc
authorTim Diekmann <tim.diekmann@3dvision.de>
Sun, 25 Oct 2020 15:32:28 +0000 (16:32 +0100)
committerTim Diekmann <tim.diekmann@3dvision.de>
Sun, 25 Oct 2020 15:32:28 +0000 (16:32 +0100)
1  2 
library/alloc/src/alloc.rs
library/alloc/src/collections/btree/node.rs
library/alloc/src/raw_vec.rs
library/alloc/src/sync.rs
src/test/ui/issues/issue-41974.stderr

Simple merge
index a60e676fda557051fc7b53c1e5bb11119633dcaa,657b568e7f6f6b5cd35770f85334fe9128ad87d3..a4240308bb35fec34f630518235b16c337b99c02
@@@ -111,36 -111,12 +111,37 @@@ impl<T> RawVec<T, Global> 
      pub unsafe fn from_raw_parts(ptr: *mut T, capacity: usize) -> Self {
          unsafe { Self::from_raw_parts_in(ptr, capacity, Global) }
      }
-     #[allow_internal_unstable(const_fn)]
 +}
 +
 +impl<T, A: AllocRef> RawVec<T, A> {
 +    /// Like `new`, but parameterized over the choice of allocator for
 +    /// the returned `RawVec`.
++    #[cfg_attr(not(bootstrap), rustc_allow_const_fn_unstable(const_fn))]
++    #[cfg_attr(bootstrap, allow_internal_unstable(const_fn))]
 +    pub const fn new_in(alloc: A) -> Self {
 +        // `cap: 0` means "unallocated". zero-sized types are ignored.
 +        Self { ptr: Unique::dangling(), cap: 0, alloc }
 +    }
 +
 +    /// Like `with_capacity`, but parameterized over the choice of
 +    /// allocator for the returned `RawVec`.
 +    #[inline]
 +    pub fn with_capacity_in(capacity: usize, alloc: A) -> Self {
 +        Self::allocate_in(capacity, AllocInit::Uninitialized, alloc)
 +    }
 +
 +    /// Like `with_capacity_zeroed`, but parameterized over the choice
 +    /// of allocator for the returned `RawVec`.
 +    #[inline]
 +    pub fn with_capacity_zeroed_in(capacity: usize, alloc: A) -> Self {
 +        Self::allocate_in(capacity, AllocInit::Zeroed, alloc)
 +    }
  
      /// Converts a `Box<[T]>` into a `RawVec<T>`.
 -    pub fn from_box(slice: Box<[T]>) -> Self {
 +    pub fn from_box(slice: Box<[T], A>) -> Self {
          unsafe {
 -            let mut slice = ManuallyDrop::new(slice);
 -            RawVec::from_raw_parts(slice.as_mut_ptr(), slice.len())
 +            let (slice, alloc) = Box::into_raw_with_alloc(slice);
 +            RawVec::from_raw_parts_in(slice.as_mut_ptr(), slice.len(), alloc)
          }
      }
  
Simple merge
Simple merge