Skip to content

Link Cargo lint message to its lint doc #17438

Description

@weihanglo

Problem

Cargo's lint messages currently look pretty similar to rustc's. They are fairly bare like "cargo::manual_readme is set to warn by default", without any further information. Of course, users can navigate to the Cargo Book and search for the lint, but there is room to improve the user experience.

Steps

Below is an example showing lints from three different sources all at once:

23:47:32❯ cargo +nightly clippy
warning: explicit `package.readme` can be inferred
 --> Cargo.toml:5:1
  |
5 | readme = "README.md"
  | ^^^^^^^^^^^^^^^^^^^^
  |
  = note: `cargo::manual_readme` is set to `warn` by default
help: consider removing `package.readme`
warning: `xxxx` (manifest) generated 1 warning
    Checking xxxx v0.1.0 (/projects/xxxx)
warning: unused variable: `x`
 --> src/main.rs:2:9
  |
2 |     let x = format!("foo");
  |         ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

warning: useless use of `format!`
 --> src/main.rs:2:13
  |
2 |     let x = format!("foo");
  |             ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#useless_format
  = note: `#[warn(clippy::useless_format)]` on by default

warning: `xxxx` (bin "xxxx") generated 2 warnings (run `cargo clippy --fix --bin "xxxx" -p xxxx -- ` to apply 2 suggestions)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.08s

Possible Solution(s)

Proposals in mind:

  • Make the lint name a terminal hyperlink (via term.hyperlinks). This keeps the terminal output less cluttered.
  • Like Clippy, provide a full-text hyperlink to the lint doc. This is more useful when debugging from CI logs.
  • Do nothing, which is also fine. LLM is fairly good to figure out these days.

Version

cargo 1.100.0-nightly (b2e9d5f9d 2026-09-02)
release: 1.100.0-nightly
commit-hash: b2e9d5f9db3fb1c454ab84f10c16508984a266e2
commit-date: 2026-09-02
host: aarch64-apple-darwin
libgit2: 1.9.6 (sys:0.21.0 vendored)
libcurl: 8.7.1 (sys:0.4.90+curl-8.21.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 3.6.3 9 Jun 2026
os: Mac OS 26.6.2 [64-bit]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Error and warning messages generated by Cargo itself.C-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions