Skip to content

Commit 4f386db

Browse files
committed
Linkify $crate
1 parent 468b213 commit 4f386db

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/macros-by-example.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Valid fragment specifiers are:
134134
* `block`: a [BlockExpression]
135135
* `expr`: an [Expression]
136136
* `expr_2021`: an [Expression] except [UnderscoreExpression] and [ConstBlockExpression] (see [macro.decl.meta.edition2024])
137-
* `ident`: an [IDENTIFIER_OR_KEYWORD], [RAW_IDENTIFIER], or `$crate`
137+
* `ident`: an [IDENTIFIER_OR_KEYWORD], [RAW_IDENTIFIER], or [`$crate`]
138138
* `item`: an [Item]
139139
* `lifetime`: a [LIFETIME_TOKEN]
140140
* `literal`: matches `-`<sup>?</sup>[LiteralExpression]
@@ -151,10 +151,10 @@ r[macro.decl.meta.transcription]
151151
In the transcriber, metavariables are referred to simply by `$`_name_, since
152152
the fragment kind is specified in the matcher. Metavariables are replaced with
153153
the syntax element that matched them.
154+
Metavariables can be transcribed more than once or not at all.
154155

155156
r[macro.decl.meta.dollar-crate]
156-
The keyword metavariable `$crate` can be used to refer to the current crate; see [Hygiene] below. Metavariables can be
157-
transcribed more than once or not at all.
157+
The keyword metavariable [`$crate`] can be used to refer to the current crate.
158158

159159
r[macro.decl.meta.edition2021]
160160
> [!EDITION-2021]
@@ -594,3 +594,4 @@ For more detail, see the [formal specification].
594594
[Metavariables]: #metavariables
595595
[Repetitions]: #repetitions
596596
[token]: tokens.md
597+
[`$crate`]: macro.decl.hygiene.crate

src/paths.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,11 @@ r[paths.qualifiers.macro-crate]
368368
### `$crate`
369369

370370
r[paths.qualifiers.macro-crate.allowed-positions]
371-
`$crate` is only used within [macro transcribers], and can only be used as the first
371+
[`$crate`] is only used within [macro transcribers], and can only be used as the first
372372
segment, without a preceding `::`.
373373

374374
r[paths.qualifiers.macro-crate.hygiene]
375-
`$crate` will expand to a path to access items from the
375+
[`$crate`] will expand to a path to access items from the
376376
top level of the crate where the macro is defined, regardless of which crate the macro is
377377
invoked.
378378

@@ -472,6 +472,7 @@ mod without { // crate::without
472472
# fn main() {}
473473
```
474474

475+
[`$crate`]: macro.decl.hygiene.crate
475476
[implementations]: items/implementations.md
476477
[items]: items.md
477478
[literal]: expressions/literal-expr.md

src/procedural-macros.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ r[macro.proc.token.conversion.to-proc_macro]
350350
When passed to a proc-macro
351351
- All multi-character operators are broken into single characters.
352352
- Lifetimes are broken into a `'` character and an identifier.
353-
- The keyword metavariable `$crate` is passed as a single identifier.
353+
- The keyword metavariable [`$crate`] is passed as a single identifier.
354354
- All other metavariable substitutions are represented as their underlying
355355
token streams.
356356
- Such token streams may be wrapped into delimited groups ([`Group`]) with
@@ -377,6 +377,7 @@ their equivalent `#[doc = r"str"]` attributes when passed to macros.
377377
[Cargo's build scripts]: ../cargo/reference/build-scripts.html
378378
[Derive macros]: #derive-macros
379379
[Function-like macros]: #function-like-procedural-macros
380+
[`$crate`]: macro.decl.hygiene.crate
380381
[`Delimiter::None`]: proc_macro::Delimiter::None
381382
[`Group`]: proc_macro::Group
382383
[`TokenStream`]: proc_macro::TokenStream

0 commit comments

Comments
 (0)