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
This commit is contained in:
Alex Crichton
2015-07-29 17:01:14 -07:00
parent ceded6adb3
commit 5cccf3cd25
157 changed files with 478 additions and 385 deletions

View File

@@ -71,7 +71,8 @@
use boxed::Box;
use core::prelude::*;
#[cfg(stage0)]
use core::prelude::v1::*;
use core::atomic;
use core::atomic::Ordering::{Relaxed, Release, Acquire, SeqCst};

View File

@@ -53,7 +53,8 @@
#![stable(feature = "rust1", since = "1.0.0")]
use core::prelude::*;
#[cfg(stage0)]
use core::prelude::v1::*;
use heap;
use raw_vec::RawVec;

View File

@@ -75,7 +75,6 @@
#![feature(coerce_unsized)]
#![feature(core)]
#![feature(core_intrinsics)]
#![feature(core_prelude)]
#![feature(core_slice_ext)]
#![feature(custom_attribute)]
#![feature(fundamental)]
@@ -93,17 +92,17 @@
#![feature(unsize)]
#![feature(core_slice_ext)]
#![feature(core_str_ext)]
#![cfg_attr(stage0, feature(core, core_prelude))]
#![cfg_attr(test, feature(test, alloc, rustc_private, box_raw))]
#![cfg_attr(all(not(feature = "external_funcs"), not(feature = "external_crate")),
feature(libc))]
#[macro_use]
extern crate core;
#[cfg(all(not(feature = "external_funcs"), not(feature = "external_crate")))]
extern crate libc;
#[cfg(stage0)] #[macro_use] extern crate core;
// Allow testing this library
#[cfg(test)] #[macro_use] extern crate std;

View File

@@ -150,7 +150,8 @@
#![stable(feature = "rust1", since = "1.0.0")]
use core::prelude::*;
#[cfg(stage0)]
use core::prelude::v1::*;
#[cfg(not(test))]
use boxed::Box;