Skip to content

Update no_implicit_prelude to use the attribute template #1914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions src/names/preludes.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,40 @@ r[names.preludes.no_implicit_prelude]
## The `no_implicit_prelude` attribute

r[names.preludes.no_implicit_prelude.intro]
The *`no_implicit_prelude` [attribute]* may be applied at the crate level or
on a module to indicate that it should not automatically bring the [standard
library prelude], [extern prelude], or [tool prelude] into scope for that
module or any of its descendants.
The *`no_implicit_prelude` [attribute]* is used to prevent implicit preludes from being brought into scope.

> [!EXAMPLE]
> ```rust
> // It can be applied to the crate root to apply to all modules.
> #![no_implicit_prelude]
>
> // Or it can be applied to a module to only affect that module or any of its descendants.
> #[no_implicit_prelude]
> mod example {
> // ...
> }
> ```

r[names.preludes.no_implicit_prelude.syntax]
The `no_implicit_prelude` attribute uses the [MetaWord] syntax and thus does not take any inputs.

r[names.preludes.no_implicit_prelude.allowed-positions]
The `no_implicit_prelude` attribute may only be applied to the crate level or a module.

> [!NOTE]
> `rustc` currently warns in other positions, but this may be rejected in the future.

r[names.preludes.no_implicit_prelude.duplicates]
Duplicate instances of the `no_implicit_prelude` attribute have no effect.

> [!NOTE]
> `rustc` currently warns on subsequent duplicate `no_implicit_prelude` attributes.

r[names.preludes.no_implicit_prelude.excluded-preludes]
The `no_implicit_prelude` attribute prevents the [standard library prelude], [extern prelude], and the [tool prelude] from being brought into scope for the module or any of its descendants.

r[names.preludes.no_implicit_prelude.lang]
This attribute does not affect the [language prelude].
The `no_implicit_prelude` attribute does not affect the [language prelude].

r[names.preludes.no_implicit_prelude.edition2018]
> [!EDITION-2018]
Expand Down