Skip to content

Commit 1ecce2d

Browse files
authored
Merge pull request #2307 from clarcharr/master
Rearrange README.md.
2 parents f0d0fc6 + 8abf964 commit 1ecce2d

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

README.md

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,35 @@ as an included feature during build. All of these options are detailed below.
2626

2727
As a general rule clippy will only work with the *latest* Rust nightly for now.
2828

29-
### Optional dependency
29+
### As a cargo subcommand (`cargo clippy`)
30+
31+
One way to use clippy is by installing clippy through cargo as a cargo
32+
subcommand.
33+
34+
```terminal
35+
cargo install clippy
36+
```
37+
38+
Now you can run clippy by invoking `cargo clippy`, or
39+
`cargo +nightly clippy` directly from a directory that is usually
40+
compiled with stable.
41+
42+
In case you are not using rustup, you need to set the environment flag
43+
`SYSROOT` during installation so clippy knows where to find `librustc` and
44+
similar crates.
45+
46+
```terminal
47+
SYSROOT=/path/to/rustc/sysroot cargo install clippy
48+
```
3049

31-
If you want to make clippy an optional dependency, you can do the following:
50+
### Optional dependency
3251

33-
In your `Cargo.toml`:
52+
In some cases you might want to include clippy in your project directly, as an
53+
optional dependency. To do this, just modify `Cargo.toml`:
3454

3555
```toml
3656
[dependencies]
37-
clippy = {version = "*", optional = true}
38-
39-
[features]
40-
default = []
57+
clippy = { version = "*", optional = true }
4158
```
4259

4360
And, in your `main.rs` or `lib.rs`, add these lines:
@@ -54,25 +71,18 @@ Instead of adding the `cfg_attr` attributes you can also run clippy on demand:
5471
(the `-Z no trans`, while not necessary, will stop the compilation process after
5572
typechecking (and lints) have completed, which can significantly reduce the runtime).
5673

57-
### As a cargo subcommand (`cargo clippy`)
74+
Alternatively, to only run clippy when testing:
5875

59-
An alternate way to use clippy is by installing clippy through cargo as a cargo
60-
subcommand.
61-
62-
```terminal
63-
cargo install clippy
76+
```toml
77+
[dev-dependencies]`
78+
clippy = { version = "*" }
6479
```
6580

66-
Now you can run clippy by invoking `cargo clippy`, or
67-
`rustup run nightly cargo clippy` directly from a directory that is usually
68-
compiled with stable.
81+
and add to `main.rs` or `lib.rs`:
6982

70-
In case you are not using rustup, you need to set the environment flag
71-
`SYSROOT` during installation so clippy knows where to find `librustc` and
72-
similar crates.
73-
74-
```terminal
75-
SYSROOT=/path/to/rustc/sysroot cargo install clippy
83+
```
84+
#![cfg_attr(test, feature(plugin))]
85+
#![cfg_attr(test, plugin(clippy))]
7686
```
7787

7888
### Running clippy from the command line without installing

0 commit comments

Comments
 (0)