Feature-gate #![no_std]

Fixes #21833.

[breaking-change]
This commit is contained in:
Keegan McAllister 2015-02-05 16:14:42 -08:00
parent 67350bc868
commit d788588dce
47 changed files with 76 additions and 22 deletions

View File

@ -2467,6 +2467,12 @@ The currently implemented features of the reference compiler are:
* `associated_types` - Allows type aliases in traits. Experimental.
* `no_std` - Allows the `#![no_std]` crate attribute, which disables the implicit
`extern crate std`. This typically requires use of the unstable APIs
behind the libstd "facade", such as libcore and libcollections. It
may also cause problems when using syntax extensions, including
`#[derive]`.
If a feature is promoted to a language feature, then all existing programs will
start to receive compilation warnings about #[feature] directives which enabled
the new feature (because the directive is no longer necessary). However, if a

View File

@ -433,6 +433,7 @@ attribute attached to the crate.
```ignore
// a minimal library
#![crate_type="lib"]
#![feature(no_std)]
#![no_std]
# // fn main() {} tricked you, rustdoc!
```
@ -446,8 +447,8 @@ The function marked `#[start]` is passed the command line parameters
in the same format as C:
```
#![feature(lang_items, start, no_std)]
#![no_std]
#![feature(lang_items, start)]
// Pull in the system libc library for what crt0.o likely requires
extern crate libc;
@ -473,6 +474,7 @@ correct ABI and the correct name, which requires overriding the
compiler's name mangling too:
```ignore
#![feature(no_std)]
#![no_std]
#![no_main]
#![feature(lang_items, start)]
@ -528,8 +530,8 @@ As an example, here is a program that will calculate the dot product of two
vectors provided from C, using idiomatic Rust practices.
```
#![feature(lang_items, start, no_std)]
#![no_std]
#![feature(lang_items, start)]
# extern crate libc;
extern crate core;
@ -652,8 +654,8 @@ and one for deallocation. A freestanding program that uses the `Box`
sugar for dynamic allocations via `malloc` and `free`:
```
#![feature(lang_items, box_syntax, start, no_std)]
#![no_std]
#![feature(lang_items, box_syntax, start)]
extern crate libc;

View File

@ -65,6 +65,7 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(no_std)]
#![no_std]
#![feature(lang_items, unsafe_destructor)]
#![feature(box_syntax)]

View File

@ -33,6 +33,7 @@
#![cfg_attr(test, feature(test))]
#![cfg_attr(test, allow(deprecated))] // rand
#![feature(no_std)]
#![no_std]
#[macro_use]

View File

@ -56,6 +56,7 @@
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(no_std)]
#![no_std]
#![allow(raw_pointer_derive)]
#![deny(missing_docs)]

View File

@ -16,6 +16,7 @@
#![cfg_attr(not(feature = "cargo-build"), staged_api)]
#![cfg_attr(not(feature = "cargo-build"), feature(core))]
#![feature(int_uint)]
#![feature(no_std)]
#![no_std]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",

View File

@ -23,6 +23,7 @@
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(int_uint)]
#![feature(no_std)]
#![no_std]
#![unstable(feature = "rand")]
#![feature(staged_api)]

View File

@ -12,6 +12,7 @@
#![feature(staged_api)]
#![staged_api]
#![crate_type = "rlib"]
#![feature(no_std)]
#![no_std]
#![unstable(feature = "rustc_private")]

View File

@ -43,7 +43,7 @@ struct RH<'a> {
sub: &'a [RH<'a>]
}
static EMPTY_SOURCE_STR: &'static str = "#![no_std]";
static EMPTY_SOURCE_STR: &'static str = "#![feature(no_std)] #![no_std]";
struct ExpectErrorEmitter {
messages: Vec<String>

View File

@ -124,6 +124,7 @@
#![cfg_attr(test, feature(test))]
// Don't link to std. We are std.
#![feature(no_std)]
#![no_std]
#![deny(missing_docs)]

View File

@ -122,7 +122,10 @@ static KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
("staged_api", "1.0.0", Active),
// Allows using items which are missing stability attributes
("unmarked_api", "1.0.0", Active)
("unmarked_api", "1.0.0", Active),
// Allows using #![no_std]
("no_std", "1.0.0", Active),
];
enum Status {
@ -466,6 +469,11 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
attr.span,
"language items are subject to change");
}
if attr.check_name("no_std") {
self.gate_feature("no_std", attr.span,
"no_std is experimental");
}
}
fn visit_pat(&mut self, pattern: &ast::Pat) {

View File

@ -29,6 +29,7 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(no_std)]
#![no_std]
#![feature(slicing_syntax)]
#![feature(int_uint)]

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(no_std)]
#![no_std]
#![feature(lang_items)]

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(no_std)]
#![no_std]
pub fn foo() {}

View File

@ -13,6 +13,7 @@
// This aux-file will require the eh_personality function to be codegen'd, but
// it hasn't been defined just yet. Make sure we don't explode.
#![feature(no_std)]
#![no_std]
#![crate_type = "rlib"]

View File

