Skip to content

Commit 3ba86bf

Browse files
authored
Merge pull request rust-lang#1914 from ehuss/no_implicit_prelude
Update `no_implicit_prelude` to use the attribute template
2 parents bbb5cc6 + a5a9f03 commit 3ba86bf

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

src/names/preludes.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,51 @@ r[names.preludes.tool.intro]
151151
The tool prelude includes tool names for external tools in the [type
152152
namespace]. See the [tool attributes] section for more details.
153153
154+
<!-- template:attributes -->
154155
r[names.preludes.no_implicit_prelude]
155156
## The `no_implicit_prelude` attribute
156157
157158
r[names.preludes.no_implicit_prelude.intro]
158-
The *`no_implicit_prelude` [attribute]* may be applied at the crate level or
159-
on a module to indicate that it should not automatically bring the [standard
160-
library prelude], [extern prelude], or [tool prelude] into scope for that
161-
module or any of its descendants.
159+
The *`no_implicit_prelude` [attribute]* is used to prevent implicit preludes from being brought into scope.
160+
161+
> [!EXAMPLE]
162+
> ```rust
163+
> // The attribute can be applied to the crate root to affect
164+
> // all modules.
165+
> #![no_implicit_prelude]
166+
>
167+
> // Or it can be applied to a module to only affect that module
168+
> // and its descendants.
169+
> #[no_implicit_prelude]
170+
> mod example {
171+
> // ...
172+
> }
173+
> ```
174+
175+
r[names.preludes.no_implicit_prelude.syntax]
176+
The `no_implicit_prelude` attribute uses the [MetaWord] syntax.
177+
178+
r[names.preludes.no_implicit_prelude.allowed-positions]
179+
The `no_implicit_prelude` attribute may only be applied to the crate or to a module.
180+
181+
> [!NOTE]
182+
> `rustc` ignores use in other positions but lints against it. This may become an error in the future.
183+
184+
r[names.preludes.no_implicit_prelude.duplicates]
185+
The `no_implicit_prelude` attribute may be used any number of times on a form.
186+
187+
> [!NOTE]
188+
> `rustc` lints against any use following the first.
189+
190+
r[names.preludes.no_implicit_prelude.excluded-preludes]
191+
The `no_implicit_prelude` attribute prevents the [standard library prelude], [extern prelude], [`macro_use` prelude], and the [tool prelude] from being brought into scope for the module and its descendants.
162192
163193
r[names.preludes.no_implicit_prelude.lang]
164-
This attribute does not affect the [language prelude].
194+
The `no_implicit_prelude` attribute does not affect the [language prelude].
165195
166196
r[names.preludes.no_implicit_prelude.edition2018]
167197
> [!EDITION-2018]
168-
> In the 2015 edition, the `no_implicit_prelude` attribute does not affect the [`macro_use` prelude], and all macros exported from the standard library are still included in the `macro_use` prelude. Starting in the 2018 edition, it will remove the `macro_use` prelude.
198+
> In the 2015 edition, the `no_implicit_prelude` attribute does not affect the [`macro_use` prelude], and all macros exported from the standard library are still included in the `macro_use` prelude. Starting in the 2018 edition, the attribute does remove the `macro_use` prelude.
169199
170200
[`extern crate`]: ../items/extern-crates.md
171201
[`macro_use` attribute]: ../macros-by-example.md#the-macro_use-attribute

0 commit comments

Comments
 (0)