Skip to content

Commit 9f9e8f0

Browse files
committed
Update no_main to use the attribute template
1 parent cc7247d commit 9f9e8f0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/crates-and-source-files.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,27 @@ For more information, see the [panic documentation][panic-docs].
133133
r[crate.no_main]
134134
### The `no_main` attribute
135135

136+
r[crate.no_main.intro]
136137
The *`no_main` [attribute]* may be applied at the crate level to disable emitting the `main` symbol for an executable binary. This is useful when some other object being linked to defines `main`.
137138

139+
> [!EXAMPLE]
140+
> <!-- ignore: does not work with test framework -->
141+
> ```rust,ignore
142+
> #![no_main]
143+
> ```
144+
145+
r[crate.no_main.syntax]
146+
The `no_main` attribute uses the [MetaWord] syntax and thus does not take any inputs.
147+
148+
r[crate.no_main.allowed-positions]
149+
The `no_main` attribute may only be applied to the crate root.
150+
151+
r[crate.no_main.duplicates]
152+
Duplicate instances of the `no_main` attribute are ignored.
153+
154+
> [!NOTE]
155+
> `rustc` current warns about unused duplicate `no_main` attributes.
156+
138157
r[crate.crate_name]
139158
## The `crate_name` attribute
140159

0 commit comments

Comments
 (0)