Skip to content

Commit

Permalink
Rollup merge of rust-lang#59675 - SimonSapin:stable-alloc, r=alexcric…
Browse files Browse the repository at this point in the history
…hton

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 rust-lang#27783
  • Loading branch information
Centril committed Apr 12, 2019
2 parents 9a612b2 + fc928a1 commit e728ee0
Show file tree
Hide file tree
Showing 28 changed files with 25 additions and 43 deletions.
5 changes: 1 addition & 4 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@
//! default global allocator. It is not compatible with the libc allocator API.

#![allow(unused_attributes)]
#![unstable(feature = "alloc",
reason = "this library is unlikely to be stabilized in its current \
form or name",
issue = "27783")]
#![stable(feature = "alloc", since = "1.36.0")]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/",
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/prelude/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//!
//! ```
//! # #![allow(unused_imports)]
//! # #![feature(alloc)]
//! #![feature(alloc_prelude)]
//! extern crate alloc;
//! use alloc::prelude::v1::*;
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl<T, A: Alloc> RawVec<T, A> {
/// # Examples
///
/// ```
/// # #![feature(alloc, raw_vec_internals)]
/// # #![feature(raw_vec_internals)]
/// # extern crate alloc;
/// # use std::ptr;
/// # use alloc::raw_vec::RawVec;
Expand Down Expand Up @@ -460,7 +460,7 @@ impl<T, A: Alloc> RawVec<T, A> {
/// # Examples
///
/// ```
/// # #![feature(alloc, raw_vec_internals)]
/// # #![feature(raw_vec_internals)]
/// # extern crate alloc;
/// # use std::ptr;
/// # use alloc::raw_vec::RawVec;
Expand Down
1 change: 0 additions & 1 deletion src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#![deny(rust_2018_idioms)]
#![cfg_attr(not(stage0), deny(internal))]

#![feature(alloc)]
#![feature(core_intrinsics)]
#![feature(dropck_eyepatch)]
#![feature(raw_vec_internals)]
Expand Down
2 changes: 0 additions & 2 deletions src/libpanic_unwind/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

#![deny(rust_2018_idioms)]

#![feature(allocator_api)]
#![feature(alloc)]
#![feature(core_intrinsics)]
#![feature(lang_items)]
#![feature(libc)]
Expand Down
1 change: 0 additions & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@
#![feature(align_offset)]
#![feature(alloc_error_handler)]
#![feature(alloc_layout_extra)]
#![feature(alloc)]
#![feature(allocator_api)]
#![feature(allocator_internals)]
#![feature(allow_internal_unsafe)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

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


def convert_to_string(s):
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/array-slice-vec/vec-macro-no-std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// ignore-emscripten no no_std executables

#![feature(lang_items, start, rustc_private, alloc)]
#![feature(lang_items, start, rustc_private)]
#![no_std]

extern crate std as other;
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/extern/extern-prelude-core.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// run-pass
#![feature(extern_prelude, lang_items, start, alloc)]
#![feature(extern_prelude, lang_items, start)]
#![no_std]

extern crate std as other;
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/extern/extern-prelude-core.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
warning: the feature `extern_prelude` has been stable since 1.30.0 and no longer requires an attribute to enable
--> $DIR/extern-prelude-core.rs:2:12
|
LL | #![feature(extern_prelude, lang_items, start, alloc)]
LL | #![feature(extern_prelude, lang_items, start)]
| ^^^^^^^^^^^^^^
|
= note: #[warn(stable_features)] on by default
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/for-loop-while/for-loop-no-std.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// run-pass
#![allow(unused_imports)]
#![feature(lang_items, start, alloc)]
#![feature(lang_items, start)]
#![no_std]

extern crate std as other;
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/format-no-std.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ignore-emscripten no no_std executables

#![feature(lang_items, start, alloc)]
#![feature(lang_items, start)]
#![no_std]

extern crate std as other;
Expand Down
3 changes: 0 additions & 3 deletions src/test/run-pass/structs-enums/unit-like-struct-drop-run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

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


#![feature(alloc)]

use std::thread;

struct Foo;
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/allocator-submodule.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Tests that it is possible to create a global allocator in a submodule, rather than in the crate
// root.

#![feature(alloc, allocator_api, global_allocator)]

extern crate alloc;

use std::{
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/allocator-submodule.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `global_allocator` cannot be used in submodules
--> $DIR/allocator-submodule.rs:27:5
--> $DIR/allocator-submodule.rs:25:5
|
LL | static MY_HEAP: MyAlloc = MyAlloc;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/error-codes/E0254.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(alloc)]
#![allow(unused_extern_crates, non_camel_case_types)]

extern crate alloc;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0254.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0254]: the name `alloc` is defined multiple times
--> $DIR/E0254.rs:12:5
--> $DIR/E0254.rs:11:5
|
LL | extern crate alloc;
| ------------------- previous import of the extern crate `alloc` here
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0259.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(alloc, rustc_private)]
#![feature(rustc_private)]
#![allow(unused_extern_crates)]

