@@ -228,6 +228,7 @@ files ([?][rationale-cargo-lock]).
228228
229229*See the following sections for future possibilities:*
230230
231+ - [*Replace `#![no_std]` as the source-of-truth for whether a crate depends on `std`*][future-replace-no_std]
231232- [*Allow unstable crate names to be referenced behind cfgs without requiring nightly*][future-cfg-unstable-crate-name]
232233- [*Allow `builtin` source replacement*][future-source-replacement]
233234- [*Remove `rustc_dep_of_std`*][future-rustc_dep_of_std]
@@ -1041,6 +1042,33 @@ of the build-std context RFC.
10411042
10421043There are many possible follow-ups to this part of the RFC:
10431044
1045+ ## Replace `#![no_std]` as the source-of-truth for whether a crate depends on `std`
1046+ [future-replace-no_std]: #replace-no_std-as-the-source-of-truth-for-whether-a-crate-depends-on-std
1047+
1048+ Crates can currently use the crate attribute `#![no_std]` to indicate a lack of
1049+ dependency on `std`. Introducing `build-std-crates` from [RFC #3874][rfcs#3874]
1050+ or explicit dependencies would add a second way for the user to indicate a lack
1051+ of dependency on the standard library. It could therefore be desirable to
1052+ deprecate `#![no_std]` so that there remains only a single way to express a
1053+ dependency on the standard library.
1054+
1055+ `#![no_std]` serves two purposes - it stops the compiler from adding `std` to
1056+ the extern prelude and it prevents the user from depending on anything from
1057+ `std` accidentally. rustc's default behaviour of loading `std` when not
1058+ explicitly provided the crate via an `--extern` flag should be preserved for
1059+ backwards-compatibility with existing direct invocations of rustc.
1060+
1061+ `#![no_std]` could instead become a compiler flag which would indicate to the
1062+ compiler that `std` should not be loaded by default and that `core`'s prelude
1063+ should be used instead. Cargo would use this flag when driving rustc, providing
1064+ explicit paths to the newly-built or pre-built standard library crates, just as
1065+ with any other dependency.
1066+
1067+ In addition, `#![no_std]` could be migrated to denying a lint which would
1068+ prevent use of items from `std`.
1069+
1070+ ↩ [*Proposal*][proposal]
1071+
10441072## Allow unstable crate names to be referenced behind cfgs without requiring nightly
10451073[future-cfg-unstable-crate-name]: #allow-unstable-crate-names-to-be-referenced-behind-cfgs-without-requiring-nightly
10461074
0 commit comments