Skip to content

Commit dbe415a

Browse files
committed
Auto merge of #27393 - alexcrichton:no-std-changes, r=brson
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 Closes #27394
2 parents efdbc0e + 0d83403 commit dbe415a

File tree

160 files changed

+500
-417
lines changed

Some content is hidden

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

160 files changed

+500
-417
lines changed

src/liballoc/arc.rs

+2-1
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

+2-1
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

+3-4
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

+2-1
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

+2-1
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

+2-1
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

+4-2
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

+2-1
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

+2-1
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

+3-1
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};

src/libcollections/lib.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
#![feature(alloc)]
3434
#![feature(box_patterns)]
3535
#![feature(box_syntax)]
36-
#![feature(core)]
3736
#![feature(core_intrinsics)]
38-
#![feature(core_prelude)]
3937
#![feature(core_slice_ext)]
4038
#![feature(core_str_ext)]
4139
#![feature(heap_api)]
@@ -62,12 +60,12 @@
6260
#![feature(utf8_error)]
6361
#![cfg_attr(test, feature(rand, test))]
6462
#![cfg_attr(not(test), feature(str_words))]
63+
#![cfg_attr(stage0, feature(core, core_prelude))]
6564

6665
#![feature(no_std)]
6766
#![no_std]
6867

69-
#[macro_use]
70-
extern crate core;
68+
#[cfg(stage0)] #[macro_use] extern crate core;
7169

7270
extern crate rustc_unicode;
7371
extern crate alloc;

src/libcollections/linked_list.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121

2222
#![stable(feature = "rust1", since = "1.0.0")]
2323

24-
use core::prelude::*;
24+
#[cfg(stage0)]
25+
use core::prelude::v1::*;
2526

2627
use alloc::boxed::Box;
2728
use core::cmp::Ordering;

src/libcollections/string.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414

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

1718
use core::fmt;
1819
use core::hash;

src/libcollections/vec.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858
5959
#![stable(feature = "rust1", since = "1.0.0")]
6060

61-
use core::prelude::*;
61+
#[cfg(stage0)]
62+
use core::prelude::v1::*;
63+
6264
use alloc::raw_vec::RawVec;
6365
use alloc::boxed::Box;
6466
use alloc::heap::EMPTY;

src/libcollections/vec_deque.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
1919
#![stable(feature = "rust1", since = "1.0.0")]
2020

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

2324
use core::cmp::Ordering;
2425
use core::fmt;

src/libcollections/vec_map.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
use self::Entry::*;
2222

23-
use core::prelude::*;
23+
#[cfg(stage0)]
24+
use core::prelude::v1::*;
2425

2526
use core::cmp::{max, Ordering};
2627
use core::fmt;

src/libcore/fmt/builders.rs

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

11-
use prelude::*;
11+
use prelude::v1::*;
1212
use fmt::{self, Write, FlagV1};
1313

1414
struct PadAdapter<'a, 'b: 'a> {

src/libcore/fmt/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414

15-
use prelude::*;
15+
use prelude::v1::*;
1616

1717
use cell::{Cell, RefCell, Ref, RefMut, BorrowState};
1818
use marker::PhantomData;

src/libcore/fmt/num.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
// FIXME: #6220 Implement floating point formatting
1414

15-
use prelude::*;
15+
use prelude::v1::*;
1616

1717
use fmt;
1818
use num::Zero;

src/libcore/hash/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
6363
#![stable(feature = "rust1", since = "1.0.0")]
6464

65-
use prelude::*;
65+
use prelude::v1::*;
6666

6767
use mem;
6868

@@ -183,7 +183,7 @@ pub fn hash<T: Hash, H: Hasher + Default>(value: &T) -> u64 {
183183
//////////////////////////////////////////////////////////////////////////////
184184

185185
mod impls {
186-
use prelude::*;
186+
use prelude::v1::*;
187187

188188
use slice;
189189
use super::*;

src/libcore/hash/sip.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
//! An implementation of SipHash 2-4.
1212
13+
use prelude::v1::*;
14+
1315
use ptr;
14-
use prelude::*;
1516
use super::Hasher;
1617

1718
/// An implementation of SipHash 2-4.

src/libcore/lib.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@
6060
html_playground_url = "http://play.rust-lang.org/")]
6161
#![doc(test(no_crate_inject))]
6262

