@@ -88,13 +88,13 @@ mod my_mod {
8888 pub type TypeAlias = MyEnum;
8989}
9090
91- // valid imports resolved at expansion-time
91+ // Valid imports resolved at expansion-time:
9292use my_mod::MyEnum; // OK
9393use my_mod::MyEnum::MyVariant; // OK
9494use my_mod::TypeAlias; // OK
9595use my_mod::CONST; // OK
9696
97- // valid expressions resolved during type-relative resolution
97+ // Valid expressions resolved during type-relative resolution:
9898let _ = my_mod::TypeAlias::MyVariant; // OK
9999let _ = my_mod::MyEnum::CONST; // OK
100100```
@@ -113,9 +113,9 @@ let _ = my_mod::MyEnum::CONST; // OK
113113#
114114# pub type TypeAlias = MyEnum;
115115# }
116- // invalid type-relative imports that can't resolve at expansion-time
117- use my_mod::TypeAlias::MyVariant; // Doesn't work
118- use my_mod::MyEnum::CONST; // Doesn't work
116+ // Invalid type-relative imports that can't resolve at expansion-time:
117+ use my_mod::TypeAlias::MyVariant; // ERROR: unresolved import `my_mod::TypeAlias`
118+ use my_mod::MyEnum::CONST; // ERROR: unresolved import `my_mod::MyEnum::CONST`
119119```
120120
121121r[names.resolution.expansion.imports.shadowing]
@@ -145,15 +145,15 @@ mod bar {
145145}
146146
147147use foo::*;
148- use bar::*; //~ OK, no name conflict.
148+ use bar::*; // OK, no name conflict.
149149
150150fn ambiguous_use() {
151151 // This would be an error, due to the ambiguity.
152152 //let x = Qux;
153153}
154154
155155fn ambiguous_shadow() {
156- // This is permitted, since resolution is not through the ambiguous globs
156+ // This is permitted, since resolution is not through the ambiguous globs.
157157 struct Qux;
158158 let x = Qux;
159159}
@@ -239,7 +239,7 @@ pub fn qux() {
239239> pub fn foo() {
240240> use bar::*;
241241> assert!(NAME);
242- > // ^--- this NAME is resolved during primary resolution
242+ > // ^--- This ` NAME` is resolved during primary resolution.
243243> }
244244> ```
245245
@@ -278,7 +278,7 @@ macro_rules! m {
278278}
279279pub fn foo() {
280280 m!(); // ERROR: `m` is ambiguous
281- use crate::m2 as m; // in scope for entire function body
281+ use crate::m2 as m; // In scope for entire function body.
282282}
283283```
284284
@@ -315,25 +315,6 @@ pub fn baz() {}
315315pub fn qux() {}
316316```
317317
318- r[names.resolution.expansion.imports.ambiguity.derivehelper]
319- Helper attributes may not be used before the macro that introduces them.
320-
321- > [!NOTE]
322- > rustc currently allows derive helpers to be used before their attribute macro introduces them into scope so long as they do not shadow any other attributes or derive helpers that are otherwise correctly in scope. This behavior is deprecated and slated for removal.
323- >
324- > TODO this is wrong
325- >
326- > <!-- ignore: requires external crates -->
327- > ```rust,ignore
328- > #[helper] // deprecated, hard error in the future
329- > #[derive(WithHelperAttr)]
330- > struct Struct {
331- > field: (),
332- > }
333- > ```
334- >
335- > For more details, see [Rust issue #79202](https://github.com/rust-lang/rust/issues/79202).
336-
337318r[names.resolution.expansion.macros]
338319### Macros
339320
@@ -343,20 +324,26 @@ Macros are resolved by iterating through the available scopes to find the availa
343324r[names.resolution.expansion.macros.visitation-order]
344325The available scopes are visited in the following order.
345326
346- * derive helpers
347- * derive helpers compat TODO admonitionify
348- * textual scope macros
349- * path-based scope macros
350- * macrouseprelude
351- * stdlibprelude
352- * builtinattrs
327+ * [derive helpers]
328+ * [textual scope macros]
329+ * [path-based scope macros]
330+ * [`macro_use` prelude]
331+ * [Standard library prelude]
332+ * [Builtin attributes]
333+
334+ > [!NOTE]
335+ >
336+ > The compiler will attempt to resolve derive helpers that are used before
337+ > their associated macro introduces them into scope after resolving derive
338+ > helper candidates that are correctly in scope. This behavior is slated for
339+ > removal.
340+ >
341+ > For more info see [derive helper scope].
353342
354343> [!EDITION-2018]
355344>
356345> Starting in edition 2018 the `#[macro_use]` prelude is not visited when `#[no_implicit_prelude]` is present.
357346
358- TODO linkify
359-
360347r[names.resolution.expansion.macros.derivehelpers]
361348not visited when resolving derive macros in the parent scope (starting scope)
362349
@@ -373,17 +360,25 @@ r[names.resolution.type-dependent]
373360> [!NOTE]
374361> This is a placeholder for future expansion about type-dependent resolution.
375362
363+ [Builtin attributes]: ./preludes.md#r-names.preludes.lang
376364[Macros]: ../macros.md
365+ [Standard library prelude]: ./preludes.md#r-names.preludes.std
377366[`let` bindings]: ../statements.md#let-statements
367+ [`macro_use` prelude]: ./preludes.md#r-names.preludes.macro_use
378368[`use` declarations]: ../items/use-declarations.md
379369[`use` glob shadowing]: ../items/use-declarations.md#r-items.use.glob.shadowing
370+ [derive helper scope]: ../procedural-macros.md#r-macro.proc.derive.attributes.scope
371+ [derive helpers]: ../procedural-macros.md#r-macro.proc.derive.attributes
380372[item definitions]: ../items.md
381373[macro invocations]: ../macros.md#macro-invocation
382374[macro textual scope shadowing]: ../macros-by-example.md#r-macro.decl.scope.textual.shadow
383375[namespaces]: ../names/namespaces.md
384- [outer scope]: #names.resolution.general.scopes
376+ [outer scope]: #r-names.resolution.general.scopes
377+ [path-based scope macros]: ../macros.md#r-macro.invocation.name-resolution
385378[path-based scope]: ../macros.md#r-macro.invocation.name-resolution
386379[permitted]: name-resolution.md#r-names.resolution.expansion.imports.shadowing
387380[scope]: ../names/scopes.md
388381[sub-namespace]: ../names/namespaces.md#r-names.namespaces.sub-namespaces
382+ [textual scope macros]: ../macros-by-example.md#r-macro.decl.scope.textual
389383[visibility]: ../visibility-and-privacy.md
384+
0 commit comments