Skip to content

Latest commit

 

History

History
96 lines (73 loc) · 2.78 KB

basics.md

File metadata and controls

96 lines (73 loc) · 2.78 KB

Basics for hacking on Clippy

This document explains the basics for hacking on Clippy. Besides others, this includes how to build and test Clippy. For a more in depth description on the codebase take a look at Adding Lints or Common Tools.

Get the Code

First, make sure you have checked out the latest version of Clippy. If this is your first time working on Clippy, create a fork of the repository and clone it afterwards with the following command:

git clone git@github.com:<your-username>/rust-clippy

If you've already cloned Clippy in the past, update it to the latest version:

# upstream has to be the remote of the rust-lang/rust-clippy repo
git fetch upstream
# make sure that you are on the master branch
git checkout master
# rebase your master branch on the upstream master
git rebase upstream/master
# push to the master branch of your fork
git push

Building and Testing

You can build and test Clippy like every other Rust project:

cargo build  # builds Clippy
cargo test   # tests Clippy

Since Clippy's test suite is pretty big, there are some commands that only run a subset of Clippy's tests:

# only run UI tests
cargo uitest
# only run UI tests starting with `test_`
TESTNAME="test_" cargo uitest
# only run dogfood tests
cargo test --test dogfood

If the output of a UI test differs from the expected output, you can update the reference file with:

cargo dev bless

For example, this is necessary, if you fix a typo in an error message of a lint or if you modify a test file to add a test case.

Note: This command may update more files than you intended. In that case only commit the files you wanted to update.

cargo dev

Clippy has some dev tools to make working on Clippy more convenient. These tools can be accessed through the cargo dev command. Available tools are listed below. To get more information about these commands, just call them with --help.

# formats the whole Clippy codebase and all tests
cargo dev fmt
# register or update lint names/groups/...
cargo dev update_lints
# create a new lint and register it
cargo dev new_lint
# (experimental) Setup Clippy to work with rust-analyzer
cargo dev ra-setup

PR

We follow a rustc no merge-commit policy. See https://rustc-dev-guide.rust-lang.org/contributing.html#opening-a-pr.