63-
#![feature(no_std)]
64-
#![no_std]
63+
#![cfg_attr(stage0, feature(no_std))]
64+
#![cfg_attr(stage0, no_std)]
65+
#![cfg_attr(not(stage0), feature(no_core))]
66+
#![cfg_attr(not(stage0), no_core)]
6567
#![allow(raw_pointer_derive)]
6668
#![deny(missing_docs)]
6769

@@ -168,6 +170,7 @@ mod tuple;
168170
// compiling the core library when it's compiling this library, so it expands
169171
// all references to `::core::$foo`
170172
#[doc(hidden)]
173+
#[cfg(stage0)]
171174
mod core {
172175
pub use intrinsics; // derive(PartialOrd)
173176
pub use fmt; // format_args!

src/libcore/num/f32.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#![stable(feature = "rust1", since = "1.0.0")]
1717

18-
use prelude::*;
18+
use prelude::v1::*;
1919

2020
use intrinsics;
2121
use mem;

src/libcore/num/f64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#![stable(feature = "rust1", since = "1.0.0")]
1717

18-
use prelude::*;
18+
use prelude::v1::*;
1919

2020
use intrinsics;
2121
use mem;

src/libcore/num/flt2dec/bignum.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
2222
#![macro_use]
2323

24-
use prelude::*;
24+
use prelude::v1::*;
25+
2526
use mem;
2627
use intrinsics;
2728

@@ -351,7 +352,7 @@ define_bignum!(Big32x36: type=Digit32, n=36);
351352
// this one is used for testing only.
352353
#[doc(hidden)]
353354
pub mod tests {
354-
use prelude::*;
355+
use prelude::v1::*;
355356
define_bignum!(Big8x3: type=u8, n=3);
356357
}
357358

src/libcore/num/flt2dec/decoder.rs

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

1111
//! Decodes a floating-point value into individual parts and error ranges.
1212
13-
use prelude::*;
13+
use prelude::v1::*;
1414

1515
use {f32, f64};
1616
use num::{Float, FpCategory};

src/libcore/num/flt2dec/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ functions.
129129
#![unstable(feature = "flt2dec",
130130
reason = "internal routines only exposed for testing")]
131131

132-
use prelude::*;
132+
use prelude::v1::*;
133133
use i16;
134134
use num::Float;
135135
use slice::bytes;

src/libcore/num/flt2dec/strategy/dragon.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Almost direct (but slightly optimized) Rust translation of Figure 3 of [1].
1515
quickly and accurately. SIGPLAN Not. 31, 5 (May. 1996), 108-116.
1616
*/
1717

18-
use prelude::*;
18+
use prelude::v1::*;
19+
1920
use num::Float;
2021
use cmp::Ordering;
2122

src/libcore/num/flt2dec/strategy/grisu.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Rust adaptation of Grisu3 algorithm described in [1]. It uses about
1616
accurately with integers. SIGPLAN Not. 45, 6 (June 2010), 233-243.
1717
*/
1818

19-
use prelude::*;
19+
use prelude::v1::*;
20+
2021
use num::Float;
2122

2223
use num::flt2dec::{Decoded, MAX_SIG_DIGITS, round_up};

src/libcore/prelude/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
//! The libcore prelude
12+
13+
pub mod v1;

src/libcore/prelude.rs src/libcore/prelude/v1.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,8 @@
1111
//! The core prelude
1212
//!
1313
//! This module is intended for users of libcore which do not link to libstd as
14-
//! well. This module is not imported by default, but using the entire contents
15-
//! of this module will provide all of the useful traits and types in libcore
16-
//! that one would expect from the standard library as well.
17-
//!
18-
//! There is no method to automatically inject this prelude, and this prelude is
19-
//! a subset of the standard library's prelude.
20-
//!
21-
//! # Example
22-
//!
23-
//! ```ignore
24-
//! use core::prelude::*;
25-
//! ```
14+
//! well. This module is imported by default when `#![no_std]` is used in the
15+
//! same manner as the standard library's prelude.
2616
2717
#![unstable(feature = "core_prelude",
2818
reason = "the libcore prelude has not been scrutinized and \

0 commit comments

Comments
 (0)