rust-clippy

(★ 13,460)

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/

File Explorer

Showing a partial file list — download the zip above to see everything.

  • .editorconfig
  • .gitattributes
  • .gitignore
  • .remarkrc
  • askama.toml
  • build.rs
  • Cargo.toml
  • CHANGELOG.md
  • clippy.toml
  • CODE_OF_CONDUCT.md
  • CONTRIBUTING.md
  • COPYRIGHT
  • LICENSE-APACHE
  • LICENSE-MIT
  • README.md
  • rust-toolchain.toml
  • rustfmt.toml

# Installation Guide

rust
Prerequisites

Setup Steps

rustup update

Update Rustup and the compiler to the latest version.

rustup component add clippy

Install the clippy component via rustup.

cargo clippy

Run Clippy lints on your project.

Key Commands

cargo clippy

Analyze current Cargo project code and output lint warnings.

cargo clippy --fix

Automatically apply Clippy lint suggestions to the source code.

cargo clippy -p example

Run Clippy only on a specific package within the workspace.

clippy-driver --edition 2018 -Cpanic=abort foo.rs

Run Clippy directly instead of rustc for projects not using cargo.

You can use the CARGO_BUILD_WARNINGS=deny environment variable to treat warnings as errors.

# Use via CDN

jsDelivr

jsDelivr serves any public GitHub repository as a CDN with zero setup. Pick a version and a file to get a ready-to-paste link and snippet.

Showing a partial file list.

Command Glossary

Commands referenced in this DOCs, explained below.

🔍

cargo check

View Details ▼

Check a local package and all of its dependencies for errors.

cargo {{[c|check]}}

Check the current package:

cargo {{[c|check]}} --tests

Check all tests:

cargo {{[c|check]}} --test {{integration_test1}}

Check the integration tests in `tests/integration_test1.rs`:

🔍

cargo clippy

View Details ▼

A collection of lints to catch common mistakes and improve your Rust code.

cargo clippy

Run checks over the code in the current directory:

cargo clippy --locked

Require that `Cargo.lock` is up to date:

cargo clippy --workspace

Run checks on all packages in the workspace:

🔍

rustc

View Details ▼

The Rust compiler.
Rust projects usually use `cargo` instead of invoking `rustc` directly.

rustc {{path/to/main.rs}}

Compile a binary crate:

rustc {{[-C|--codegen]}} lto {{[-C|--codegen]}} opt-level={{0|1|2|3|s|z}} {{path/to/main.rs}}

Compile with optimizations (`s` means optimize for binary size; `z` is the same with even more optimizations):

rustc {{[-g|--codegen debuginfo=2]}} {{path/to/main.rs}}

Compile with debugging information:

🔍

rustup component

View Details ▼

Modify a toolchain's installed components.
Without the `--toolchain` option `rustup` will use the default toolchain. See `rustup help toolchain` for more information about toolchains.

rustup component add --toolchain {{toolchain}} {{component}}

Add a component to a toolchain:

rustup component remove --toolchain {{toolchain}} {{component}}

Remove a component from a toolchain:

rustup component list --toolchain {{toolchain}}

List installed and available components for a toolchain:

🔍

rustup self

View Details ▼

Modify the `rustup` installation.

rustup self update

Update `rustup`:

rustup self uninstall

Uninstall `rustup`:

🔍

rustup update

View Details ▼

Update Rust toolchains and `rustup` itself (if not installed using a package manager).

rustup update

Update all installed toolchains and `rustup`:

rustup update {{toolchain}}

Install or update a specific toolchain (see `rustup help toolchain` for more information):

# Project Badges

  • License: MIT OR Apache-2.0 License: MIT OR Apache-2.0 Visit
// repository documentation