diff --git a/src/names/preludes.md b/src/names/preludes.md index 4c1568ada..00a112948 100644 --- a/src/names/preludes.md +++ b/src/names/preludes.md @@ -18,9 +18,21 @@ There are several different preludes: ## Standard library prelude -The standard library prelude includes names from the [`std::prelude::v1`] -module. If the [`no_std` attribute] is used, then it instead uses the names -from the [`core::prelude::v1`] module. +Each crate has a standard library prelude, which consists of the names from a single standard library module. +The module used depends on the crate's edition, and on whether the [`no_std` attribute] is applied to the crate: + +Edition | `no_std` not applied | `no_std` applied +--------| --------------------------- | ---------------------------- +2015 | [`std::prelude::rust_2015`] | [`core::prelude::rust_2015`] +2018 | [`std::prelude::rust_2018`] | [`core::prelude::rust_2018`] +2021 | [`std::prelude::rust_2021`] | [`core::prelude::rust_2021`] + + +> **Note**: +> +> [`std::prelude::rust_2015`] and [`std::prelude::rust_2018`] have the same contents as [`std::prelude::v1`]. +> +> [`core::prelude::rust_2015`] and [`core::prelude::rust_2018`] have the same contents as [`core::prelude::v1`]. ## Extern prelude @@ -63,15 +75,13 @@ By default, the standard library is automatically included in the crate root module. The [`std`] crate is added to the root, along with an implicit [`macro_use` attribute] pulling in all macros exported from `std` into the [`macro_use` prelude]. Both [`core`] and [`std`] are added to the [extern -prelude]. The [standard library prelude] includes everything from the -[`std::prelude::v1`] module. +prelude]. The *`no_std` [attribute]* may be applied at the crate level to prevent the [`std`] crate from being automatically added into scope. It does three things: * Prevents `std` from being added to the [extern prelude](#extern-prelude). -* Uses [`core::prelude::v1`] in the [standard library prelude] instead of - [`std::prelude::v1`]. +* Affects which module is used to make up the [standard library prelude] (as described above). * Injects the [`core`] crate into the crate root instead of [`std`], and pulls in all macros exported from `core` in the [`macro_use` prelude]. @@ -129,14 +139,20 @@ This attribute does not affect the [language prelude]. [`alloc`]: ../../alloc/index.html [`Box`]: ../../std/boxed/struct.Box.html -[`core::prelude::v1`]: ../../core/prelude/index.html +[`core::prelude::v1`]: ../../core/prelude/v1/index.html +[`core::prelude::rust_2015`]: ../../core/prelude/rust_2015/index.html +[`core::prelude::rust_2018`]: ../../core/prelude/rust_2018/index.html +[`core::prelude::rust_2021`]: ../../core/prelude/rust_2021/index.html [`core`]: ../../core/index.html [`extern crate`]: ../items/extern-crates.md [`macro_use` attribute]: ../macros-by-example.md#the-macro_use-attribute [`macro_use` prelude]: #macro_use-prelude [`no_std` attribute]: #the-no_std-attribute [`no_std` attribute]: #the-no_std-attribute -[`std::prelude::v1`]: ../../std/prelude/index.html +[`std::prelude::v1`]: ../../std/prelude/v1/index.html +[`std::prelude::rust_2015`]: ../../std/prelude/rust_2015/index.html +[`std::prelude::rust_2018`]: ../../std/prelude/rust_2018/index.html +[`std::prelude::rust_2021`]: ../../std/prelude/rust_2021/index.html [`std`]: ../../std/index.html [`test`]: ../../test/index.html [attribute]: ../attributes.md