@@ -18,11 +18,13 @@ All contributors are expected to follow the [Rust Code of Conduct].
18
18
- [ Finding something to fix/improve] ( #finding-something-to-fiximprove )
19
19
- [ Writing code] ( #writing-code )
20
20
- [ 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 )
21
23
- [ 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 )
23
25
- [ 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 )
26
28
- [ Defining remotes] ( #defining-remotes )
27
29
- [ Issue and PR triage] ( #issue-and-pr-triage )
28
30
- [ Bors and Homu] ( #bors-and-homu )
@@ -105,21 +107,40 @@ quick read.
105
107
106
108
## Getting code-completion for rustc internals to work
107
109
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
109
112
using ` extern crate ` and it also needs to be able to read the source files of the rustc-compiler which are not
110
113
available via a ` rustup ` component at the time of writing.
111
114
To work around this, you need to have a copy of the [ rustc-repo] [ rustc_repo ] available which can be obtained via
112
115
` git clone https://github.com/rust-lang/rust/ ` .
113
116
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.
115
118
Run ` cargo dev ra_setup --repo-path <repo-path> ` where ` <repo-path> ` is an absolute path to the rustc repo
116
119
you just cloned.
117
120
The command will add path-dependencies pointing towards rustc-crates inside the rustc repo to
118
121
Clippys ` Cargo.toml ` s and should allow rust-analyzer to understand most of the types that Clippy uses.
119
122
Just make sure to remove the dependencies again before finally making a pull request!
120
123
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
+
121
142
[ 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
123
144
124
145
## How Clippy works
125
146
0 commit comments