diff --git a/src/liballoc/alloc.rs b/src/liballoc/alloc.rs index 3bd0c243b39ac..550fc4dcb7651 100644 --- a/src/liballoc/alloc.rs +++ b/src/liballoc/alloc.rs @@ -40,10 +40,14 @@ extern "Rust" { /// This type implements the [`Alloc`] trait by forwarding calls /// to the allocator registered with the `#[global_allocator]` attribute /// if there is one, or the `std` crate’s default. +#[cfg(not(test))] #[unstable(feature = "allocator_api", issue = "32838")] #[derive(Copy, Clone, Default, Debug)] pub struct Global; +#[cfg(test)] +pub use std::alloc::Global; + /// Allocate memory with the global allocator. /// /// This function forwards calls to the [`GlobalAlloc::alloc`] method @@ -147,6 +151,7 @@ pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 { __rust_alloc_zeroed(layout.size(), layout.align()) } +#[cfg(not(test))] #[unstable(feature = "allocator_api", issue = "32838")] unsafe impl Alloc for Global { #[inline] @@ -185,25 +190,23 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 { align as *mut u8 } else { let layout = Layout::from_size_align_unchecked(size, align); - let ptr = alloc(layout); - if !ptr.is_null() { - ptr - } else { - handle_alloc_error(layout) + match Global.alloc(layout) { + Ok(ptr) => ptr.as_ptr(), + Err(_) => handle_alloc_error(layout), } } } #[cfg_attr(not(test), lang = "box_free")] #[inline] -pub(crate) unsafe fn box_free(ptr: Unique) { +pub(crate) unsafe fn box_free(ptr: Unique, mut a: A) { let ptr = ptr.as_ptr(); let size = size_of_val(&*ptr); let align = min_align_of_val(&*ptr); // We do not allocate for Box when T is ZST, so deallocation is also not necessary. if size != 0 { let layout = Layout::from_size_align_unchecked(size, align); - dealloc(ptr as *mut u8, layout); + a.dealloc(NonNull::new_unchecked(ptr).cast(), layout); } } diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index f989e701913a5..4eb0b65d0788f 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -81,6 +81,7 @@ use core::ops::{CoerceUnsized, Deref, DerefMut, Generator, GeneratorState}; use core::ptr::{self, NonNull, Unique}; use core::task::{LocalWaker, Poll}; +use alloc::{Alloc, Global, Layout, handle_alloc_error}; use raw_vec::RawVec; use str::from_boxed_utf8_unchecked; @@ -90,7 +91,7 @@ use str::from_boxed_utf8_unchecked; #[lang = "owned_box"] #[fundamental] #[stable(feature = "rust1", since = "1.0.0")] -pub struct Box(Unique); +pub struct Box(Unique, A); impl Box { /// Allocates memory on the heap and then places `x` into it. @@ -115,6 +116,43 @@ impl Box { } } +impl Box { + /// Allocates memory in the given allocator and then places `x` into it. + /// + /// This doesn't actually allocate if `T` is zero-sized. + /// + /// # Examples + /// + /// ``` + /// # #![feature(allocator_api)] + /// use std::alloc::Global; + /// let five = Box::new_in(5, Global); + /// ``` + #[unstable(feature = "allocator_api", issue = "32838")] + #[inline(always)] + pub fn new_in(x: T, a: A) -> Box { + let mut a = a; + let layout = Layout::for_value(&x); + let size = layout.size(); + let ptr = if size == 0 { + Unique::empty() + } else { + unsafe { + let ptr = a.alloc(layout).unwrap_or_else(|_| handle_alloc_error(layout)); + ptr::write(ptr.as_ptr() as *mut T, x); + ptr.cast().into() + } + }; + Box(ptr, a) + } + + #[unstable(feature = "pin", issue = "49150")] + #[inline(always)] + pub fn pinned_in(x: T, a: A) -> Pin> { + Box::new_in(x, a).into() + } +} + impl Box { /// Constructs a box from a raw pointer. /// @@ -141,7 +179,35 @@ impl Box { #[stable(feature = "box_raw", since = "1.4.0")] #[inline] pub unsafe fn from_raw(raw: *mut T) -> Self { - Box(Unique::new_unchecked(raw)) + Box(Unique::new_unchecked(raw), Global) + } +} + +impl Box { + /// Constructs a box from a raw pointer in the given allocator. + /// + /// This is similar to the [`Box::from_raw`] function, but assumes + /// the pointer was allocated with the given allocator. + /// + /// This function is unsafe because improper use may lead to + /// memory problems. For example, specifying the wrong allocator + /// may corrupt the allocator state. + /// + /// [`Box::from_raw`]: struct.Box.html#method.from_raw + /// + /// # Examples + /// + /// ``` + /// # #![feature(allocator_api)] + /// use std::alloc::Global; + /// let x = Box::new_in(5, Global); + /// let ptr = Box::into_raw(x); + /// let x = unsafe { Box::from_raw_in(ptr, Global) }; + /// ``` + #[unstable(feature = "allocator_api", issue = "32838")] + #[inline] + pub unsafe fn from_raw_in(raw: *mut T, a: A) -> Self { + Box(Unique::new_unchecked(raw), a) } /// Consumes the `Box`, returning a wrapped raw pointer. @@ -168,7 +234,7 @@ impl Box { /// ``` #[stable(feature = "box_raw", since = "1.4.0")] #[inline] - pub fn into_raw(b: Box) -> *mut T { + pub fn into_raw(b: Box) -> *mut T { Box::into_raw_non_null(b).as_ptr() } @@ -200,14 +266,14 @@ impl Box { /// ``` #[unstable(feature = "box_into_raw_non_null", issue = "47336")] #[inline] - pub fn into_raw_non_null(b: Box) -> NonNull { + pub fn into_raw_non_null(b: Box) -> NonNull { Box::into_unique(b).into() } #[unstable(feature = "ptr_internals", issue = "0", reason = "use into_raw_non_null instead")] #[inline] #[doc(hidden)] - pub fn into_unique(b: Box) -> Unique { + pub fn into_unique(b: Box) -> Unique { let unique = b.0; mem::forget(b); unique @@ -256,7 +322,7 @@ impl Box { /// ``` #[stable(feature = "box_leak", since = "1.26.0")] #[inline] - pub fn leak<'a>(b: Box) -> &'a mut T + pub fn leak<'a>(b: Box) -> &'a mut T where T: 'a // Technically not needed, but kept to be explicit. { @@ -265,7 +331,7 @@ impl Box { } #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl<#[may_dangle] T: ?Sized> Drop for Box { +unsafe impl<#[may_dangle] T: ?Sized, A: Alloc> Drop for Box { fn drop(&mut self) { // FIXME: Do nothing, drop is currently performed by compiler. } @@ -279,10 +345,18 @@ impl Default for Box { } } +#[unstable(feature = "allocator_api", issue = "32838")] +impl Default for Box { + /// Creates a `Box`, with the `Default` value for T. + default fn default() -> Box { + Box::new_in(Default::default(), Default::default()) + } +} + #[stable(feature = "rust1", since = "1.0.0")] -impl Default for Box<[T]> { - fn default() -> Box<[T]> { - Box::<[T; 0]>::new([]) +impl Default for Box<[T], A> { + fn default() -> Box<[T], A> { + Box::<[T; 0], A>::new_in([], A::default()) } } @@ -326,6 +400,18 @@ impl Clone for Box { } } +#[unstable(feature = "allocator_api", issue = "32838")] +impl Clone for Box { + #[inline] + default fn clone(&self) -> Box { + Box::new_in((**self).clone(), self.1.clone()) + } + + #[inline] + default fn clone_from(&mut self, source: &Box) { + (**self).clone_from(&(**source)); + } +} #[stable(feature = "box_slice_clone", since = "1.3.0")] impl Clone for Box { @@ -340,58 +426,58 @@ impl Clone for Box { } #[stable(feature = "rust1", since = "1.0.0")] -impl PartialEq for Box { +impl PartialEq for Box { #[inline] - fn eq(&self, other: &Box) -> bool { + fn eq(&self, other: &Box) -> bool { PartialEq::eq(&**self, &**other) } #[inline] - fn ne(&self, other: &Box) -> bool { + fn ne(&self, other: &Box) -> bool { PartialEq::ne(&**self, &**other) } } #[stable(feature = "rust1", since = "1.0.0")] -impl PartialOrd for Box { +impl PartialOrd for Box { #[inline] - fn partial_cmp(&self, other: &Box) -> Option { + fn partial_cmp(&self, other: &Box) -> Option { PartialOrd::partial_cmp(&**self, &**other) } #[inline] - fn lt(&self, other: &Box) -> bool { + fn lt(&self, other: &Box) -> bool { PartialOrd::lt(&**self, &**other) } #[inline] - fn le(&self, other: &Box) -> bool { + fn le(&self, other: &Box) -> bool { PartialOrd::le(&**self, &**other) } #[inline] - fn ge(&self, other: &Box) -> bool { + fn ge(&self, other: &Box) -> bool { PartialOrd::ge(&**self, &**other) } #[inline] - fn gt(&self, other: &Box) -> bool { + fn gt(&self, other: &Box) -> bool { PartialOrd::gt(&**self, &**other) } } #[stable(feature = "rust1", since = "1.0.0")] -impl Ord for Box { +impl Ord for Box { #[inline] - fn cmp(&self, other: &Box) -> Ordering { + fn cmp(&self, other: &Box) -> Ordering { Ord::cmp(&**self, &**other) } } #[stable(feature = "rust1", since = "1.0.0")] -impl Eq for Box {} +impl Eq for Box {} #[stable(feature = "rust1", since = "1.0.0")] -impl Hash for Box { +impl Hash for Box { fn hash(&self, state: &mut H) { (**self).hash(state); } } #[stable(feature = "indirect_hasher_impl", since = "1.22.0")] -impl Hasher for Box { +impl Hasher for Box { fn finish(&self) -> u64 { (**self).finish() } @@ -443,10 +529,17 @@ impl From for Box { } } +#[unstable(feature = "allocator_api", issue = "32838")] +impl From for Box { + default fn from(t: T) -> Self { + Box::new_in(t, A::default()) + } +} + #[unstable(feature = "pin", issue = "49150")] -impl From> for Pin> { - fn from(boxed: Box) -> Self { - // It's not possible to move or replace the insides of a `Pin>` +impl From> for Pin> { + fn from(boxed: Box) -> Self { + // It's not possible to move or replace the insides of a `Pin>` // when `T: !Unpin`, so it's safe to pin it directly without any // additional requirements. unsafe { Pin::new_unchecked(boxed) } @@ -454,9 +547,10 @@ impl From> for Pin> { } #[stable(feature = "box_from_slice", since = "1.17.0")] -impl<'a, T: Copy> From<&'a [T]> for Box<[T]> { - fn from(slice: &'a [T]) -> Box<[T]> { - let mut boxed = unsafe { RawVec::with_capacity(slice.len()).into_box() }; +impl<'a, T: Copy, A: Alloc + Default> From<&'a [T]> for Box<[T], A> { + fn from(slice: &'a [T]) -> Box<[T], A> { + let a = A::default(); + let mut boxed = unsafe { RawVec::with_capacity_in(slice.len(), a).into_box() }; boxed.copy_from_slice(slice); boxed } @@ -543,21 +637,21 @@ impl Box { } #[stable(feature = "rust1", since = "1.0.0")] -impl fmt::Display for Box { +impl fmt::Display for Box { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] -impl fmt::Debug for Box { +impl fmt::Debug for Box { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] -impl fmt::Pointer for Box { +impl fmt::Pointer for Box { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // It's not possible to extract the inner Uniq directly from the Box, // instead we cast it to a *const which aliases the Unique @@ -567,7 +661,7 @@ impl fmt::Pointer for Box { } #[stable(feature = "rust1", since = "1.0.0")] -impl Deref for Box { +impl Deref for Box { type Target = T; fn deref(&self) -> &T { @@ -576,14 +670,14 @@ impl Deref for Box { } #[stable(feature = "rust1", since = "1.0.0")] -impl DerefMut for Box { +impl DerefMut for Box { fn deref_mut(&mut self) -> &mut T { &mut **self } } #[stable(feature = "rust1", since = "1.0.0")] -impl Iterator for Box { +impl Iterator for Box { type Item = I::Item; fn next(&mut self) -> Option { (**self).next() @@ -596,13 +690,13 @@ impl Iterator for Box { } } #[stable(feature = "rust1", since = "1.0.0")] -impl DoubleEndedIterator for Box { +impl DoubleEndedIterator for Box { fn next_back(&mut self) -> Option { (**self).next_back() } } #[stable(feature = "rust1", since = "1.0.0")] -impl ExactSizeIterator for Box { +impl ExactSizeIterator for Box { fn len(&self) -> usize { (**self).len() } @@ -612,7 +706,7 @@ impl ExactSizeIterator for Box { } #[stable(feature = "fused", since = "1.26.0")] -impl FusedIterator for Box {} +impl FusedIterator for Box {} /// `FnBox` is a version of the `FnOnce` intended for use with boxed @@ -655,52 +749,52 @@ impl FusedIterator for Box {} #[rustc_paren_sugar] #[unstable(feature = "fnbox", reason = "will be deprecated if and when `Box` becomes usable", issue = "28796")] -pub trait FnBox { +pub trait FnBox { type Output; - fn call_box(self: Box, args: A) -> Self::Output; + fn call_box(self: Box, args: Args) -> Self::Output; } #[unstable(feature = "fnbox", reason = "will be deprecated if and when `Box` becomes usable", issue = "28796")] -impl FnBox for F - where F: FnOnce +impl FnBox for F + where F: FnOnce { type Output = F::Output; - fn call_box(self: Box, args: A) -> F::Output { + fn call_box(self: Box, args: Args) -> F::Output { self.call_once(args) } } #[unstable(feature = "fnbox", reason = "will be deprecated if and when `Box` becomes usable", issue = "28796")] -impl<'a, A, R> FnOnce for Box + 'a> { +impl<'a, Args, R, A: Alloc> FnOnce for Box + 'a, A> { type Output = R; - extern "rust-call" fn call_once(self, args: A) -> R { + extern "rust-call" fn call_once(self, args: Args) -> R { self.call_box(args) } } #[unstable(feature = "fnbox", reason = "will be deprecated if and when `Box` becomes usable", issue = "28796")] -impl<'a, A, R> FnOnce for Box + Send + 'a> { +impl<'a, Args, R, A: Alloc> FnOnce for Box + Send + 'a, A> { type Output = R; - extern "rust-call" fn call_once(self, args: A) -> R { + extern "rust-call" fn call_once(self, args: Args) -> R { self.call_box(args) } } #[unstable(feature = "coerce_unsized", issue = "27732")] -impl, U: ?Sized> CoerceUnsized> for Box {} +impl, U: ?Sized, A: Alloc> CoerceUnsized> for Box {} #[stable(feature = "box_slice_clone", since = "1.3.0")] -impl Clone for Box<[T]> { +impl Clone for Box<[T], A> { fn clone(&self) -> Self { let mut new = BoxBuilder { - data: RawVec::with_capacity(self.len()), + data: RawVec::with_capacity_in(self.len(), self.1.clone()), len: 0, }; @@ -718,20 +812,20 @@ impl Clone for Box<[T]> { return unsafe { new.into_box() }; // Helper type for responding to panics correctly. - struct BoxBuilder { - data: RawVec, + struct BoxBuilder { + data: RawVec, len: usize, } - impl BoxBuilder { - unsafe fn into_box(self) -> Box<[T]> { + impl BoxBuilder { + unsafe fn into_box(self) -> Box<[T], A> { let raw = ptr::read(&self.data); mem::forget(self); raw.into_box() } } - impl Drop for BoxBuilder { + impl Drop for BoxBuilder { fn drop(&mut self) { let mut data = self.data.ptr(); let max = unsafe { data.add(self.len) }; @@ -748,28 +842,28 @@ impl Clone for Box<[T]> { } #[stable(feature = "box_borrow", since = "1.1.0")] -impl borrow::Borrow for Box { +impl borrow::Borrow for Box { fn borrow(&self) -> &T { &**self } } #[stable(feature = "box_borrow", since = "1.1.0")] -impl borrow::BorrowMut for Box { +impl borrow::BorrowMut for Box { fn borrow_mut(&mut self) -> &mut T { &mut **self } } #[stable(since = "1.5.0", feature = "smart_ptr_as_ref")] -impl AsRef for Box { +impl AsRef for Box { fn as_ref(&self) -> &T { &**self } } #[stable(since = "1.5.0", feature = "smart_ptr_as_ref")] -impl AsMut for Box { +impl AsMut for Box { fn as_mut(&mut self) -> &mut T { &mut **self } @@ -798,10 +892,10 @@ impl AsMut for Box { * could have a method to project a Pin from it. */ #[unstable(feature = "pin", issue = "49150")] -impl Unpin for Box { } +impl Unpin for Box { } #[unstable(feature = "generator_trait", issue = "43122")] -impl Generator for Box +impl Generator for Box where T: Generator + ?Sized { type Yield = T::Yield; @@ -812,7 +906,7 @@ impl Generator for Box } #[unstable(feature = "futures_api", issue = "50547")] -impl Future for Box { +impl Future for Box { type Output = F::Output; fn poll(mut self: Pin<&mut Self>, lw: &LocalWaker) -> Poll { diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index 837770feecef5..ea0a21450d92d 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -693,8 +693,8 @@ impl RawVec { } -impl RawVec { - /// Converts the entire buffer into `Box<[T]>`. +impl RawVec { + /// Converts the entire buffer into `Box<[T], A>`. /// /// While it is not *strictly* Undefined Behavior to call /// this procedure while some of the RawVec is uninitialized, @@ -702,10 +702,11 @@ impl RawVec { /// /// Note that this will correctly reconstitute any `cap` changes /// that may have been performed. (see description of type for details) - pub unsafe fn into_box(self) -> Box<[T]> { + pub unsafe fn into_box(self) -> Box<[T], A> { // NOTE: not calling `cap()` here, actually using the real `cap` field! let slice = slice::from_raw_parts_mut(self.ptr(), self.cap); - let output: Box<[T]> = Box::from_raw(slice); + let a = ptr::read(&self.a); + let output: Box<[T], A> = Box::from_raw_in(slice, a); mem::forget(self); output } diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 40bb2faa3623b..9ebcf6941fecd 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -697,7 +697,7 @@ impl Rc { value_size); // Free the allocation without dropping its contents - box_free(box_unique); + box_free(box_unique, Global); Rc { ptr: NonNull::new_unchecked(ptr), phantom: PhantomData } } diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 35935861fb182..1809a00ea42aa 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -598,7 +598,7 @@ impl Arc { value_size); // Free the allocation without dropping its contents - box_free(box_unique); + box_free(box_unique, Global); Arc { ptr: NonNull::new_unchecked(ptr), phantom: PhantomData } } diff --git a/src/test/mir-opt/validate_2.rs b/src/test/mir-opt/validate_2.rs index 3776a11b3ab82..46f0aaad47ce0 100644 --- a/src/test/mir-opt/validate_2.rs +++ b/src/test/mir-opt/validate_2.rs @@ -22,14 +22,14 @@ fn main() { // fn main() -> () { // ... // bb1: { -// Validate(Acquire, [_2: std::boxed::Box<[i32; 3]>]); -// Validate(Release, [_2: std::boxed::Box<[i32; 3]>]); -// _1 = move _2 as std::boxed::Box<[i32]> (Unsize); -// Validate(Acquire, [_1: std::boxed::Box<[i32]>]); +// Validate(Acquire, [_2: std::boxed::Box<[i32; 3], std::alloc::Global>]); +// Validate(Release, [_2: std::boxed::Box<[i32; 3], std::alloc::Global>]); +// _1 = move _2 as std::boxed::Box<[i32], std::alloc::Global> (Unsize); +// Validate(Acquire, [_1: std::boxed::Box<[i32], std::alloc::Global>]); // StorageDead(_2); // StorageDead(_3); // _0 = (); -// Validate(Release, [_1: std::boxed::Box<[i32]>]); +// Validate(Release, [_1: std::boxed::Box<[i32], std::alloc::Global>]); // drop(_1) -> [return: bb2, unwind: bb3]; // } // ... diff --git a/src/test/ui/e0119/conflict-with-std.stderr b/src/test/ui/e0119/conflict-with-std.stderr index e8b2c84c0df0b..72db200637f6a 100644 --- a/src/test/ui/e0119/conflict-with-std.stderr +++ b/src/test/ui/e0119/conflict-with-std.stderr @@ -5,8 +5,8 @@ LL | impl AsRef for Box { //~ ERROR conflicting implementations | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `alloc`: - - impl std::convert::AsRef for std::boxed::Box - where T: ?Sized; + - impl std::convert::AsRef for std::boxed::Box + where A: std::alloc::Alloc, T: ?Sized; error[E0119]: conflicting implementations of trait `std::convert::From` for type `S`: --> $DIR/conflict-with-std.rs:24:1 diff --git a/src/test/ui/issues/issue-14092.rs b/src/test/ui/issues/issue-14092.rs index fdce4b7a31dfb..1d5fb7f850afe 100644 --- a/src/test/ui/issues/issue-14092.rs +++ b/src/test/ui/issues/issue-14092.rs @@ -9,6 +9,6 @@ // except according to those terms. fn fn1(0: Box) {} - //~^ ERROR wrong number of type arguments: expected 1, found 0 [E0107] + //~^ ERROR wrong number of type arguments: expected at least 1, found 0 [E0107] fn main() {} diff --git a/src/test/ui/issues/issue-14092.stderr b/src/test/ui/issues/issue-14092.stderr index 98f18d7544881..fc1b14a2515b0 100644 --- a/src/test/ui/issues/issue-14092.stderr +++ b/src/test/ui/issues/issue-14092.stderr @@ -1,8 +1,8 @@ -error[E0107]: wrong number of type arguments: expected 1, found 0 +error[E0107]: wrong number of type arguments: expected at least 1, found 0 --> $DIR/issue-14092.rs:11:11 | LL | fn fn1(0: Box) {} - | ^^^ expected 1 type argument + | ^^^ expected at least 1 type argument error: aborting due to previous error diff --git a/src/test/ui/issues/issue-41974.stderr b/src/test/ui/issues/issue-41974.stderr index eca40ed43557d..ae32be16befe0 100644 --- a/src/test/ui/issues/issue-41974.stderr +++ b/src/test/ui/issues/issue-41974.stderr @@ -1,13 +1,13 @@ -error[E0119]: conflicting implementations of trait `std::ops::Drop` for type `std::boxed::Box<_>`: +error[E0119]: conflicting implementations of trait `std::ops::Drop` for type `std::boxed::Box<_, _>`: --> $DIR/issue-41974.rs:17:1 | LL | impl Drop for T where T: A { //~ ERROR E0119 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `alloc`: - - impl std::ops::Drop for std::boxed::Box - where T: ?Sized; - = note: downstream crates may implement trait `A` for type `std::boxed::Box<_>` + - impl std::ops::Drop for std::boxed::Box + where A: std::alloc::Alloc, T: ?Sized; + = note: downstream crates may implement trait `A` for type `std::boxed::Box<_, _>` error[E0120]: the Drop trait may only be implemented on structures --> $DIR/issue-41974.rs:17:18 diff --git a/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr b/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr index 9b7fe466696f8..833e84c18a710 100644 --- a/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr @@ -8,7 +8,7 @@ LL | with_signature(x, |mut y| Box::new(y.next())) '_#1r, T, i32, - extern "rust-call" fn((std::boxed::Box,)) -> std::boxed::Box<(dyn Anything + '_#2r)> + extern "rust-call" fn((std::boxed::Box,)) -> std::boxed::Box<(dyn Anything + '_#2r), std::alloc::Global> ] = note: number of external vids: 3 = note: where ::Item: '_#2r @@ -48,7 +48,7 @@ LL | with_signature(x, |mut y| Box::new(y.next())) '_#1r, T, i32, - extern "rust-call" fn((std::boxed::Box,)) -> std::boxed::Box<(dyn Anything + '_#2r)> + extern "rust-call" fn((std::boxed::Box,)) -> std::boxed::Box<(dyn Anything + '_#2r), std::alloc::Global> ] = note: number of external vids: 3 = note: where ::Item: '_#2r @@ -80,7 +80,7 @@ LL | with_signature(x, |mut y| Box::new(y.next())) '_#2r, T, i32, - extern "rust-call" fn((std::boxed::Box,)) -> std::boxed::Box<(dyn Anything + '_#3r)> + extern "rust-call" fn((std::boxed::Box,)) -> std::boxed::Box<(dyn Anything + '_#3r), std::alloc::Global> ] = note: number of external vids: 4 = note: where ::Item: '_#3r @@ -122,7 +122,7 @@ LL | with_signature(x, |mut y| Box::new(y.next())) '_#2r, T, i32, - extern "rust-call" fn((std::boxed::Box,)) -> std::boxed::Box<(dyn Anything + '_#3r)> + extern "rust-call" fn((std::boxed::Box,)) -> std::boxed::Box<(dyn Anything + '_#3r), std::alloc::Global> ] = note: number of external vids: 4 = note: where ::Item: '_#3r diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr index 9e69ae051732c..57b7da23a6ea4 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr @@ -8,7 +8,7 @@ LL | with_signature(x, |y| y) '_#1r, T, i32, - extern "rust-call" fn((std::boxed::Box,)) -> std::boxed::Box<(dyn std::fmt::Debug + '_#2r)> + extern "rust-call" fn((std::boxed::Box,)) -> std::boxed::Box<(dyn std::fmt::Debug + '_#2r), std::alloc::Global> ] = note: number of external vids: 3 = note: where T: '_#2r diff --git a/src/test/ui/unique-object-noncopyable.stderr b/src/test/ui/unique-object-noncopyable.stderr index 777b9f19badb5..ce4db03fb2f3c 100644 --- a/src/test/ui/unique-object-noncopyable.stderr +++ b/src/test/ui/unique-object-noncopyable.stderr @@ -4,8 +4,6 @@ error[E0599]: no method named `clone` found for type `std::boxed::Box` LL | let _z = y.clone(); //~ ERROR no method named `clone` found | ^^^^^ | - = note: the method `clone` exists but the following trait bounds were not satisfied: - `std::boxed::Box : std::clone::Clone` = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `clone`, perhaps you need to implement it: candidate #1: `std::clone::Clone` diff --git a/src/test/ui/unique-pinned-nocopy.stderr b/src/test/ui/unique-pinned-nocopy.stderr index ddc676601fa2e..bcc072263bbcf 100644 --- a/src/test/ui/unique-pinned-nocopy.stderr +++ b/src/test/ui/unique-pinned-nocopy.stderr @@ -4,8 +4,6 @@ error[E0599]: no method named `clone` found for type `std::boxed::Box` in the LL | let _j = i.clone(); //~ ERROR no method named `clone` found | ^^^^^ | - = note: the method `clone` exists but the following trait bounds were not satisfied: - `std::boxed::Box : std::clone::Clone` = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `clone`, perhaps you need to implement it: candidate #1: `std::clone::Clone`