Skip to content

Commit 9659f05

Browse files
committed
Rollup merge of rust-lang#49958 - glandium:cleanup, r=SimonSapin
Cleanup liballoc use statements Some modules were still using the deprecated `allocator` module, use the `alloc` module instead. Some modules were using `super` while it's not needed. Some modules were more or less ordering them, and other not, so the latter have been modified to match the others.
2 parents e681ba2 + e35499c commit 9659f05

File tree

15 files changed

+30
-30
lines changed

15 files changed

+30
-30
lines changed

src/doc/unstable-book/src/language-features/global-allocator.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn main() {
5555
```
5656

5757
And that's it! The `#[global_allocator]` attribute is applied to a `static`
58-
which implements the `Alloc` trait in the `std::heap` module. Note, though,
58+
which implements the `Alloc` trait in the `std::alloc` module. Note, though,
5959
that the implementation is defined for `&MyAllocator`, not just `MyAllocator`.
6060
You may wish, however, to also provide `Alloc for MyAllocator` for other use
6161
cases.

src/liballoc/boxed.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@
5555
5656
#![stable(feature = "rust1", since = "1.0.0")]
5757

58-
use raw_vec::RawVec;
59-
6058
use core::any::Any;
6159
use core::borrow;
6260
use core::cmp::Ordering;
@@ -68,6 +66,8 @@ use core::mem::{self, Pin};
6866
use core::ops::{CoerceUnsized, Deref, DerefMut, Generator, GeneratorState};
6967
use core::ptr::{self, NonNull, Unique};
7068
use core::convert::From;
69+
70+
use raw_vec::RawVec;
7171
use str::from_boxed_utf8_unchecked;
7272

7373
/// A pointer type for heap allocation.

src/liballoc/raw_vec.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use alloc::{Alloc, Layout, Global};
1211
use core::cmp;
1312
use core::mem;
1413
use core::ops::Drop;
1514
use core::ptr::{self, NonNull, Unique};
1615
use core::slice;
17-
use super::boxed::Box;
18-
use super::allocator::CollectionAllocErr;
19-
use super::allocator::CollectionAllocErr::*;
16+
17+
use alloc::{Alloc, Layout, Global};
18+
use alloc::CollectionAllocErr;
19+
use alloc::CollectionAllocErr::*;
20+
use boxed::Box;
2021

2122
/// A low-level utility for more ergonomically allocating, reallocating, and deallocating
2223
/// a buffer of memory on the heap without having to worry about all the corner cases

src/liballoc/str.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ use core::mem;
4646
use core::ptr;
4747
use core::iter::FusedIterator;
4848

49-
use vec_deque::VecDeque;
5049
use borrow::{Borrow, ToOwned};
50+
use boxed::Box;
51+
use slice::{SliceConcatExt, SliceIndex};
5152
use string::String;
5253
use vec::Vec;
53-
use slice::{SliceConcatExt, SliceIndex};
54-
use boxed::Box;
54+
use vec_deque::VecDeque;
5555

5656
#[stable(feature = "rust1", since = "1.0.0")]
5757
pub use core::str::{FromStr, Utf8Error};

src/liballoc/string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ use core::ptr;
6666
use core::str::pattern::Pattern;
6767
use core::str::lossy;
6868

69+
use alloc::CollectionAllocErr;
6970
use borrow::{Cow, ToOwned};
71+
use boxed::Box;
7072
use str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars};
7173
use vec::Vec;
72-
use boxed::Box;
73-
use super::allocator::CollectionAllocErr;
7474

7575
/// A UTF-8 encoded, growable string.
7676
///

src/liballoc/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ use core::ptr;
8282
use core::ptr::NonNull;
8383
use core::slice;
8484

85+
use alloc::CollectionAllocErr;
8586
use borrow::ToOwned;
8687
use borrow::Cow;
8788
use boxed::Box;
8889
use raw_vec::RawVec;
89-
use super::allocator::CollectionAllocErr;
9090

9191
/// A contiguous growable array type, written `Vec<T>` but pronounced 'vector'.
9292
///

src/liballoc/vec_deque.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ use core::slice;
3030
use core::hash::{Hash, Hasher};
3131
use core::cmp;
3232

