VS Code extension that displays the documentation of a clippy lint in a dedicated tab of the bottom panel, from a clippy warning in the code.
Features
A Display lint rule: <lint> entry in the hover and in the Quick Fix menu of any code span flagged by clippy.
The documentation of the lint rendered in a Clippy Lint tab of the bottom panel.
One entry per lint when several clippy lints cover the same code span.
Requirements
The rust-analyzer extension, configured to run clippy: "rust-analyzer.check.command": "clippy". Without this setting, no clippy diagnostic is reported.
cargo with the clippy component, available in the PATH.
Usage
On a code span underlined by a clippy warning:
From the hover: hover over the code, then click the Display lint rule: <lint> link.
From the Quick Fix menu: click Quick Fix... in the hover (or Ctrl+., or the lightbulb in the gutter or in the Problems panel), then pick Display lint rule: <lint>.
The Clippy Lint tab of the bottom panel opens with the documentation of the lint.
How it works
The lint name is read from the clippy documentation URL (...index.html#needless_return), found either in the code or in the message of the diagnostic. The rust-analyzer extension replaces the code of the main diagnostic with a Click for full compiler diagnostic link.
The documentation comes from cargo clippy --explain <lint>, run from the directory of the file. It therefore matches the clippy version used by the project, rust-toolchain.toml included.
The resulting Markdown is converted to HTML by the markdown.api.render command of the Markdown extension built into VS Code. This command is not officially documented.