Skip to content

Commit 3d7a84c

Browse files
committed
CONTRIBUTING: update section explaining how to get ra to work inside the clippy repo
1 parent 56161b2 commit 3d7a84c

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

CONTRIBUTING.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ All contributors are expected to follow the [Rust Code of Conduct].
1818
- [Finding something to fix/improve](#finding-something-to-fiximprove)
1919
- [Writing code](#writing-code)
2020
- [Getting code-completion for rustc internals to work](#getting-code-completion-for-rustc-internals-to-work)
21+
- [IntelliJ Rust](#intellij-rust)
22+
- [Rust Analyzer](#rust-analyzer)
2123
- [How Clippy works](#how-clippy-works)
22-
- [Syncing changes between Clippy and `rust-lang/rust`](#syncing-changes-between-clippy-and-rust-langrust)
24+
- [Syncing changes between Clippy and [`rust-lang/rust`]](#syncing-changes-between-clippy-and-rust-langrust)
2325
- [Patching git-subtree to work with big repos](#patching-git-subtree-to-work-with-big-repos)
24-
- [Performing the sync from `rust-lang/rust` to Clippy](#performing-the-sync-from-rust-langrust-to-clippy)
25-
- [Performing the sync from Clippy to `rust-lang/rust`](#performing-the-sync-from-clippy-to-rust-langrust)
26+
- [Performing the sync from [`rust-lang/rust`] to Clippy](#performing-the-sync-from-rust-langrust-to-clippy)
27+
- [Performing the sync from Clippy to [`rust-lang/rust`]](#performing-the-sync-from-clippy-to-rust-langrust)
2628
- [Defining remotes](#defining-remotes)
2729
- [Issue and PR triage](#issue-and-pr-triage)
2830
- [Bors and Homu](#bors-and-homu)
@@ -105,21 +107,41 @@ quick read.
105107

106108
## Getting code-completion for rustc internals to work
107109

108-
Unfortunately, [`rust-analyzer`][ra_homepage] does not (yet?) understand how Clippy uses compiler-internals
110+
### IntelliJ Rust
111+
Unfortunately, [`IntelliJ Rust`][IntelliJ_rust_homepage] does not (yet?) understand how Clippy uses compiler-internals
109112
using `extern crate` and it also needs to be able to read the source files of the rustc-compiler which are not
110113
available via a `rustup` component at the time of writing.
111114
To work around this, you need to have a copy of the [rustc-repo][rustc_repo] available which can be obtained via
112115
`git clone https://github.com/rust-lang/rust/`.
113116
Then you can run a `cargo dev` command to automatically make Clippy use the rustc-repo via path-dependencies
114-
which rust-analyzer will be able to understand.
115-
Run `cargo dev ra_setup --repo-path <repo-path>` where `<repo-path>` is an absolute path to the rustc repo
117+
which `IntelliJ Rust` will be able to understand.
118+
Run `cargo dev ra_setup --repo-path <repo-path>` where `<repo-path>` is a path to the rustc repo
116119
you just cloned.
117120
The command will add path-dependencies pointing towards rustc-crates inside the rustc repo to
118121
Clippys `Cargo.toml`s and should allow rust-analyzer to understand most of the types that Clippy uses.
119122
Just make sure to remove the dependencies again before finally making a pull request!
120123

121-
[ra_homepage]: https://rust-analyzer.github.io/
122124
[rustc_repo]: https://github.com/rust-lang/rust/
125+
[IntelliJ_rust_homepage]: https://intellij-rust.github.io/
126+
127+
### Rust Analyzer
128+
As of [#6869][6869], [`rust-analyzer`][ra_homepage] can understand that Clippy uses compiler-internals
129+
using `extern crate` when `package.metadata.rust-analyzer.rustc_private` is set to `true` in Clippys `Cargo.toml.`
130+
You will required a `nightly` toolchain with the `rustc-dev` component installed.
131+
Make sure that in the `rust-analyzer` configuration, you set
132+
```
133+
{ "rust-analyzer.rustcSource": "discover" }
134+
```
135+
and
136+
```
137+
{ "rust-analyzer.updates.channel": "nightly" }
138+
```
139+
You should be able to see information on things like `Expr` or `EarlyContext` now if you hover them, also
140+
a lot more type hints.
141+
This will work with `rust-analyzer 2021-03-15` shipped in nightly `1.52.0-nightly (107896c32 2021-03-15)` or later.
142+
143+
[ra_homepage]: https://rust-analyzer.github.io/
144+
[6869]: https://github.com/rust-lang/rust-clippy/pull/6869
123145

124146
## How Clippy works
125147

doc/basics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ cargo dev fmt
8888
cargo dev update_lints
8989
# create a new lint and register it
9090
cargo dev new_lint
91-
# (experimental) Setup Clippy to work with rust-analyzer
91+
# (experimental) Setup Clippy to work with IntelliJ-Rust
9292
cargo dev ra_setup
9393
```
9494

0 commit comments

Comments
 (0)