Skip to content

Commit 8f900d8

Browse files
committed
CONTRIBUTING: explain how to use cargo dev ra-setup
Fixes #5514
1 parent 7ea7cd1 commit 8f900d8

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

CONTRIBUTING.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ anything, feel free to ask questions on issues or visit the `#clippy` on [Discor
1212

1313
All contributors are expected to follow the [Rust Code of Conduct].
1414

15-
* [Getting started](#getting-started)
16-
* [Finding something to fix/improve](#finding-something-to-fiximprove)
17-
* [Writing code](#writing-code)
18-
* [How Clippy works](#how-clippy-works)
19-
* [Fixing nightly build failures](#fixing-build-failures-caused-by-rust)
20-
* [Issue and PR Triage](#issue-and-pr-triage)
21-
* [Bors and Homu](#bors-and-homu)
22-
* [Contributions](#contributions)
15+
- [Contributing to Clippy](#contributing-to-clippy)
16+
- [Getting started](#getting-started)
17+
- [Finding something to fix/improve](#finding-something-to-fiximprove)
18+
- [Writing code](#writing-code)
19+
- [Getting code-completion for rustc internals to work](#getting-code-completion-for-rustc-internals-to-work)
20+
- [How Clippy works](#how-clippy-works)
21+
- [Fixing build failures caused by Rust](#fixing-build-failures-caused-by-rust)
22+
- [Issue and PR triage](#issue-and-pr-triage)
23+
- [Bors and Homu](#bors-and-homu)
24+
- [Contributions](#contributions)
2325

2426
[Discord]: https://discord.gg/rust-lang
2527
[Rust Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct
@@ -91,6 +93,18 @@ quick read.
9193
[rfc_stability]: https://github.com/rust-lang/rfcs/blob/master/text/2476-clippy-uno.md#stability-guarantees
9294
[rfc_lint_cats]: https://github.com/rust-lang/rfcs/blob/master/text/2476-clippy-uno.md#lint-audit-and-categories
9395

96+
## Getting code-completion for rustc internals to work
97+
98+
Unfortunately, [`rust-analyzer`][ra_homepage] does not (yet?) understand how clippy uses compiler-internals using `extern crate` and it also needs to be able to read the source files of the rustc-compiler which are not available via a `rustup` component at the time of writing.
99+
To work around this, you need to have a copy of the a [rustc-repo][rustc_repo] available which can be obtained via `git clone https://github.com/rust-lang/rust/`.
100+
Then you can run a `cargo dev` command to automatically make clippy use the rustc-repo via path-dependencies which rust-analyzer will be able to understand.
101+
Run `cargo dev ra-setup --repo-path <repo-path>` where `<repo-path>` is an absolute path to the rustc repo you just cloned.
102+
The command will add path-dependencies pointing towards rustc-crates inside the rustc repo to clippys `Cargo.toml`s and should allow rust-analyzer to understand most of the type that clippy uses.
103+
Just make sure to remove the dependencies again before finally making a pull request!
104+
105+
[ra_homepage]: https://rust-analyzer.github.io/
106+
[rustc_repo]: https://github.com/rust-lang/rust/
107+
94108
## How Clippy works
95109

96110
[`clippy_lints/src/lib.rs`][lint_crate_entry] imports all the different lint modules and registers in the [`LintStore`].

0 commit comments

Comments
 (0)