extern crate alloc;
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/error-codes/E0260.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(alloc)]
#![allow(unused_extern_crates)]

extern crate alloc;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0260.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0260]: the name `alloc` is defined multiple times
--> $DIR/E0260.rs:6:1
--> $DIR/E0260.rs:5:1
|
LL | extern crate alloc;
| ------------------- previous import of the extern crate `alloc` here
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/missing/missing-alloc_error_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#![no_std]
#![crate_type = "staticlib"]
#![feature(panic_handler, alloc_error_handler, alloc)]
#![feature(panic_handler, alloc_error_handler)]

#[panic_handler]
fn panic(_: &core::panic::PanicInfo) -> ! {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/missing/missing-allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#![no_std]
#![crate_type = "staticlib"]
#![feature(panic_handler, alloc_error_handler, alloc)]
#![feature(panic_handler, alloc_error_handler)]

#[panic_handler]
fn panic(_: &core::panic::PanicInfo) -> ! {
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/resolve_self_super_hint.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(alloc)]
#![allow(unused_extern_crates)]

mod a {
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/resolve_self_super_hint.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error[E0432]: unresolved import `alloc`
--> $DIR/resolve_self_super_hint.rs:6:9
--> $DIR/resolve_self_super_hint.rs:5:9
|
LL | use alloc::HashMap;
| ^^^^^ help: a similar path exists: `self::alloc`

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

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

error[E0432]: unresolved import `alloc`
--> $DIR/resolve_self_super_hint.rs:21:21
--> $DIR/resolve_self_super_hint.rs:20:21
|
LL | use alloc::HashMap;
| ^^^^^
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/rust-2018/remove-extern-crate.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// aux-build:remove-extern-crate.rs
// compile-flags:--extern remove_extern_crate

#![feature(alloc)]
#![warn(rust_2018_idioms)]


Expand Down
1 change: 0 additions & 1 deletion src/test/ui/rust-2018/remove-extern-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// aux-build:remove-extern-crate.rs
// compile-flags:--extern remove_extern_crate

#![feature(alloc)]
#![warn(rust_2018_idioms)]

extern crate core;
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/rust-2018/remove-extern-crate.stderr
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
warning: unused extern crate
--> $DIR/remove-extern-crate.rs:10:1
--> $DIR/remove-extern-crate.rs:9:1
|
LL | extern crate core;
| ^^^^^^^^^^^^^^^^^^ help: remove it
|
note: lint level defined here
--> $DIR/remove-extern-crate.rs:8:9
--> $DIR/remove-extern-crate.rs:7:9
|
LL | #![warn(rust_2018_idioms)]
| ^^^^^^^^^^^^^^^^
= note: #[warn(unused_extern_crates)] implied by #[warn(rust_2018_idioms)]

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

warning: `extern crate` is not idiomatic in the new edition
--> $DIR/remove-extern-crate.rs:29:5
--> $DIR/remove-extern-crate.rs:28:5
|
LL | extern crate core;
| ^^^^^^^^^^^^^^^^^^ help: convert it to a `use`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/unnecessary-extern-crate.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// edition:2018

#![deny(unused_extern_crates)]
#![feature(alloc, test, rustc_private, crate_visibility_modifier)]
#![feature(test, rustc_private, crate_visibility_modifier)]

extern crate libc;
//~^ ERROR unused extern crate
Expand Down

0 comments on commit e728ee0

Please sign in to comment.