diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-07-29 17:01:14 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-08-03 17:23:01 -0700 |
| commit | 5cccf3cd256420d9f32c265e83036dea1d5f94d8 (patch) | |
| tree | 22904c7bb3df0872afa227638aa5e1e4ccb99fbc /src/libcore | |
| parent | ceded6adb3a4e172eabef09e1c78717a99c16b14 (diff) | |
| download | rust-5cccf3cd256420d9f32c265e83036dea1d5f94d8.tar.gz rust-5cccf3cd256420d9f32c265e83036dea1d5f94d8.zip | |
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]: https://github.com/rust-lang/rfcs/pull/1184
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/fmt/builders.rs | 2 | ||||
| -rw-r--r-- | src/libcore/fmt/mod.rs | 2 | ||||
| -rw-r--r-- | src/libcore/fmt/num.rs | 2 | ||||
| -rw-r--r-- | src/libcore/hash/mod.rs | 4 | ||||
| -rw-r--r-- | src/libcore/hash/sip.rs | 3 | ||||
| -rw-r--r-- | src/libcore/lib.rs | 7 | ||||
| -rw-r--r-- | src/libcore/num/f32.rs | 2 | ||||
| -rw-r--r-- | src/libcore/num/f64.rs | 2 | ||||
| -rw-r--r-- | src/libcore/num/flt2dec/bignum.rs | 5 | ||||
| -rw-r--r-- | src/libcore/num/flt2dec/decoder.rs | 2 | ||||
| -rw-r--r-- | src/libcore/num/flt2dec/mod.rs | 2 | ||||
| -rw-r--r-- | src/libcore/num/flt2dec/strategy/dragon.rs | 3 | ||||
| -rw-r--r-- | src/libcore/num/flt2dec/strategy/grisu.rs | 3 | ||||
| -rw-r--r-- | src/libcore/prelude/mod.rs | 13 | ||||
| -rw-r--r-- | src/libcore/prelude/v1.rs (renamed from src/libcore/prelude.rs) | 14 | ||||
| -rw-r--r-- | src/libcore/str/pattern.rs | 3 |
16 files changed, 40 insertions, 29 deletions
diff --git a/src/libcore/fmt/builders.rs b/src/libcore/fmt/builders.rs index 22f0215f0ad..39a067c1608 100644 --- a/src/libcore/fmt/builders.rs +++ b/src/libcore/fmt/builders.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use prelude::*; +use prelude::v1::*; use fmt::{self, Write, FlagV1}; struct PadAdapter<'a, 'b: 'a> { diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 02b23c6c7e7..668e2ecf1c6 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -12,7 +12,7 @@ #![stable(feature = "rust1", since = "1.0.0")] -use prelude::*; +use prelude::v1::*; use cell::{Cell, RefCell, Ref, RefMut, BorrowState}; use marker::PhantomData; diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 7cacc6af575..bffbb789f22 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -12,7 +12,7 @@ // FIXME: #6220 Implement floating point formatting -use prelude::*; +use prelude::v1::*; use fmt; use num::Zero; diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index e35f380d06f..34bc3b835a1 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -62,7 +62,7 @@ #![stable(feature = "rust1", since = "1.0.0")] -use prelude::*; +use prelude::v1::*; use mem; @@ -183,7 +183,7 @@ pub fn hash<T: Hash, H: Hasher + Default>(value: &T) -> u64 { ////////////////////////////////////////////////////////////////////////////// mod impls { - use prelude::*; + use prelude::v1::*; use slice; use super::*; diff --git a/src/libcore/hash/sip.rs b/src/libcore/hash/sip.rs index 93bdadff549..4dcd513a0d2 100644 --- a/src/libcore/hash/sip.rs +++ b/src/libcore/hash/sip.rs @@ -10,8 +10,9 @@ //! An implementation of SipHash 2-4. +use prelude::v1::*; + use ptr; -use prelude::*; use super::Hasher; /// An implementation of SipHash 2-4. diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 238644c4a26..56fb4c71a6a 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -60,8 +60,10 @@ html_playground_url = "http://play.rust-lang.org/")] #![doc(test(no_crate_inject))] -#![feature(no_std)] -#![no_std] +#![cfg_attr(stage0, feature(no_std))] +#![cfg_attr(stage0, no_std)] +#![cfg_attr(not(stage0), feature(no_core))] +#![cfg_attr(not(stage0), no_core)] #![allow(raw_pointer_derive)] #![deny(missing_docs)] @@ -168,6 +170,7 @@ mod tuple; // compiling the core library when it's compiling this library, so it expands // all references to `::core::$foo` #[doc(hidden)] +#[cfg(stage0)] mod core { pub use intrinsics; // derive(PartialOrd) pub use fmt; // format_args! diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 6b4424093b4..d0e6d4fa49c 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -15,7 +15,7 @@ #![stable(feature = "rust1", since = "1.0.0")] -use prelude::*; +use prelude::v1::*; use intrinsics; use mem; diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index fa7aa2ab5ce..bf7da04f995 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -15,7 +15,7 @@ #![stable(feature = "rust1", since = "1.0.0")] -use prelude::*; +use prelude::v1::*; use intrinsics; use mem; diff --git a/src/libcore/num/flt2dec/bignum.rs b/src/libcore/num/flt2dec/bignum.rs index 4f373c16f7c..1e39c53f9e0 100644 --- a/src/libcore/num/flt2dec/bignum.rs +++ b/src/libcore/num/flt2dec/bignum.rs @@ -21,7 +21,8 @@ #![macro_use] -use prelude::*; +use prelude::v1::*; + use mem; use intrinsics; @@ -351,7 +352,7 @@ define_bignum!(Big32x36: type=Digit32, n=36); // this one is used for testing only. #[doc(hidden)] pub mod tests { - use prelude::*; + use prelude::v1::*; define_bignum!(Big8x3: type=u8, n=3); } diff --git a/src/libcore/num/flt2dec/decoder.rs b/src/libcore/num/flt2dec/decoder.rs index f98bc11a315..a292ffa2e9d 100644 --- a/src/libcore/num/flt2dec/decoder.rs +++ b/src/libcore/num/flt2dec/decoder.rs @@ -10,7 +10,7 @@ //! Decodes a floating-point value into individual parts and error ranges. -use prelude::*; +use prelude::v1::*; use {f32, f64}; use num::{Float, FpCategory}; diff --git a/src/libcore/num/flt2dec/mod.rs b/src/libcore/num/flt2dec/mod.rs index f3a7e8f09a9..40fa2a5563d 100644 --- a/src/libcore/num/flt2dec/mod.rs +++ b/src/libcore/num/flt2dec/mod.rs @@ -129,7 +129,7 @@ functions. #![unstable(feature = "flt2dec", reason = "internal routines only exposed for testing")] -use prelude::*; +use prelude::v1::*; use i16; use num::Float; use slice::bytes; diff --git a/src/libcore/num/flt2dec/strategy/dragon.rs b/src/libcore/num/flt2dec/strategy/dragon.rs index a1137789371..b03286ddd0d 100644 --- a/src/libcore/num/flt2dec/strategy/dragon.rs +++ b/src/libcore/num/flt2dec/strategy/dragon.rs @@ -15,7 +15,8 @@ Almost direct (but slightly optimized) Rust translation of Figure 3 of [1]. quickly and accurately. SIGPLAN Not. 31, 5 (May. 1996), 108-116. */ -use prelude::*; +use prelude::v1::*; + use num::Float; use cmp::Ordering; diff --git a/src/libcore/num/flt2dec/strategy/grisu.rs b/src/libcore/num/flt2dec/strategy/grisu.rs index 54d3c92eca4..390920a354c 100644 --- a/src/libcore/num/flt2dec/strategy/grisu.rs +++ b/src/libcore/num/flt2dec/strategy/grisu.rs @@ -16,7 +16,8 @@ Rust adaptation of Grisu3 algorithm described in [1]. It uses about accurately with integers. SIGPLAN Not. 45, 6 (June 2010), 233-243. */ -use prelude::*; +use prelude::v1::*; + use num::Float; use num::flt2dec::{Decoded, MAX_SIG_DIGITS, round_up}; diff --git a/src/libcore/prelude/mod.rs b/src/libcore/prelude/mod.rs new file mode 100644 index 00000000000..b6c93615378 --- /dev/null +++ b/src/libcore/prelude/mod.rs @@ -0,0 +1,13 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The libcore prelude + +pub mod v1; diff --git a/src/libcore/prelude.rs b/src/libcore/prelude/v1.rs index ac153d64ab2..50dc9b7e043 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude/v1.rs @@ -11,18 +11,8 @@ //! The core prelude //! //! This module is intended for users of libcore which do not link to libstd as -//! well. This module is not imported by default, but using the entire contents -//! of this module will provide all of the useful traits and types in libcore -//! that one would expect from the standard library as well. -//! -//! There is no method to automatically inject this prelude, and this prelude is -//! a subset of the standard library's prelude. -//! -//! # Example -//! -//! ```ignore -//! use core::prelude::*; -//! ``` +//! well. This module is imported by default when `#![no_std]` is used in the +//! same manner as the standard library's prelude. #![unstable(feature = "core_prelude", reason = "the libcore prelude has not been scrutinized and \ diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index 2b3fc39fc8b..10ef689ba5d 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -16,7 +16,8 @@ #![unstable(feature = "pattern", reason = "API not fully fleshed out and ready to be stabilized")] -use prelude::*; +use prelude::v1::*; + use cmp; use usize; |
