Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the markdown source files of The Cargo Book #15113

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
1 change: 0 additions & 1 deletion src/doc/src/guide/cargo-toml-vs-cargo-lock.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,3 @@ that the argument to `cargo update` is actually a
short specification.

[def-manifest]: ../appendix/glossary.md#manifest '"manifest" (glossary entry)'
[def-package]: ../appendix/glossary.md#package '"package" (glossary entry)'
10 changes: 5 additions & 5 deletions src/doc/src/reference/build-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ one detailed below.
* [`cargo::rustc-cfg=KEY[="VALUE"]`](#rustc-cfg) --- Enables compile-time `cfg`
settings.
* [`cargo::rustc-check-cfg=CHECK_CFG`](#rustc-check-cfg) -- Register custom `cfg`s as
expected for compile-time checking of configs.
expected for compile-time checking of configs.
* [`cargo::rustc-env=VAR=VALUE`](#rustc-env) --- Sets an environment variable.
* [`cargo::rustc-cdylib-link-arg=FLAG`](#rustc-cdylib-link-arg) --- Passes custom
flags to a linker for cdylib crates.
- [`cargo::error=MESSAGE`](#cargo-error) --- Displays an error on the terminal.
* [`cargo::error=MESSAGE`](#cargo-error) --- Displays an error on the terminal.
* [`cargo::warning=MESSAGE`](#cargo-warning) --- Displays a warning on the
terminal.
* [`cargo::metadata=KEY=VALUE`](#the-links-manifest-key) --- Metadata, used by `links`
Expand Down Expand Up @@ -256,7 +256,7 @@ identifier, the value should be a string.
### `cargo::rustc-check-cfg=CHECK_CFG` {#rustc-check-cfg}

Add to the list of expected config names and values that is used when checking
the _reachable_ cfg expressions with the [`unexpected_cfgs`][unexpected-cfgs] lint.
the *reachable* cfg expressions with the [`unexpected_cfgs`][unexpected-cfgs] lint.

The syntax of `CHECK_CFG` mirrors the `rustc` [`--check-cfg` flag][option-check-cfg], see
[Checking conditional configurations][checking-conditional-configurations] for more details.
Expand Down Expand Up @@ -439,11 +439,11 @@ key-value pairs. This metadata is set with the `cargo::metadata=KEY=VALUE`
instruction.

The metadata is passed to the build scripts of **dependent** packages. For
example, if the package `foo` depends on `bar`, which links `baz`, then if
example, if the package `foo` depends on `bar`, which links `baz`, then if
`bar` generates `key=value` as part of its build script metadata, then the
build script of `foo` will have the environment variables `DEP_BAZ_KEY=value`
(note that the value of the `links` key is used).
See the ["Using another `sys` crate"][using-another-sys] for an example of
See the ["Using another `sys` crate"][using-another-sys] for an example of
how this can be used.

Note that metadata is only passed to immediate dependents, not transitive
Expand Down
2 changes: 0 additions & 2 deletions src/doc/src/reference/cargo-targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ name = "my-pg-tool"
required-features = ["postgres", "tools"]
```


## Target auto-discovery

By default, Cargo automatically determines the targets to build based on the
Expand Down Expand Up @@ -379,7 +378,6 @@ autobins = false
[`cargo test`]: ../commands/cargo-test.md
[cfg-test]: ../../reference/conditional-compilation.html#test
[crate types]: ../../reference/linkage.html
[crates.io]: https://crates.io/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't really follow the conversation, but it seems to me that the “Remove an unused link reference definition” changes could be combined into one commit, to avoid excessive commits. Anyway, it's up to you both to decide what’s better.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that I split my changes into several commits, one source file per commit. This is good for review. When merging, we can choose the option squash and merge:
2025-01-30_20-30

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Squash-and-merge is disabled in this repository (and in most repos in rust-lang org).
  • To myself, commit messages are not only for one-time review, but also for future bisects and reverts. This random article has explained it well
  • Again, I was just fly-by and wasn't really close enough to this PR review. I'll leave this to you and Ed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, its taken me some time to get back to this.

I think there was a misunderstanding. My intent wasn't literally one commit per source file but to fix one type of issue per commit.

Copy link
Author

@ShapelessCat ShapelessCat Feb 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole PR is about one issue, as mentioned in the title:
Fix link and image reference definitions and remove unused link and image reference definitions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix link and image reference definitions and remove unused link and image reference definitions.

Note that "and" as it shows that that statement is about resolving two problems.

However, its about more than two

  • Removing unused link definitions
  • Making list characters consistent
  • Removing trailing whitespace
  • Removing trailing lines
  • Making emphasis characters consistent
  • Changing the semver text
  • Fixing an unbalanced code fence
  • Adding additional links
  • Making table formatting consistent

I was looking for the commits to be oriented around these

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I edited the title and description.

[customized]: #configuring-a-target
[dependencies]: specifying-dependencies.md
[dev-dependencies]: specifying-dependencies.md#development-dependencies
Expand Down
2 changes: 0 additions & 2 deletions src/doc/src/reference/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ In summary, the supported environment variables are:
[`build.incremental`]: config.md#buildincremental
[`build.dep-info-basedir`]: config.md#builddep-info-basedir
[`doc.browser`]: config.md#docbrowser
[`cargo-new.name`]: config.md#cargo-newname
[`cargo-new.email`]: config.md#cargo-newemail
[`cargo-new.vcs`]: config.md#cargo-newvcs
[`future-incompat-report.frequency`]: config.md#future-incompat-reportfrequency
[`http.debug`]: config.md#httpdebug
Expand Down
6 changes: 1 addition & 5 deletions src/doc/src/reference/external-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ facilities:

* support for custom subcommands.


## Information about package structure

You can use [`cargo metadata`] command to get information about package
Expand Down Expand Up @@ -63,7 +62,6 @@ messages.
> **MSRV:** 1.77 is required for `package_id` to be a Package ID Specification. Before that, it was opaque.

[build command documentation]: ../commands/cargo-build.md
[cargo_metadata]: https://crates.io/crates/cargo_metadata
[Package ID Specifications]: ./pkgid-spec.md

### Compiler messages
Expand Down Expand Up @@ -203,7 +201,6 @@ following structure:
*/
"fresh": true
}

```

### Build script output
Expand Down Expand Up @@ -258,7 +255,7 @@ The "build-finished" message is emitted at the end of the build.
/* Whether or not the build finished successfully. */
"success": true,
}
````
```

This message can be helpful for tools to know when to stop reading JSON
messages. Commands such as `cargo test` or `cargo run` can produce additional
Expand Down Expand Up @@ -305,5 +302,4 @@ Instead, it is encouraged to use the CLI interface to drive Cargo. The [`cargo
metadata`] command can be used to obtain information about the current project
(the [`cargo_metadata`] crate provides a Rust interface to this command).

[`cargo metadata`]: ../commands/cargo-metadata.md
[`cargo_metadata`]: https://crates.io/crates/cargo_metadata
3 changes: 1 addition & 2 deletions src/doc/src/reference/features-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Some packages provide bindings to common C libraries (sometimes referred to as
C library installed on the system, or to build it from source. For example,
the [`openssl`] package has a [`vendored` feature][openssl-vendored] which
enables the corresponding `vendored` feature of [`openssl-sys`]. The
`openssl-sys` build script has some [conditional logic][openssl-sys-cfg] which
`openssl-sys` [build script] has some [conditional logic][openssl-sys-cfg] which
causes it to build from a local copy of the OpenSSL source code instead of
using the version from the system.

Expand Down Expand Up @@ -162,7 +162,6 @@ features.
The [`simd_support` feature][rand-simd_support] of the [`rand`] package is another example,
which relies on a dependency that only builds on the nightly channel.

[`wasm-bindgen`]: https://crates.io/crates/wasm-bindgen
[nightly channel]: ../../book/appendix-07-nightly-rust.html
[wasm-bindgen-nightly]: https://github.com/rustwasm/wasm-bindgen/blob/0.2.69/Cargo.toml#L27
[wasm-bindgen-unsize]: https://github.com/rustwasm/wasm-bindgen/blob/0.2.69/src/closure.rs#L257-L269
Expand Down
12 changes: 5 additions & 7 deletions src/doc/src/reference/manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,18 @@ For example, `1.0.0-alpha.11` is higher than `1.0.0-alpha.4`.
A metadata part can be added after a plus, such as `1.0.0+21AF26D3`.
This is for informational purposes only and is generally ignored by Cargo.

Cargo bakes in the concept of [Semantic Versioning](https://semver.org/),
so versions are considered [compatible](semver.md) if their left-most non-zero major/minor/patch component is the same.
See the [Resolver] chapter for more information on how Cargo uses versions to
resolve dependencies.
Cargo bakes in the concept of [SemVer], so versions are considered [compatible]
if their left-most non-zero major/minor/patch component is the same. See the
[Resolver] chapter for more information on how Cargo uses versions to resolve
dependencies.

This field is optional and defaults to `0.0.0`. The field is required for publishing packages.

> **MSRV:** Before 1.75, this field was required

[SemVer]: https://semver.org
[Resolver]: resolver.md
[SemVer compatibility]: semver.md
[compatible]: semver.md

### The `authors` field

Expand Down Expand Up @@ -612,8 +612,6 @@ The `[profile]` tables provide a way to customize compiler settings such as
optimizations and debug settings. See [the Profiles chapter](profiles.md) for
more detail.



[`cargo init`]: ../commands/cargo-init.md
[`cargo new`]: ../commands/cargo-new.md
[`cargo package`]: ../commands/cargo-package.md
Expand Down
14 changes: 7 additions & 7 deletions src/doc/src/reference/profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,18 +382,18 @@ The profile used depends on the command, the command-line flags like
| Command | Default Profile |
|---------|-----------------|
| [`cargo run`], [`cargo build`],<br>[`cargo check`], [`cargo rustc`] | [`dev` profile](#dev) |
| [`cargo test`] | [`test` profile](#test)
| [`cargo bench`] | [`bench` profile](#bench)
| [`cargo install`] | [`release` profile](#release)
| [`cargo test`] | [`test` profile](#test) |
| [`cargo bench`] | [`bench` profile](#bench) |
| [`cargo install`] | [`release` profile](#release) |

You can switch to a different profile using the `--profile=NAME` option which will used the given profile.
The `--release` flag is equivalent to `--profile=release`.

The selected profile applies to all Cargo targets,
The selected profile applies to all Cargo targets,
including [library](./cargo-targets.md#library),
[binary](./cargo-targets.md#binaries),
[example](./cargo-targets.md#examples),
[test](./cargo-targets.md#tests),
[binary](./cargo-targets.md#binaries),
[example](./cargo-targets.md#examples),
[test](./cargo-targets.md#tests),
and [benchmark](./cargo-targets.md#benchmarks).

The profile for specific packages can be specified with
Expand Down
1 change: 0 additions & 1 deletion src/doc/src/reference/publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ request the org owner to do so.
[`cargo publish`]: ../commands/cargo-publish.md
[`categories`]: manifest.md#the-categories-field
[`description`]: manifest.md#the-description-field
[`documentation`]: manifest.md#the-documentation-field
[`homepage`]: manifest.md#the-homepage-field
[`keywords`]: manifest.md#the-keywords-field
[`license` or `license-file`]: manifest.md#the-license-and-license-file-fields
Expand Down
2 changes: 0 additions & 2 deletions src/doc/src/reference/registries.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,11 @@ controlled via the [`registries.crates-io.protocol`] config key.
[Credential Provider Protocol]: credential-provider-protocol.md
[Registry Authentication]: registry-authentication.md
[`cargo publish`]: ../commands/cargo-publish.md
[`cargo package`]: ../commands/cargo-package.md
[`cargo login`]: ../commands/cargo-login.md
[config]: config.md
[crates.io]: https://crates.io/
[`registries.crates-io.protocol`]: config.md#registriescrates-ioprotocol


<script>
(function() {
var fragments = {
Expand Down
4 changes: 0 additions & 4 deletions src/doc/src/reference/registry-web-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,5 @@ The "login" endpoint is not an actual API request. It exists solely for the
browser to log in and retrieve an API token.

[`cargo login`]: ../commands/cargo-login.md
[`cargo package`]: ../commands/cargo-package.md
[`cargo publish`]: ../commands/cargo-publish.md
[alphanumeric]: ../../std/primitive.char.html#method.is_alphanumeric
[config]: config.md
[crates.io]: https://crates.io/
[publishing documentation]: publishing.md#cargo-owner
4 changes: 0 additions & 4 deletions src/doc/src/reference/resolver.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ situations:

[build-dependencies]: specifying-dependencies.md#build-dependencies
[dev-dependencies]: specifying-dependencies.md#development-dependencies
[resolver-field]: features.md#resolver-versions

### `links`

Expand Down Expand Up @@ -466,7 +465,6 @@ all platforms are enabled. In other words, the resolver ignores the platform
or `cfg` expression.

[build]: specifying-dependencies.md#build-dependencies
[dev-dependencies]: specifying-dependencies.md#development-dependencies
[Platform-specific dependencies]: specifying-dependencies.md#platform-specific-dependencies

### dev-dependency cycles
Expand Down Expand Up @@ -647,8 +645,6 @@ The use of open-ended version requirements like `>=0.6` is discouraged in Cargo.
But, if you run into this situation, the [`cargo update`] command with the
`--precise` flag can be used to manually remove such duplications.

[`cargo update`]: ../commands/cargo-update.md

### Why wasn't a newer version selected?

Say you noticed that the latest version of a dependency wasn't selected when you ran:
Expand Down
1 change: 0 additions & 1 deletion src/doc/src/reference/running-a-registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ for a list of what is available.

[Registry Web API]: registry-web-api.md
[Registry Index]: registry-index.md
[`cargo publish`]: ../commands/cargo-publish.md
[`cargo package`]: ../commands/cargo-package.md
1 change: 0 additions & 1 deletion src/doc/src/reference/semver.md
Original file line number Diff line number Diff line change
Expand Up @@ -2310,7 +2310,6 @@ document what your commitments are.
[items]: ../../reference/items.html
[non_exhaustive]: ../../reference/attributes/type_system.html#the-non_exhaustive-attribute
[object safe]: ../../reference/items/traits.html#object-safety
[rust-feature]: https://doc.rust-lang.org/nightly/unstable-book/
[sealed trait]: https://rust-lang.github.io/api-guidelines/future-proofing.html#sealed-traits-protect-against-downstream-implementations-c-sealed
[SemVer]: https://semver.org/
[struct literal]: ../../reference/expressions/struct-expr.html
Expand Down
12 changes: 5 additions & 7 deletions src/doc/src/reference/specifying-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This is different from [SemVer] which considers all pre-1.0.0 packages to be inc

### Caret requirements

**Caret requirements** are the default version requirement strategy.
**Caret requirements** are the default version requirement strategy.
This version strategy allows [SemVer] compatible updates.
They are specified as version requirements with a leading caret (`^`).

Expand Down Expand Up @@ -213,7 +213,7 @@ regex = { git = "https://github.com/rust-lang/regex.git" }
```

Cargo fetches the `git` repository at that location and traverses the file tree to find
`Cargo.toml` file for the requested crate anywhere inside the `git` repository.
`Cargo.toml` file for the requested crate anywhere inside the `git` repository.
For example, `regex-lite` and `regex-syntax` are members of `rust-lang/regex` repo
and can be referred to by the repo's root URL (`https://github.com/rust-lang/regex.git`)
regardless of where in the file tree they reside.
Expand All @@ -240,7 +240,7 @@ regex = { git = "https://github.com/rust-lang/regex.git", branch = "next" }

Anything that is not a branch or a tag falls under `rev` key. This can be a commit
hash like `rev = "4c59b707"`, or a named reference exposed by the remote
repository such as `rev = "refs/pull/493/head"`.
repository such as `rev = "refs/pull/493/head"`.

What references are available for the `rev` key varies by where the repo is hosted.
GitHub exposes a reference to the most recent commit of every pull request as in the example above.
Expand Down Expand Up @@ -280,7 +280,7 @@ The `version` key always implies that the package is available in a registry,
regardless of the presence of `git` or `path` keys.

The `version` key does _not_ affect which commit is used when Cargo retrieves the `git` dependency,
but Cargo checks the version information in the dependency's `Cargo.toml` file
but Cargo checks the version information in the dependency's `Cargo.toml` file
against the `version` key and raises an error if the check fails.

In this example, Cargo retrieves the HEAD commit of the branch called `next` from Git and checks if the crate's version
Expand All @@ -291,7 +291,7 @@ is compatible with `version = "1.10.3"`:
regex = { version = "1.10.3", git = "https://github.com/rust-lang/regex.git", branch = "next" }
```

`version`, `git`, and `path` keys are considered separate locations for resolving the dependency.
`version`, `git`, and `path` keys are considered separate locations for resolving the dependency.
See [Multiple locations](#multiple-locations) section below for detailed explanations.

> **Note**: [crates.io] does not allow packages to be published with
Expand Down Expand Up @@ -519,7 +519,6 @@ manifest:
cc = "1.0.3"
```


You can also have target-specific build dependencies by using
`build-dependencies` in the target section header instead of `dependencies`. For
example:
Expand Down Expand Up @@ -647,7 +646,6 @@ cc.workspace = true
rand = { workspace = true, optional = true }
```


[SemVer]: https://semver.org
[crates.io]: https://crates.io/
[dev-dependencies]: #development-dependencies
Expand Down