From f5e9e9c2cc459fddd7a62d473887b7415cc9a133 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 31 May 2025 15:43:05 -0700 Subject: [PATCH 1/5] Unwrap no_implicit_prelude --- src/names/preludes.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/names/preludes.md b/src/names/preludes.md index 97edc59fc..8bce1ee4b 100644 --- a/src/names/preludes.md +++ b/src/names/preludes.md @@ -143,10 +143,7 @@ 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]* 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. r[names.preludes.no_implicit_prelude.lang] This attribute does not affect the [language prelude]. From 403222a169df17181f1cb2cb1c033ede2a5271da Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 31 May 2025 15:54:34 -0700 Subject: [PATCH 2/5] Add an example for no_implicit_prelude --- src/names/preludes.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/names/preludes.md b/src/names/preludes.md index 8bce1ee4b..c57c49ac2 100644 --- a/src/names/preludes.md +++ b/src/names/preludes.md @@ -145,6 +145,18 @@ r[names.preludes.no_implicit_prelude] 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. +> [!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.lang] This attribute does not affect the [language prelude]. From 8a3e7b70e2cc032487d3ba1bc8abbd2d087f8661 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 31 May 2025 15:55:11 -0700 Subject: [PATCH 3/5] Add explicit rules for no_implicit_prelude This is to follow the attribute template. --- src/names/preludes.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/names/preludes.md b/src/names/preludes.md index c57c49ac2..bb0b9aef1 100644 --- a/src/names/preludes.md +++ b/src/names/preludes.md @@ -157,6 +157,21 @@ The *`no_implicit_prelude` [attribute]* may be applied at the crate level or on > } > ``` +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.lang] This attribute does not affect the [language prelude]. From d4ca54a3f47b60e3eff1d471a73d310c909c6385 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 31 May 2025 15:56:23 -0700 Subject: [PATCH 4/5] Rewrite no_implicit_prelude to move to a specific rule This rewrites the intro to be a little more general, and moves the description of the behavior to a specific rule that can be cited. --- src/names/preludes.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/names/preludes.md b/src/names/preludes.md index bb0b9aef1..a7a04d34f 100644 --- a/src/names/preludes.md +++ b/src/names/preludes.md @@ -143,7 +143,7 @@ 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 @@ -172,6 +172,9 @@ 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]. From 19a6c42ed4b96548de5590b4c7e9f2cb5dc65bfa Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sat, 31 May 2025 15:57:08 -0700 Subject: [PATCH 5/5] Be explicit in the wording here --- src/names/preludes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/names/preludes.md b/src/names/preludes.md index a7a04d34f..abb56e1da 100644 --- a/src/names/preludes.md +++ b/src/names/preludes.md @@ -176,7 +176,7 @@ 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]