Skip to content

Commit e04bcd9

Browse files
committed
Fix use of wrongGlobal in tests
1 parent 5d32908 commit e04bcd9

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

src/liballoc/alloc.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
33
#![stable(feature = "alloc_module", since = "1.28.0")]
44

5-
use core::intrinsics::{self, min_align_of_val, size_of_val};
6-
use core::ptr::{NonNull, Unique};
5+
#[cfg(not(test))]
6+
use core::intrinsics;
7+
#[cfg(not(test))]
8+
use core::ptr::NonNull;
9+
10+
use core::intrinsics::{min_align_of_val, size_of_val};
11+
use core::ptr::Unique;
712

813
#[stable(feature = "alloc_module", since = "1.28.0")]
914
#[doc(inline)]
@@ -40,8 +45,12 @@ extern "Rust" {
4045
/// [`AllocRef`]: trait.AllocRef.html
4146
#[unstable(feature = "allocator_api", issue = "32838")]
4247
#[derive(Copy, Clone, Default, Debug)]
48+
#[cfg(not(test))]
4349
pub struct Global;
4450

51+
#[cfg(test)]
52+
pub use std::alloc::Global;
53+
4554
/// Allocate memory with the global allocator.
4655
///
4756
/// This function forwards calls to the [`GlobalAlloc::alloc`] method
@@ -162,6 +171,7 @@ pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 {
162171
}
163172

164173
#[unstable(feature = "allocator_api", issue = "32838")]
174+
#[cfg(not(test))]
165175
unsafe impl AllocRef for Global {
166176
#[inline]
167177
fn alloc(&mut self, layout: Layout, init: AllocInit) -> Result<MemoryBlock, AllocErr> {

src/liballoc/boxed.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ unsafe impl<#[may_dangle] T: ?Sized, A: AllocRef> Drop for Box<T, A> {
739739
}
740740

741741
#[stable(feature = "rust1", since = "1.0.0")]
742-
impl<T: Default, A: AllocRef + Default> Default for Box<T, A> {
742+
impl<T: Default> Default for Box<T> {
743743
/// Creates a `Box<T>`, with the `Default` value for T.
744744
fn default() -> Self {
745745
box T::default()
@@ -916,7 +916,7 @@ impl<T: ?Sized + Hasher, A: AllocRef> Hasher for Box<T, A> {
916916
}
917917

918918
#[stable(feature = "from_for_ptrs", since = "1.6.0")]
919-
impl<T, A: AllocRef + Default> From<T> for Box<T, A> {
919+
impl<T> From<T> for Box<T> {
920920
/// Converts a generic type `T` into a `Box<T>`
921921
///
922922
/// The conversion allocates on the heap and moves `t`
@@ -930,7 +930,7 @@ impl<T, A: AllocRef + Default> From<T> for Box<T, A> {
930930
/// assert_eq!(Box::from(x), boxed);
931931
/// ```
932932
fn from(t: T) -> Self {
933-
Box::new_in(t, A::default())
933+
Box::new(t)
934934
}
935935
}
936936

@@ -945,7 +945,7 @@ impl<T: ?Sized, A: AllocRef> From<Box<T, A>> for Pin<Box<T, A>> {
945945
}
946946

947947
#[stable(feature = "box_from_slice", since = "1.17.0")]
948-
impl<T: Copy, A: AllocRef + Default> From<&[T]> for Box<[T], A> {
948+
impl<T: Copy> From<&[T]> for Box<[T]> {
949949
/// Converts a `&[T]` into a `Box<[T]>`
950950
///
951951
/// This conversion allocates on the heap
@@ -970,7 +970,7 @@ impl<T: Copy, A: AllocRef + Default> From<&[T]> for Box<[T], A> {
970970
}
971971

972972
#[stable(feature = "box_from_slice", since = "1.17.0")]
973-
impl<A: AllocRef + Default> From<&str> for Box<str, A> {
973+
impl From<&str> for Box<str> {
974974
/// Converts a `&str` into a `Box<str>`
975975
///
976976
/// This conversion allocates on the heap
@@ -1237,9 +1237,9 @@ impl<I> FromIterator<I> for Box<[I]> {
12371237
}
12381238

12391239
#[stable(feature = "box_slice_clone", since = "1.3.0")]
1240-
impl<T: Clone, A: AllocRef + Clone> Clone for Box<[T], A> {
1240+
impl<T: Clone> Clone for Box<[T]> {
12411241
fn clone(&self) -> Self {
1242-
self.to_vec_in(self.1.clone()).into_boxed_slice()
1242+
self.to_vec().into_boxed_slice()
12431243
}
12441244
}
12451245

0 commit comments

Comments
 (0)