Skip to content

Commit 5cccf3c

Browse files
committed
syntax: Implement #![no_core]
This commit is an implementation of [RFC 1184][rfc] which tweaks the behavior of the `#![no_std]` attribute and adds a new `#![no_core]` attribute. The `#![no_std]` attribute now injects `extern crate core` at the top of the crate as well as the libcore prelude into all modules (in the same manner as the standard library's prelude). The `#![no_core]` attribute disables both std and core injection. [rfc]: rust-lang/rfcs#1184
1 parent ceded6a commit 5cccf3c

File tree

157 files changed

+478
-385
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+478
-385
lines changed

src/liballoc/arc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
7272
use boxed::Box;
7373

74-
use core::prelude::*;
74+
#[cfg(stage0)]
75+
use core::prelude::v1::*;
7576

7677
use core::atomic;
7778
use core::atomic::Ordering::{Relaxed, Release, Acquire, SeqCst};

src/liballoc/boxed.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
5454
#![stable(feature = "rust1", since = "1.0.0")]
5555

56-
use core::prelude::*;
56+
#[cfg(stage0)]
57+
use core::prelude::v1::*;
5758

5859
use heap;
5960
use raw_vec::RawVec;

src/liballoc/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
#![feature(coerce_unsized)]
7676
#![feature(core)]
7777
#![feature(core_intrinsics)]
78-
#![feature(core_prelude)]
7978
#![feature(core_slice_ext)]
8079
#![feature(custom_attribute)]
8180
#![feature(fundamental)]
@@ -93,17 +92,17 @@
9392
#![feature(unsize)]
9493
#![feature(core_slice_ext)]
9594
#![feature(core_str_ext)]
95+
#![cfg_attr(stage0, feature(core, core_prelude))]
9696

9797
#![cfg_attr(test, feature(test, alloc, rustc_private, box_raw))]
9898
#![cfg_attr(all(not(feature = "external_funcs"), not(feature = "external_crate")),
9999
feature(libc))]
100100

101-
#[macro_use]
102-
extern crate core;
103-
104101
#[cfg(all(not(feature = "external_funcs"), not(feature = "external_crate")))]
105102
extern crate libc;
106103

104+
#[cfg(stage0)] #[macro_use] extern crate core;
105+
107106
// Allow testing this library
108107

109108
#[cfg(test)] #[macro_use] extern crate std;

src/liballoc/rc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@
150150
151151
#![stable(feature = "rust1", since = "1.0.0")]
152152

153-
use core::prelude::*;
153+
#[cfg(stage0)]
154+
use core::prelude::v1::*;
154155

155156
#[cfg(not(test))]
156157
use boxed::Box;

src/libcollections/binary_heap.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@
151151
#![allow(missing_docs)]
152152
#![stable(feature = "rust1", since = "1.0.0")]
153153

154-
use core::prelude::*;
154+
#[cfg(stage0)]
155+
use core::prelude::v1::*;
155156

156157
use core::iter::{FromIterator};
157158
use core::mem::swap;

src/libcollections/bit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@
8686
//! println!("There are {} primes below {}", num_primes, max_prime);
8787
//! ```
8888
89-
use core::prelude::*;
89+
#[cfg(stage0)]
90+
use core::prelude::v1::*;
9091

9192
use core::cmp::Ordering;
9293
use core::cmp;

src/libcollections/btree/map.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
use self::Entry::*;
1919

20-
use core::prelude::*;
20+
#[cfg(stage0)]
21+
use core::prelude::v1::*;
2122

2223
use core::cmp::Ordering;
2324
use core::fmt::Debug;
@@ -530,7 +531,8 @@ enum Continuation<A, B> {
530531
/// to nodes. By using this module much better safety guarantees can be made, and more search
531532
/// boilerplate gets cut out.
532533
mod stack {
533-
use core::prelude::*;
534+
#[cfg(stage0)]
535+
use core::prelude::v1::*;
534536
use core::marker;
535537
use core::mem;
536538
use core::ops::{Deref, DerefMut};

src/libcollections/btree/node.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ pub use self::SearchResult::*;
1616
pub use self::ForceResult::*;
1717
pub use self::TraversalItem::*;
1818

19-
use core::prelude::*;
19+
#[cfg(stage0)]
20+
use core::prelude::v1::*;
2021

2122
use core::cmp::Ordering::{Greater, Less, Equal};
2223
use core::intrinsics::arith_offset;

src/libcollections/btree/set.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
// This is pretty much entirely stolen from TreeSet, since BTreeMap has an identical interface
1212
// to TreeMap
1313

14-
use core::prelude::*;
14+
#[cfg(stage0)]
15+
use core::prelude::v1::*;
1516

1617
use core::cmp::Ordering::{self, Less, Greater, Equal};
1718
use core::fmt::Debug;

src/libcollections/enum_set.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
reason = "matches collection reform specification, \
1818
waiting for dust to settle")]
1919

20-
use core::prelude::*;
20+
#[cfg(stage0)]
21+
use core::prelude::v1::*;
22+
2123
use core::marker;
2224
use core::fmt;
2325
use core::iter::{FromIterator};

0 commit comments

Comments
 (0)