33+
use alloc::CollectionAllocErr;
3334
use raw_vec::RawVec;
34-
35-
use super::allocator::CollectionAllocErr;
36-
use super::vec::Vec;
35+
use vec::Vec;
3736

3837
const INITIAL_CAPACITY: usize = 7; // 2^3 - 1
3938
const MINIMUM_CAPACITY: usize = 1; // 2 - 1

src/test/compile-fail/allocator/auxiliary/system-allocator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#![feature(global_allocator, allocator_api)]
1414
#![crate_type = "rlib"]
1515

16-
use std::heap::System;
16+
use std::alloc::System;
1717

1818
#[global_allocator]
1919
static A: System = System;

src/test/compile-fail/allocator/auxiliary/system-allocator2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#![feature(global_allocator, allocator_api)]
1414
#![crate_type = "rlib"]
1515

16-
use std::heap::System;
16+
use std::alloc::System;
1717

1818
#[global_allocator]
1919
static A: System = System;

src/test/compile-fail/allocator/two-allocators.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#![feature(global_allocator, allocator_api)]
1212

13-
use std::heap::System;
13+
use std::alloc::System;
1414

1515
#[global_allocator]
1616
static A: System = System;

src/test/compile-fail/allocator/two-allocators2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
extern crate system_allocator;
1818

19-
use std::heap::System;
19+
use std::alloc::System;
2020

2121
#[global_allocator]
2222
static A: System = System;

src/test/run-pass/allocator-alloc-one.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010

1111
#![feature(allocator_api, nonnull)]
1212

13-
use std::heap::{Heap, Alloc};
13+
use std::alloc::{Alloc, Global};
1414

1515
fn main() {
1616
unsafe {
17-
let ptr = Heap.alloc_one::<i32>().unwrap_or_else(|_| {
18-
Heap.oom()
17+
let ptr = Global.alloc_one::<i32>().unwrap_or_else(|_| {
18+
Global.oom()
1919
});
2020
*ptr.as_ptr() = 4;
2121
assert_eq!(*ptr.as_ptr(), 4);
22-
Heap.dealloc_one(ptr);
22+
Global.dealloc_one(ptr);
2323
}
2424
}

src/test/run-pass/allocator/auxiliary/custom.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#![feature(heap_api, allocator_api)]
1414
#![crate_type = "rlib"]
1515

16-
use std::heap::{GlobalAlloc, System, Layout, Opaque};
16+
use std::alloc::{GlobalAlloc, System, Layout, Opaque};
1717
use std::sync::atomic::{AtomicUsize, Ordering};
1818

1919
pub struct A(pub AtomicUsize);

src/test/run-pass/regions-mock-trans.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#![feature(allocator_api)]
1414

15-
use std::heap::{Alloc, Heap, Layout};
15+
use std::alloc::{Alloc, Global, Layout};
1616
use std::ptr::NonNull;
1717

1818
struct arena(());
@@ -32,8 +32,8 @@ struct Ccx {
3232

3333
fn alloc<'a>(_bcx : &'a arena) -> &'a Bcx<'a> {
3434
unsafe {
35-
let ptr = Heap.alloc(Layout::new::<Bcx>())
36-
.unwrap_or_else(|_| Heap.oom());
35+
let ptr = Global.alloc(Layout::new::<Bcx>())
36+
.unwrap_or_else(|_| Global.oom());
3737
&*(ptr.as_ptr() as *const _)
3838
}
3939
}
@@ -46,7 +46,7 @@ fn g(fcx : &Fcx) {
4646
let bcx = Bcx { fcx: fcx };
4747
let bcx2 = h(&bcx);
4848
unsafe {
49-
Heap.dealloc(NonNull::new_unchecked(bcx2 as *const _ as *mut _), Layout::new::<Bcx>());
49+
Global.dealloc(NonNull::new_unchecked(bcx2 as *const _ as *mut _), Layout::new::<Bcx>());
5050
}
5151
}
5252

src/test/run-pass/thin-lto-global-allocator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
#![feature(allocator_api, global_allocator)]
1515

1616
#[global_allocator]
17-
static A: std::heap::System = std::heap::System;
17+
static A: std::alloc::System = std::alloc::System;
1818

1919
fn main() {}

0 commit comments

Comments
 (0)