Skip to content

Commit 91a6b8f

Browse files
committed
Auto merge of #13887 - weihanglo:message, r=Muscraft
docs: clarify dash replacement rule in target name
2 parents 6914ead + 4b3123e commit 91a6b8f

File tree

7 files changed

+25
-14
lines changed

7 files changed

+25
-14
lines changed

src/doc/man/cargo-metadata.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ The JSON output has the following format:
151151
"crate_types": [
152152
"bin"
153153
],
154-
/* The name of the target. */
154+
/* The name of the target.
155+
For lib targets, dashes will be replaced with underscores.
156+
*/
155157
"name": "my-package",
156158
/* Absolute path to the root source file of the target. */
157159
"src_path": "/path/to/my-package/src/main.rs",

src/doc/man/generated_txt/cargo-metadata.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ OUTPUT FORMAT
147147
"crate_types": [
148148
"bin"
149149
],
150-
/* The name of the target. */
150+
/* The name of the target.
151+
For lib targets, dashes will be replaced with underscores.
152+
*/
151153
"name": "my-package",
152154
/* Absolute path to the root source file of the target. */
153155
"src_path": "/path/to/my-package/src/main.rs",

src/doc/src/commands/cargo-metadata.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ The JSON output has the following format:
151151
"crate_types": [
152152
"bin"
153153
],
154-
/* The name of the target. */
154+
/* The name of the target.
155+
For lib targets, dashes will be replaced with underscores.
156+
*/
155157
"name": "my-package",
156158
/* Absolute path to the root source file of the target. */
157159
"src_path": "/path/to/my-package/src/main.rs",

src/doc/src/reference/cargo-targets.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ configuring the settings for a target.
1414

1515
The library target defines a "library" that can be used and linked by other
1616
libraries and executables. The filename defaults to `src/lib.rs`, and the name
17-
of the library defaults to the name of the package. A package can have only
18-
one library. The settings for the library can be [customized] in the `[lib]`
19-
table in `Cargo.toml`.
17+
of the library defaults to the name of the package, with any dashes replaced
18+
with underscores. A package can have only one library. The settings for the
19+
library can be [customized] in the `[lib]` table in `Cargo.toml`.
2020

2121
```toml
2222
# Example of customizing the library in Cargo.toml.
@@ -198,9 +198,10 @@ The `name` field specifies the name of the target, which corresponds to the
198198
filename of the artifact that will be generated. For a library, this is the
199199
crate name that dependencies will use to reference it.
200200

201-
For the `[lib]` and the default binary (`src/main.rs`), this defaults to the
202-
name of the package, with any dashes replaced with underscores. For other
203-
[auto discovered](#target-auto-discovery) targets, it defaults to the
201+
For the library target, this defaults to the name of the package , with any
202+
dashes replaced with underscores. For the default binary (`src/main.rs`),
203+
it also defaults to the name of the package, with no replacement for dashes.
204+
For [auto discovered](#target-auto-discovery) targets, it defaults to the
204205
directory or file name.
205206

206207
This is required for all targets except `[lib]`.

src/doc/src/reference/external-tools.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ structure:
9797
"crate_types": [
9898
"lib"
9999
],
100-
/* The name of the target. */
101-
"name": "my-package",
100+
/* The name of the target.
101+
For lib targets, dashes will be replaced with underscores.
102+
*/
103+
"name": "my_package",
102104
/* Absolute path to the root source file of the target. */
103105
"src_path": "/path/to/my-package/src/lib.rs",
104106
/* The Rust edition of the target.
@@ -152,7 +154,7 @@ following structure:
152154
"crate_types": [
153155
"lib"
154156
],
155-
"name": "my-package",
157+
"name": "my_package",
156158
"src_path": "/path/to/my-package/src/lib.rs",
157159
"edition": "2018",
158160
"doc": true,

src/doc/src/reference/unstable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ The following is a description of the JSON structure:
645645
"target": {
646646
"kind": ["lib"],
647647
"crate_types": ["lib"],
648-
"name": "my-package",
648+
"name": "my_package",
649649
"src_path": "/path/to/my-package/src/lib.rs",
650650
"edition": "2018",
651651
"test": true,

src/etc/man/cargo-metadata.1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ The JSON output has the following format:
153153
"crate_types": [
154154
"bin"
155155
],
156-
/* The name of the target. */
156+
/* The name of the target.
157+
For lib targets, dashes will be replaced with underscores.
158+
*/
157159
"name": "my\-package",
158160
/* Absolute path to the root source file of the target. */
159161
"src_path": "/path/to/my\-package/src/main.rs",

0 commit comments

Comments
 (0)