Skip to content

Commit fc928a1

Browse files
committed
Stabilize the alloc crate.
This implements RFC 2480: * rust-lang/rfcs#2480 * https://github.com/rust-lang/rfcs/blob/master/text/2480-liballoc.md Closes #27783
1 parent f8673e0 commit fc928a1

28 files changed

+25
-43
lines changed

src/liballoc/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@
5151
//! default global allocator. It is not compatible with the libc allocator API.
5252
5353
#![allow(unused_attributes)]
54-
#![unstable(feature = "alloc",
55-
reason = "this library is unlikely to be stabilized in its current \
56-
form or name",
57-
issue = "27783")]
54+
#![stable(feature = "alloc", since = "1.36.0")]
5855
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/",
5956
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
6057
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]

src/liballoc/prelude/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//!
66
//! ```
77
//! # #![allow(unused_imports)]
8-
//! # #![feature(alloc)]
98
//! #![feature(alloc_prelude)]
109
//! extern crate alloc;
1110
//! use alloc::prelude::v1::*;

src/liballoc/raw_vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ impl<T, A: Alloc> RawVec<T, A> {
256256
/// # Examples
257257
///
258258
/// ```
259-
/// # #![feature(alloc, raw_vec_internals)]
259+
/// # #![feature(raw_vec_internals)]
260260
/// # extern crate alloc;
261261
/// # use std::ptr;
262262
/// # use alloc::raw_vec::RawVec;
@@ -460,7 +460,7 @@ impl<T, A: Alloc> RawVec<T, A> {
460460
/// # Examples
461461
///
462462
/// ```
463-
/// # #![feature(alloc, raw_vec_internals)]
463+
/// # #![feature(raw_vec_internals)]
464464
/// # extern crate alloc;
465465
/// # use std::ptr;
466466
/// # use alloc::raw_vec::RawVec;

src/libarena/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#![deny(rust_2018_idioms)]
1515

16-
#![feature(alloc)]
1716
#![feature(core_intrinsics)]
1817
#![feature(dropck_eyepatch)]
1918
#![feature(raw_vec_internals)]

src/libpanic_unwind/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
#![deny(rust_2018_idioms)]
2121

22-
#![feature(allocator_api)]
23-
#![feature(alloc)]
2422
#![feature(core_intrinsics)]
2523
#![feature(lang_items)]
2624
#![feature(libc)]

src/libstd/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@
229229
#![feature(align_offset)]
230230
#![feature(alloc_error_handler)]
231231
#![feature(alloc_layout_extra)]
232-
#![feature(alloc)]
233232
#![feature(allocator_api)]
234233
#![feature(allocator_internals)]
235234
#![feature(allow_internal_unsafe)]

src/test/run-make-fulldeps/sysroot-crates-are-unstable/test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
# This is a whitelist of files which are stable crates or simply are not crates,
99
# we don't check for the instability of these crates as they're all stable!
10-
STABLE_CRATES = ['std', 'core', 'proc_macro', 'rsbegin.o', 'rsend.o', 'dllcrt2.o', 'crt2.o',
11-
'clang_rt']
10+
STABLE_CRATES = ['std', 'alloc', 'core', 'proc_macro',
11+
'rsbegin.o', 'rsend.o', 'dllcrt2.o', 'crt2.o', 'clang_rt']
1212

1313

1414
def convert_to_string(s):

src/test/run-pass/array-slice-vec/vec-macro-no-std.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// ignore-emscripten no no_std executables
44

5-
#![feature(lang_items, start, rustc_private, alloc)]
5+
#![feature(lang_items, start, rustc_private)]
66
#![no_std]
77

88
extern crate std as other;

src/test/run-pass/extern/extern-prelude-core.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-pass
2-
#![feature(extern_prelude, lang_items, start, alloc)]
2+
#![feature(extern_prelude, lang_items, start)]
33
#![no_std]
44

55
extern crate std as other;

src/test/run-pass/extern/extern-prelude-core.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
warning: the feature `extern_prelude` has been stable since 1.30.0 and no longer requires an attribute to enable
22
--> $DIR/extern-prelude-core.rs:2:12
33
|
4-
LL | #![feature(extern_prelude, lang_items, start, alloc)]
4+
LL | #![feature(extern_prelude, lang_items, start)]
55
| ^^^^^^^^^^^^^^
66
|
77
= note: #[warn(stable_features)] on by default

src/test/run-pass/for-loop-while/for-loop-no-std.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-pass
22
#![allow(unused_imports)]
3-
#![feature(lang_items, start, alloc)]
3+
#![feature(lang_items, start)]
44
#![no_std]
55

66
extern crate std as other;

src/test/run-pass/format-no-std.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ignore-emscripten no no_std executables
22

3-
#![feature(lang_items, start, alloc)]
3+
#![feature(lang_items, start)]
44
#![no_std]
55

66
extern crate std as other;

src/test/run-pass/structs-enums/unit-like-struct-drop-run.rs

-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33

44
// Make sure the destructor is run for unit-like structs.
55

6-
7-
#![feature(alloc)]
8-
96
use std::thread;
107

118
struct Foo;

src/test/ui/allocator-submodule.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Tests that it is possible to create a global allocator in a submodule, rather than in the crate
22
// root.
33

4-
#![feature(alloc, allocator_api, global_allocator)]
5-
64
extern crate alloc;
75

86
use std::{

src/test/ui/allocator-submodule.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `global_allocator` cannot be used in submodules
2-
--> $DIR/allocator-submodule.rs:27:5
2+
--> $DIR/allocator-submodule.rs:25:5
33
|
44
LL | static MY_HEAP: MyAlloc = MyAlloc;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/error-codes/E0254.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(alloc)]
21
#![allow(unused_extern_crates, non_camel_case_types)]
32

43
extern crate alloc;

src/test/ui/error-codes/E0254.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0254]: the name `alloc` is defined multiple times
2-
--> $DIR/E0254.rs:12:5
2+
--> $DIR/E0254.rs:11:5
33
|
44
LL | extern crate alloc;
55
| ------------------- previous import of the extern crate `alloc` here

src/test/ui/error-codes/E0259.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(alloc, rustc_private)]
1+
#![feature(rustc_private)]
22
#![allow(unused_extern_crates)]
33

