Skip to content

Commit 354dc3f

Browse files
committed
The prelude is not a use statement
1 parent d5aa63d commit 354dc3f

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/crates-and-source-files.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,16 @@ fn main() {
8585

8686
## Preludes and `no_std`
8787

88-
All crates have a *prelude* that automatically inserts a [use declaration] into
89-
each [module] and an [`extern crate]` into the crate root module. By default,
90-
the *standard prelude* is used. The linked crate is [`std`] and the [use
91-
delcaration] uses [`std::prelude::v1::*`].
88+
All crates have a *prelude* that automatically inserts paths of a specific
89+
module, the *prelude module*, into scope of each [module] and an [`extern
90+
crate]` into the crate root module. By default, the *standard prelude* is used.
91+
The linked crate is [`std`] and the prelude module is [`std::prelude::v1`].
9292

9393
The prelude can be changed to the *core prelude* by using the `no_std`
9494
[attribute] on the root crate module. The linked crate is [`core`] and the
95-
[`use` declaration] uses [`core::prelude::v1::*`]. Using the core prelude over
96-
the standard prelude is useful when either the crate is targeting a platform
97-
that does not support the standard library or is purposefully not using the
95+
prelude module is [`core::prelude::v1`]. Using the core prelude over the
96+
standard prelude is useful when either the crate is targeting a platform that
97+
does not support the standard library or is purposefully not using the
9898
capabilities of the standard library. Those capabilities are mainly dynamic
9999
memory allocation (e.g. `Box` and `Vec`) and file and network capabilities (e.g.
100100
`std::fs` and `std::io`).
@@ -139,9 +139,9 @@ type must be one of the following:
139139
[_utf8 byte order mark_]: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8
140140
[`Termination`]: ../std/process/trait.Termination.html
141141
[`core`]: ../core/index.html
142-
[`core::prelude::v1::*`]: ../core/preludce.index.html
142+
[`core::prelude::v1`]: ../core/preludce.index.html
143143
[`std`]: ../std/index.html
144-
[`std::prelude::v1::*`]: ../std/prelude/index.html
144+
[`std::prelude::v1`]: ../std/prelude/index.html
145145
[`use` declaration]: items/use-declarations.html
146146
[attribute]: attributes.html
147147
[attributes]: attributes.html

src/items/modules.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@ mod thread {
6868
}
6969
```
7070

71-
Modules implicitly have a [use declaration] specified by crate's [prelude]. The
72-
[use declaration] can be removed by using the `no_implicit_prelude` [attribute].
71+
Modules implicitly have some paths in scope. These paths are to built-in types,
72+
macros imported with `#[macro_use]` on an extern crate, and by the crate's
73+
[prelude]. These paths are all made of a single identifier. These paths are not
74+
paths of the module, so for example, any path `path`, `self::path` is not also
75+
a valid path. The paths added by the [prelude] can be removed by placing the
76+
`no_implicit_prelude` [attribute] onto the module.
7377

7478
## Attributes on Modules
7579

0 commit comments

Comments
 (0)