@@ -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,41 @@ 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.
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 ide_setup --repo-path <repo-path> ` where ` <repo-path> ` is a 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
121
- [ ra_homepage ] : https://rust-analyzer.github.io/
122
124
[ 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
123
145
124
146
## How Clippy works
125
147
0 commit comments