44
extern crate alloc;

src/test/ui/error-codes/E0260.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(alloc)]
21
#![allow(unused_extern_crates)]
32

43
extern crate alloc;

src/test/ui/error-codes/E0260.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0260]: the name `alloc` is defined multiple times
2-
--> $DIR/E0260.rs:6:1
2+
--> $DIR/E0260.rs:5:1
33
|
44
LL | extern crate alloc;
55
| ------------------- previous import of the extern crate `alloc` here

src/test/ui/missing/missing-alloc_error_handler.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#![no_std]
55
#![crate_type = "staticlib"]
6-
#![feature(panic_handler, alloc_error_handler, alloc)]
6+
#![feature(panic_handler, alloc_error_handler)]
77

88
#[panic_handler]
99
fn panic(_: &core::panic::PanicInfo) -> ! {

src/test/ui/missing/missing-allocator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#![no_std]
55
#![crate_type = "staticlib"]
6-
#![feature(panic_handler, alloc_error_handler, alloc)]
6+
#![feature(panic_handler, alloc_error_handler)]
77

88
#[panic_handler]
99
fn panic(_: &core::panic::PanicInfo) -> ! {

src/test/ui/resolve_self_super_hint.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(alloc)]
21
#![allow(unused_extern_crates)]
32

43
mod a {

src/test/ui/resolve_self_super_hint.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0432]: unresolved import `alloc`
2-
--> $DIR/resolve_self_super_hint.rs:6:9
2+
--> $DIR/resolve_self_super_hint.rs:5:9
33
|
44
LL | use alloc::HashMap;
55
| ^^^^^ help: a similar path exists: `self::alloc`
66

77
error[E0432]: unresolved import `alloc`
8-
--> $DIR/resolve_self_super_hint.rs:11:13
8+
--> $DIR/resolve_self_super_hint.rs:10:13
99
|
1010
LL | use alloc::HashMap;
1111
| ^^^^^ help: a similar path exists: `super::alloc`
1212

1313
error[E0432]: unresolved import `alloc`
14-
--> $DIR/resolve_self_super_hint.rs:16:17
14+
--> $DIR/resolve_self_super_hint.rs:15:17
1515
|
1616
LL | use alloc::HashMap;
1717
| ^^^^^
@@ -20,7 +20,7 @@ LL | use alloc::HashMap;
2020
| help: a similar path exists: `a::alloc`
2121

2222
error[E0432]: unresolved import `alloc`
23-
--> $DIR/resolve_self_super_hint.rs:21:21
23+
--> $DIR/resolve_self_super_hint.rs:20:21
2424
|
2525
LL | use alloc::HashMap;
2626
| ^^^^^

src/test/ui/rust-2018/remove-extern-crate.fixed

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// aux-build:remove-extern-crate.rs
55
// compile-flags:--extern remove_extern_crate
66

7-
#![feature(alloc)]
87
#![warn(rust_2018_idioms)]
98

109

src/test/ui/rust-2018/remove-extern-crate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// aux-build:remove-extern-crate.rs
55
// compile-flags:--extern remove_extern_crate
66

7-
#![feature(alloc)]
87
#![warn(rust_2018_idioms)]
98

109
extern crate core;

src/test/ui/rust-2018/remove-extern-crate.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
warning: unused extern crate
2-
--> $DIR/remove-extern-crate.rs:10:1
2+
--> $DIR/remove-extern-crate.rs:9:1
33
|
44
LL | extern crate core;
55
| ^^^^^^^^^^^^^^^^^^ help: remove it
66
|
77
note: lint level defined here
8-
--> $DIR/remove-extern-crate.rs:8:9
8+
--> $DIR/remove-extern-crate.rs:7:9
99
|
1010
LL | #![warn(rust_2018_idioms)]
1111
| ^^^^^^^^^^^^^^^^
1212
= note: #[warn(unused_extern_crates)] implied by #[warn(rust_2018_idioms)]
1313

1414
warning: `extern crate` is not idiomatic in the new edition
15-
--> $DIR/remove-extern-crate.rs:11:1
15+
--> $DIR/remove-extern-crate.rs:10:1
1616
|
1717
LL | extern crate core as another_name;
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `use`
1919

2020
warning: `extern crate` is not idiomatic in the new edition
21-
--> $DIR/remove-extern-crate.rs:29:5
21+
--> $DIR/remove-extern-crate.rs:28:5
2222
|
2323
LL | extern crate core;
2424
| ^^^^^^^^^^^^^^^^^^ help: convert it to a `use`

src/test/ui/unnecessary-extern-crate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// edition:2018
22

33
#![deny(unused_extern_crates)]
4-
#![feature(alloc, test, rustc_private, crate_visibility_modifier)]
4+
#![feature(test, rustc_private, crate_visibility_modifier)]
55

66
extern crate libc;
77
//~^ ERROR unused extern crate

0 commit comments

Comments
 (0)