diff --git a/src/crates-and-source-files.md b/src/crates-and-source-files.md index e43c06e4d0..9fd919da64 100644 --- a/src/crates-and-source-files.md +++ b/src/crates-and-source-files.md @@ -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]. + 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] +> +> ```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