@ -13,6 +13,7 @@
#![crate_type = "lib"]
#![feature(lang_items)]
#![feature(no_std)]
#![no_std]
#[lang="sized"]

View File

@ -10,6 +10,7 @@
// ignore-tidy-linelength
#![feature(no_std)]
#![no_std]
#![feature(lang_items)]

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(no_std)]
#![no_std]
extern crate core;

View File

@ -0,0 +1,13 @@
// Copyright 2105 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.
#![no_std] //~ ERROR no_std is experimental
fn main() {}

View File

@ -10,7 +10,7 @@
// error-pattern: requires `copy` lang_item
#![feature(lang_items, start)]
#![feature(lang_items, start, no_std)]
#![no_std]
#[lang = "sized"]

View File

@ -13,8 +13,8 @@
// error-pattern: requires `sized` lang_item
#![feature(start, no_std)]
#![no_std]
#![feature(start)]
#[start]
fn start(argc: isize, argv: *const *const u8) -> isize {

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(no_std)]
#![no_std]
#![allow(unused_variables)]
#![allow(non_camel_case_types)]

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(lang_items, start)]
#![feature(lang_items, start, no_std)]
#![no_std] // makes debugging this test *a lot* easier (during resolve)
#[lang="sized"]

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(start)]
#![feature(start, no_std)]
#![no_std] // makes debugging this test *a lot* easier (during resolve)
// Test to make sure that globs don't leak in regular `use` statements.

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(start)]
#![feature(start, no_std)]
#![no_std] // makes debugging this test *a lot* easier (during resolve)
// Test to make sure that private items imported through globs remain private

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(lang_items, start)]
#![feature(lang_items, start, no_std)]
#![no_std] // makes debugging this test *a lot* easier (during resolve)
#[lang = "sized"] pub trait Sized {}

View File

@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(lang_items, no_std)]
#![no_std]
#![feature(lang_items)]
// Check that explicit region bounds are allowed on the various
// nominal types (but not on other types) and that they are type

View File

@ -10,6 +10,7 @@
// Various examples of structs whose fields are not well-formed.
#![feature(no_std)]
#![no_std]
#![allow(dead_code)]

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(lang_items)]
#![feature(lang_items, no_std)]
#![no_std]
#[lang="sized"] pub trait Sized {}

View File

@ -13,6 +13,7 @@
// error-pattern: language item required, but not found: `stack_exhausted`
// error-pattern: language item required, but not found: `eh_personality`
#![feature(no_std)]
#![no_std]
extern crate core;

View File

@ -1,3 +1,4 @@
#![feature(no_std)]
#![no_std]
#[prelude_import]
use std::prelude::v1::*;

View File

@ -7,5 +7,6 @@
// <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.
#![feature(no_std)]
#![no_std]
extern crate foo;

View File

@ -7,5 +7,6 @@
// <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.
#![feature(no_std)]
#![no_std]
#![crate_type = "lib"]

View File

@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(lang_items, no_std)]
#![no_std]
#![feature(lang_items)]
#![crate_type = "dylib"]
extern crate libc;

View File

@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(lang_items, no_std)]
#![no_std]
#![feature(lang_items)]
#![crate_type = "dylib"]
extern crate libc;

View File

@ -9,6 +9,7 @@
// except according to those terms.
// minimal junk
#![feature(no_std)]
#![no_std]

View File

@ -9,6 +9,7 @@
// except according to those terms.
// minimal junk
#![feature(no_std)]
#![no_std]
macro_rules! foo {

View File

@ -12,6 +12,7 @@
#![crate_type = "lib"]
// we can compile to a variety of platforms, because we don't need
// cross-compiled standard libraries.
#![feature(no_std)]
#![no_std]
#![feature(simd, simd_ffi, link_llvm_intrinsics, lang_items)]

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(lang_items)]
#![feature(lang_items, no_std)]
#![no_std]
#[lang="copy"]

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(no_std)]
#![no_std]
extern crate core;

View File

@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(lang_items, start, no_std)]
#![no_std]
#![feature(lang_items, start)]
extern crate "std" as other;

View File

@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(lang_items, start, no_std)]
#![no_std]
#![feature(lang_items, start)]
extern crate "std" as other;

View File

@ -12,8 +12,8 @@
// ignore-android
// ignore-windows #13361
#![feature(lang_items, start, no_std)]
#![no_std]
#![feature(lang_items, start)]
extern crate "lang-item-public" as lang_lib;

View File

@ -16,6 +16,7 @@
// This tests that libraries built with #[no_std] can be linked to crates with
// #[no_std] and actually run.
#![feature(no_std)]
#![no_std]
extern crate no_std_crate;

View File

@ -12,8 +12,8 @@
// Smallest "hello world" with a libc runtime
#![feature(intrinsics, lang_items, start, no_std)]
#![no_std]
#![feature(intrinsics, lang_items, start)]
extern crate libc;

View File

@ -10,7 +10,7 @@
// except according to those terms.
#![allow(unused_imports)]
#![feature(start)]
#![feature(start, no_std)]
#![no_std]
extern crate std;

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(lang_items, start)]
#![feature(lang_items, start, no_std)]
#![no_std]
extern crate "std" as other;