From 90d3cc358e79715e9c9c8d1d678f451dc25fc7dd Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 20 Jun 2025 17:26:52 -0700 Subject: [PATCH 1/2] Unwrap crate_name --- src/crates-and-source-files.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/crates-and-source-files.md b/src/crates-and-source-files.md index c1f7d3dc6..f241dd199 100644 --- a/src/crates-and-source-files.md +++ b/src/crates-and-source-files.md @@ -139,16 +139,14 @@ r[crate.crate_name] ## The `crate_name` attribute r[crate.crate_name.general] -The *`crate_name` [attribute]* may be applied at the crate level to specify the -name of the crate with the [MetaNameValueStr] syntax. +The *`crate_name` [attribute]* may be applied at the crate level to specify the name of the crate with the [MetaNameValueStr] syntax. ```rust #![crate_name = "mycrate"] ``` r[crate.crate_name.restriction] -The crate name must not be empty, and must only contain [Unicode alphanumeric] -or `_` (U+005F) characters. +The crate name must not be empty, and must only contain [Unicode alphanumeric] or `_` (U+005F) characters. [^phase-distinction]: This distinction would also exist in an interpreter. Static checks like syntactic analysis, type checking, and lints should From 81efbd0afcd67b67c5509a0504b40971c6f6d8d8 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 20 Jun 2025 17:39:43 -0700 Subject: [PATCH 2/2] Update crate_name to use the attribute template --- src/crates-and-source-files.md | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/crates-and-source-files.md b/src/crates-and-source-files.md index f241dd199..b912682dc 100644 --- a/src/crates-and-source-files.md +++ b/src/crates-and-source-files.md @@ -138,14 +138,27 @@ The *`no_main` [attribute]* may be applied at the crate level to disable emittin r[crate.crate_name] ## The `crate_name` attribute -r[crate.crate_name.general] -The *`crate_name` [attribute]* may be applied at the crate level to specify the name of the crate with the [MetaNameValueStr] syntax. +r[crate.crate_name.intro] +The *`crate_name` [attribute]* specifies the name of the crate. -```rust -#![crate_name = "mycrate"] -``` +> [!EXAMPLE] +> ```rust +> #![crate_name = "mycrate"] +> ``` + +r[crate.crate_name.syntax] +The `crate_name` attribute uses the [MetaNameValueStr] syntax to specify the name of the crate. + +r[crate.crate_name.allowed-positions] +The `crate_name` attribute may only be applied to the crate root. + +r[crate.crate_name.duplicates] +Only the first `crate_name` attribute is used to determine the crate name. + +> [!NOTE] +> `rustc` currently warns on following duplicate `crate_name` attributes. This may become an error in the future. -r[crate.crate_name.restriction] +r[crate.crate_name.required-format] The crate name must not be empty, and must only contain [Unicode alphanumeric] or `_` (U+005F) characters. [^phase-distinction]: This distinction would also exist in an interpreter.