diff --git a/src/names/preludes.md b/src/names/preludes.md index 97edc59fc..abb56e1da 100644 --- a/src/names/preludes.md +++ b/src/names/preludes.md @@ -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]