Skip to content

Commit d788588

Browse files
author
Keegan McAllister
committed
Feature-gate #![no_std]
Fixes #21833. [breaking-change]
1 parent 67350bc commit d788588

Some content is hidden

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

47 files changed

+76
-22
lines changed

src/doc/reference.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2467,6 +2467,12 @@ The currently implemented features of the reference compiler are:
24672467

24682468
* `associated_types` - Allows type aliases in traits. Experimental.
24692469

2470+
* `no_std` - Allows the `#![no_std]` crate attribute, which disables the implicit
2471+
`extern crate std`. This typically requires use of the unstable APIs
2472+
behind the libstd "facade", such as libcore and libcollections. It
2473+
may also cause problems when using syntax extensions, including
2474+
`#[derive]`.
2475+
24702476
If a feature is promoted to a language feature, then all existing programs will
24712477
start to receive compilation warnings about #[feature] directives which enabled
24722478
the new feature (because the directive is no longer necessary). However, if a

src/doc/trpl/unsafe.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ attribute attached to the crate.
433433
```ignore
434434
// a minimal library
435435
#![crate_type="lib"]
436+
#![feature(no_std)]
436437
#![no_std]
437438
# // fn main() {} tricked you, rustdoc!
438439
```
@@ -446,8 +447,8 @@ The function marked `#[start]` is passed the command line parameters
446447
in the same format as C:
447448

448449
```
450+
#![feature(lang_items, start, no_std)]
449451
#![no_std]
450-
#![feature(lang_items, start)]
451452
452453
// Pull in the system libc library for what crt0.o likely requires
453454
extern crate libc;
@@ -473,6 +474,7 @@ correct ABI and the correct name, which requires overriding the
473474
compiler's name mangling too:
474475

475476
```ignore
477+
#![feature(no_std)]
476478
#![no_std]
477479
#![no_main]
478480
#![feature(lang_items, start)]
@@ -528,8 +530,8 @@ As an example, here is a program that will calculate the dot product of two
528530
vectors provided from C, using idiomatic Rust practices.
529531

530532
```
533+
#![feature(lang_items, start, no_std)]
531534
#![no_std]
532-
#![feature(lang_items, start)]
533535
534536
# extern crate libc;
535537
extern crate core;
@@ -652,8 +654,8 @@ and one for deallocation. A freestanding program that uses the `Box`
652654
sugar for dynamic allocations via `malloc` and `free`:
653655

654656
```
657+
#![feature(lang_items, box_syntax, start, no_std)]
655658
#![no_std]
656-
#![feature(lang_items, box_syntax, start)]
657659
658660
extern crate libc;
659661

src/liballoc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
6666
html_root_url = "http://doc.rust-lang.org/nightly/")]
6767

68+
#![feature(no_std)]
6869
#![no_std]
6970
#![feature(lang_items, unsafe_destructor)]
7071
#![feature(box_syntax)]

src/libcollections/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#![cfg_attr(test, feature(test))]
3434
#![cfg_attr(test, allow(deprecated))] // rand
3535

36+
#![feature(no_std)]
3637
#![no_std]
3738

3839
#[macro_use]

src/libcore/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
html_root_url = "http://doc.rust-lang.org/nightly/",
5757
html_playground_url = "http://play.rust-lang.org/")]
5858

59+
#![feature(no_std)]
5960
#![no_std]
6061
#![allow(raw_pointer_derive)]
6162
#![deny(missing_docs)]

src/liblibc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#![cfg_attr(not(feature = "cargo-build"), staged_api)]
1717
#![cfg_attr(not(feature = "cargo-build"), feature(core))]
1818
#![feature(int_uint)]
19+
#![feature(no_std)]
1920
#![no_std]
2021
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2122
html_favicon_url = "http://www.rust-lang.org/favicon.ico",

src/librand/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
html_root_url = "http://doc.rust-lang.org/nightly/",
2424
html_playground_url = "http://play.rust-lang.org/")]
2525
#![feature(int_uint)]
26+
#![feature(no_std)]
2627
#![no_std]
2728
#![unstable(feature = "rand")]
2829
#![feature(staged_api)]

src/librustc_bitflags/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#![feature(staged_api)]
1313
#![staged_api]
1414
#![crate_type = "rlib"]
15+
#![feature(no_std)]
1516
#![no_std]
1617
#![unstable(feature = "rustc_private")]
1718

src/librustc_driver/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct RH<'a> {
4343
sub: &'a [RH<'a>]
4444
}
4545

46-
static EMPTY_SOURCE_STR: &'static str = "#![no_std]";
46+
static EMPTY_SOURCE_STR: &'static str = "#![feature(no_std)] #![no_std]";
4747

4848
struct ExpectErrorEmitter {
4949
messages: Vec<String>

src/libstd/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
#![cfg_attr(test, feature(test))]
125125

126126
// Don't link to std. We are std.
127+
#![feature(no_std)]
127128
#![no_std]
128129

129130
#![deny(missing_docs)]

0 commit comments

Comments
 (0)