Skip to content

Commit a724a3b

Browse files
committed
CONTRIBUTING: update section explaining how to get ra to work inside the clippy repo
1 parent 6ed6f1e commit a724a3b

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

CONTRIBUTING.md

+27-6
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,40 @@ 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.
117+
which `IntelliJ Rust` will be able to understand.
115118
Run `cargo dev ra_setup --repo-path <repo-path>` where `<repo-path>` is an absolute 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

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

124145
## How Clippy works
125146

doc/basics.md

-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ 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
92-
cargo dev ra_setup
9391
```
9492

9593
## lintcheck

0 commit comments

Comments
 (0)