Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/crates-and-source-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,31 @@ When a "foreign" unwind (e.g. an exception thrown from C++ code, or a `panic!` i

For more information, see the [panic documentation][panic-docs].

<!-- template:attributes -->
r[crate.no_main]
### The `no_main` attribute

r[crate.no_main.intro]
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`.

> [!EXAMPLE]
> <!-- ignore: does not work with test framework -->
> ```rust,ignore
> #![no_main]
> ```

r[crate.no_main.syntax]
The `no_main` attribute uses the [MetaWord] syntax.

r[crate.no_main.allowed-positions]
The `no_main` attribute may only be applied to the crate root.

r[crate.no_main.duplicates]
The `no_main` attribute may be used any number of times on the crate root.

> [!NOTE]
> `rustc` lints against any use following the first.

r[crate.crate_name]
## The `crate_name` attribute

Expand Down