Skip to content
Merged
Show file tree
Hide file tree
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
31 changes: 26 additions & 5 deletions crates/xtask-lint-docs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,25 @@ fn main() -> anyhow::Result<()> {
writeln!(
buf,
"> [!NOTE]
> This chapter is about lints emitted by `cargo` itself.
>
> See [the lints section in the Manifest Format
> chapter](manifest.md#the-lints-section) to configure lint levels for tools
> such as `rustc` or `clippy`."
> This chapter is about lints emitted by `cargo` itself."
)?;
writeln!(buf)?;

writeln!(
buf,
r#"## Configuring Cargo lints

Cargo lints can be configured in the `[lints.cargo]` table of the `Cargo.toml` manifest.
The key is the lint name without the `cargo::` prefix.
For example:

```toml
[lints.cargo]
unused_dependencies = "deny"
```

See [the `[lints]` section](manifest.md#the-lints-section)
for details about lint levels and priorities."#
)?;
writeln!(buf)?;

Expand Down Expand Up @@ -83,6 +97,13 @@ fn main() -> anyhow::Result<()> {
}

fn lint_groups(buf: &mut String) -> anyhow::Result<()> {
writeln!(
buf,
r#"## Lint groups

Cargo has the concept of a "lint group",
where you can toggle several warnings through one name."#
)?;
let (max_name_len, max_desc_len) = cargo::diagnostics::LINT_GROUPS
.iter()
.filter(|g| !g.hidden)
Expand Down
22 changes: 18 additions & 4 deletions doc/book/src/reference/lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@

> [!NOTE]
> This chapter is about lints emitted by `cargo` itself.
>
> See [the lints section in the Manifest Format
> chapter](manifest.md#the-lints-section) to configure lint levels for tools
> such as `rustc` or `clippy`.

## Configuring Cargo lints

Cargo lints can be configured in the `[lints.cargo]` table of the `Cargo.toml` manifest.
The key is the lint name without the `cargo::` prefix.
For example:

```toml
[lints.cargo]
unused_dependencies = "deny"
```

See [the `[lints]` section](manifest.md#the-lints-section)
for details about lint levels and priorities.

## Lint groups

Cargo has the concept of a "lint group",
where you can toggle several warnings through one name.
Comment on lines +22 to +23

@weihanglo weihanglo Sep 5, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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



| Group | Description | Default level |
Expand Down
5 changes: 5 additions & 0 deletions doc/book/src/reference/manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -567,13 +567,18 @@ unsafe_code = "forbid"

[lints.clippy]
enum_glob_use = "deny"

[lints.cargo]
unused_dependencies = "deny"
```

Generally, these will only affect local development of the current package.
Cargo only applies these to the current package and not to dependencies.
As for dependents, Cargo suppresses lints from non-path dependencies with features like
[`--cap-lints`](../../rustc/lints/levels.html#capping-lints).

See also the [lints chapter](lints.md) for the available lints emitted by Cargo itself.

> **MSRV:** Respected as of 1.74

## The `[hints]` section
Expand Down
Loading