@@ -14,6 +14,7 @@ the codebase take a look at [Adding Lints] or [Common Tools].
14
14
- [ lintcheck] ( #lintcheck )
15
15
- [ PR] ( #pr )
16
16
- [ Common Abbreviations] ( #common-abbreviations )
17
+ - [ Install from source] ( #install-from-source )
17
18
18
19
## Get the Code
19
20
@@ -128,4 +129,45 @@ This is a concise list of abbreviations that can come up during Clippy developme
128
129
general list can be found in the [ rustc-dev-guide glossary] [ glossary ] . Always feel free to ask if
129
130
an abbreviation or meaning is unclear to you.
130
131
132
+ ## Install from source
133
+
134
+ If you are hacking on Clippy and want to install it from source, do the following:
135
+
136
+ First, take note of the toolchain [ override] ( https://rust-lang.github.io/rustup/overrides.html ) in ` /rust-toolchain ` .
137
+ We will use this override to install Clippy into the right toolchain.
138
+
139
+ > Tip: You can view the active toolchain for the current directory with ` rustup show active-toolchain ` .
140
+
141
+ From the Clippy project root, run the following command to build the Clippy binaries and copy them into the
142
+ toolchain directory. This will override the currently installed Clippy component.
143
+
144
+ ``` terminal
145
+ cargo build --release --bin cargo-clippy --bin clippy-driver -Zunstable-options --out-dir "$(rustc --print=sysroot)/bin"
146
+ ```
147
+
148
+ Now you may run ` cargo clippy ` in any project, using the toolchain where you just installed Clippy.
149
+
150
+ ``` terminal
151
+ cd my-project
152
+ cargo +nightly-2021-07-01 clippy
153
+ ```
154
+
155
+ ...or ` clippy-driver `
156
+
157
+ ``` terminal
158
+ clippy-driver +nightly-2021-07-01 <filename>
159
+ ```
160
+
161
+ If you need to restore the default Clippy installation, run the following (from the Clippy project root).
162
+
163
+ ``` terminal
164
+ rustup component remove clippy
165
+ rustup component add clippy
166
+ ```
167
+
168
+ > ** DO NOT** install using ` cargo install --path . --force ` since this will overwrite rustup
169
+ [ proxies] ( https://rust-lang.github.io/rustup/concepts/proxies.html ) . That is, ` ~/.cargo/bin/cargo-clippy ` and
170
+ ` ~/.cargo/bin/clippy-driver ` should be hard or soft links to ` ~/.cargo/bin/rustup ` . You can repair these by running
171
+ ` rustup update ` .
172
+
131
173
[ glossary ] : https://rustc-dev-guide.rust-lang.org/appendix/glossary.html
0 commit comments