Skip to content

Commit 81efbd0

Browse files
committed
Update crate_name to use the attribute template
1 parent 90d3cc3 commit 81efbd0

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/crates-and-source-files.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,27 @@ The *`no_main` [attribute]* may be applied at the crate level to disable emittin
138138
r[crate.crate_name]
139139
## The `crate_name` attribute
140140

141-
r[crate.crate_name.general]
142-
The *`crate_name` [attribute]* may be applied at the crate level to specify the name of the crate with the [MetaNameValueStr] syntax.
141+
r[crate.crate_name.intro]
142+
The *`crate_name` [attribute]* specifies the name of the crate.
143143

144-
```rust
145-
#![crate_name = "mycrate"]
146-
```
144+
> [!EXAMPLE]
145+
> ```rust
146+
> #![crate_name = "mycrate"]
147+
> ```
148+
149+
r[crate.crate_name.syntax]
150+
The `crate_name` attribute uses the [MetaNameValueStr] syntax to specify the name of the crate.
151+
152+
r[crate.crate_name.allowed-positions]
153+
The `crate_name` attribute may only be applied to the crate root.
154+
155+
r[crate.crate_name.duplicates]
156+
Only the first `crate_name` attribute is used to determine the crate name.
157+
158+
> [!NOTE]
159+
> `rustc` currently warns on following duplicate `crate_name` attributes. This may become an error in the future.
147160
148-
r[crate.crate_name.restriction]
161+
r[crate.crate_name.required-format]
149162
The crate name must not be empty, and must only contain [Unicode alphanumeric] or `_` (U+005F) characters.
150163
151164
[^phase-distinction]: This distinction would also exist in an interpreter.

0 commit comments

Comments
 (0)