Unnamed repository; edit this file 'description' to name the repository.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# Author : OwOSwordsman <[email protected]>
# An unofficial GitHub theme, generated using colors from: https://primer.style/primitives/colors
# Credit goes to the original VSCode theme: https://github.com/primer/github-vscode-theme
# Only the Light and Dark variants were specifically tested

attribute = "fg.default"
keyword = "scale.red.3"
"keyword.directive" = "scale.red.3"          # -- preprocessor comments (#if in C)
namespace = "scale.orange.2"
punctuation = "fg.default"
"punctuation.delimiter" = "fg.default"
operator = "scale.blue.1"
special = "scale.blue.1"
"variable.other.member" = "scale.blue.1"
variable = "fg.default"
"variable.parameter" = "scale.orange.2"
"variable.builtin" = "scale.red.3"
type = "scale.orange.2"
"type.builtin" = "scale.blue.2"
constructor = "scale.purple.2"
function = "scale.purple.2"
"function.macro" = "scale.purple.2"
tag = "scale.green.1"
comment = "fg.muted"
constant = "scale.blue.2"
"constant.builtin" = "scale.blue.2"
string = "scale.blue.1"
"constant.numeric" = "scale.blue.2"
"constant.character.escape" = "scale.blue.2"
# used for lifetimes
label = "scale.red.3"

"markup.heading" = "scale.blue.2"
"markup.bold" = { modifiers = ["bold"] }
"markup.italic" = { modifiers = ["italic"] }
"markup.strikethrough" = { modifiers = ["crossed_out"] }
"markup.link.url" = { modifiers = ["underlined"] }
"markup.link.text" = { fg = "scale.blue.1", modifiers = ["underlined"] }
"markup.raw" = "scale.blue.2"

"diff.plus" = "open.fg"
"diff.minus" = "closed.fg"
"diff.delta" = "attention.fg"

"ui.background" = { bg = "canvas.default" }
"ui.background.separator" = { fg = "fg.subtle" }
"ui.linenr" = { fg = "fg.subtle" }
"ui.linenr.selected" = { fg = "fg.default" }
"ui.statusline" = { fg = "fg.muted", bg = "scale.gray.7" }
"ui.statusline.active" = { fg = "fg.default", bg = "canvas.default", underline = { color = "scale.coral.3", style = "line" } }
"ui.statusline.normal" = { fg = "fg.default", bg = "accent.muted" }
"ui.statusline.insert" = { fg = "fg.default", bg = "attention.muted" }
"ui.statusline.select" = { fg = "fg.default", bg = "sponsors.muted" }
"ui.popup" = { bg = "scale.gray.8" }
"ui.popup.info" = { fg = "fg.default", bg = "canvas.overlay" }
"ui.window" = { fg = "border.default" }
"ui.help" = { fg = "fg.default", bg = "canvas.overlay" }

"ui.text" = { fg = "fg.muted" }
"ui.text.focus" = { fg = "fg.default" }
"ui.text.inactive" = "fg.subtle"
"ui.text.directory" = { fg = "scale.blue.2" }
"ui.virtual" = { fg = "scale.gray.6" }
"ui.virtual.ruler" = { bg = "canvas.subtle" }
"ui.virtual.jump-label" = { fg = "scale.red.2", modifiers = ["bold"] }

"ui.selection" = { bg = "scale.blue.8" }
"ui.selection.primary" = { bg = "scale.blue.7" }
"ui.cursor.match" = { fg = "attention.fg", modifiers = [
    "bold",
], underline = { style = "line" } }
"ui.cursor" = { modifiers = ["reversed"] }
"ui.cursorline.primary" = { bg = "canvas.subtle" }

"ui.menu" = { fg = "fg.default", bg = "canvas.overlay" }
"ui.menu.selected" = { bg = "scale.gray.4" }
"ui.menu.scroll" = { fg = "scale.gray.5", bg = "canvas.overlay" }

"diagnostic.hint" = { underline = { color = "success.fg", style = "curl" } }
"diagnostic.info" = { underline = { color = "accent.fg", style = "curl" } }
"diagnostic.warning" = { underline = { color = "attention.fg", style = "curl" } }
"diagnostic.error" = { underline = { color = "danger.fg", style = "curl" } }
"diagnostic.unnecessary" = { modifiers = ["dim"] }
"diagnostic.deprecated" = { modifiers = ["crossed_out"] }

hint = "success.fg"
info = "accent.fg"
warning = "attention.fg"
error = "danger.fg"

[palette]
"accent.emphasis" = "#1f6feb"
"accent.fg" = "#58a6ff"
"accent.muted" = "#388bfd66"
"accent.subtle" = "#388bfd26"
"attention.emphasis" = "#9e6a03"
"attention.fg" = "#d29922"
"attention.muted" = "#bb800966"
"attention.subtle" = "#bb800926"
"border.default" = "#30363d"
"border.muted" = "#21262d"
"border.subtle" = "#f0f6fc1a"
"canvas.default" = "#0d1117"
"canvas.inset" = "#010409"
"canvas.overlay" = "#161b22"
"canvas.subtle" = "#161b22"
"closed.emphasis" = "#da3633"
"closed.fg" = "#f85149"
"closed.muted" = "#f8514966"
"closed.subtle" = "#f8514926"
"danger.emphasis" = "#da3633"
"danger.fg" = "#f85149"
"danger.muted" = "#f8514966"
"danger.subtle" = "#f8514926"
"done.emphasis" = "#8957e5"
"done.fg" = "#a371f7"
"done.muted" = "#a371f766"
"done.subtle" = "#a371f726"
"fg.default" = "#c9d1d9"
"fg.muted" = "#8b949e"
"fg.onEmphasis" = "#ffffff"
"fg.subtle" = "#6e7681"
"neutral.emphasis" = "#6e7681"
"neutral.emphasisPlus" = "#6e7681"
"neutral.muted" = "#6e768166"
"neutral.subtle" = "#6e76811a"
"open.emphasis" = "#238636"
"open.fg" = "#3fb950"
"open.muted" = "#2ea04366"
"open.subtle" = "#2ea04326"
"scale.black" = "#010409"
"scale.blue.0" = "#cae8ff"
"scale.blue.1" = "#a5d6ff"
"scale.blue.2" = "#79c0ff"
"scale.blue.3" = "#58a6ff"
"scale.blue.4" = "#388bfd"
"scale.blue.5" = "#1f6feb"
"scale.blue.6" = "#1158c7"
"scale.blue.7" = "#0d419d"
"scale.blue.8" = "#0c2d6b"
"scale.blue.9" = "#051d4d"
"scale.coral.0" = "#ffddd2"
"scale.coral.1" = "#ffc2b2"
"scale.coral.2" = "#ffa28b"
"scale.coral.3" = "#f78166"
"scale.coral.4" = "#ea6045"
"scale.coral.5" = "#cf462d"
"scale.coral.6" = "#ac3220"
"scale.coral.7" = "#872012"
"scale.coral.8" = "#640d04"
"scale.coral.9" = "#460701"
"scale.gray.0" = "#f0f6fc"
"scale.gray.1" = "#c9d1d9"
"scale.gray.2" = "#b1bac4"
"scale.gray.3" = "#8b949e"
"scale.gray.4" = "#6e7681"
"scale.gray.5" = "#484f58"
"scale.gray.6" = "#30363d"
"scale.gray.7" = "#21262d"
"scale.gray.8" = "#161b22"
"scale.gray.9" = "#0d1117"
"scale.green.0" = "#aff5b4"
"scale.green.1" = "#7ee787"
"scale.green.2" = "#56d364"
"scale.green.3" = "#3fb950"
"scale.green.4" = "#2ea043"
"scale.green.5" = "#238636"
"scale.green.6" = "#196c2e"
"scale.green.7" = "#0f5323"
"scale.green.8" = "#033a16"
"scale.green.9" = "#04260f"
"scale.orange.0" = "#ffdfb6"
"scale.orange.1" = "#ffc680"
"scale.orange.2" = "#ffa657"
"scale.orange.3" = "#f0883e"
"scale.orange.4" = "#db6d28"
"scale.orange.5" = "#bd561d"
"scale.orange.6" = "#9b4215"
"scale.orange.7" = "#762d0a"
"scale.orange.8" = "#5a1e02"
"scale.orange.9" = "#3d1300"
"scale.pink.0" = "#ffdaec"
"scale.pink.1" = "#ffbedd"
"scale.pink.2" = "#ff9bce"
"scale.pink.3" = "#f778ba"
"scale.pink.4" = "#db61a2"
"scale.pink.5" = "#bf4b8a"
"scale.pink.6" = "#9e3670"
"scale.pink.7" = "#7d2457"
"scale.pink.8" = "#5e103e"
"scale.pink.9" = "#42062a"
"scale.purple.0" = "#eddeff"
"scale.purple.1" = "#e2c5ff"
"scale.purple.2" = "#d2a8ff"
"scale.purple.3" = "#bc8cff"
"scale.purple.4" = "#a371f7"
"scale.purple.5" = "#8957e5"
"scale.purple.6" = "#6e40c9"
"scale.purple.7" = "#553098"
"scale.purple.8" = "#3c1e70"
"scale.purple.9" = "#271052"
"scale.red.0" = "#ffdcd7"
"scale.red.1" = "#ffc1ba"
"scale.red.2" = "#ffa198"
"scale.red.3" = "#ff7b72"
"scale.red.4" = "#f85149"
"scale.red.5" = "#da3633"
"scale.red.6" = "#b62324"
"scale.red.7" = "#8e1519"
"scale.red.8" = "#67060c"
"scale.red.9" = "#490202"
"scale.white" = "#ffffff"
"scale.yellow.0" = "#f8e3a1"
"scale.yellow.1" = "#f2cc60"
"scale.yellow.2" = "#e3b341"
"scale.yellow.3" = "#d29922"
"scale.yellow.4" = "#bb8009"
"scale.yellow.5" = "#9e6a03"
"scale.yellow.6" = "#845306"
"scale.yellow.7" = "#693e00"
"scale.yellow.8" = "#4b2900"
"scale.yellow.9" = "#341a00"
"severe.emphasis" = "#bd561d"
"severe.fg" = "#db6d28"
"severe.muted" = "#db6d2866"
"severe.subtle" = "#db6d2826"
"sponsors.emphasis" = "#bf4b8a"
"sponsors.fg" = "#db61a2"
"sponsors.muted" = "#db61a266"
"sponsors.subtle" = "#db61a226"
"success.emphasis" = "#238636"
"success.fg" = "#3fb950"
"success.muted" = "#2ea04366"
"success.subtle" = "#2ea04326"
t-analyzer, we use the tracing crate for logging, and tracing-subscriber for logging frontend. By default, log goes to stderr, but the stderr itself is processed by VS Code. --log-file <PATH> CLI argument allows logging to file. Setting the RA_LOG_FILE=<PATH> environment variable will also log to file, it will also override --log-file.

To see stderr in the running VS Code instance, go to the "Output" tab of the panel and select rust-analyzer. This shows eprintln! as well. Note that stdout is used for the actual protocol, so println! will break things.

To log all communication between the server and the client, there are two choices:

There are also several VS Code commands which might be of interest:

You can hover over syntax nodes in the opened text file to see the appropriate rust code that it refers to and the rust editor will also highlight the proper text range.

If you trigger Go to Definition in the inspected Rust source file, the syntax tree read-only editor should scroll to and select the appropriate syntax node token.

demo

Profiling

We have a built-in hierarchical profiler, you can enable it by using RA_PROFILE env-var:

RA_PROFILE=*             // dump everything
RA_PROFILE=foo|bar|baz   // enabled only selected entries
RA_PROFILE=*@3>10        // dump everything, up to depth 3, if it takes more than 10 ms

In particular, I have export RA_PROFILE='*>10' in my shell profile.

We also have a "counting" profiler which counts number of instances of popular structs. It is enabled by RA_COUNT=1.

To measure time for from-scratch analysis, use something like this:

$ cargo run --release -p rust-analyzer -- analysis-stats ../chalk/

For measuring time of incremental analysis, use either of these:

$ cargo run --release -p rust-analyzer -- analysis-bench ../chalk/ --highlight ../chalk/chalk-engine/src/logic.rs
$ cargo run --release -p rust-analyzer -- analysis-bench ../chalk/ --complete ../chalk/chalk-engine/src/logic.rs:94:0

Look for fn benchmark_xxx tests for a quick way to reproduce performance problems.

Release Process

Release process is handled by release, dist, publish-release-notes and promote xtasks, release being the main one.

release assumes that you have checkouts of rust-analyzer, rust-analyzer.github.io, and rust-lang/rust in the same directory:

./rust-analyzer
./rust-analyzer.github.io
./rust-rust-analyzer  # Note the name!

The remote for rust-analyzer must be called upstream (I use origin to point to my fork). In addition, for xtask promote (see below), rust-rust-analyzer must have a rust-analyzer remote pointing to this repository on GitHub.

release calls the GitHub API calls to scrape pull request comments and categorize them in the changelog. This step uses the curl and jq applications, which need to be available in PATH. Finally, you need to obtain a GitHub personal access token and set the GITHUB_TOKEN environment variable.

Release steps:

  1. Set the GITHUB_TOKEN environment variable.
  2. Inside rust-analyzer, run cargo xtask release. This will: * checkout the release branch * reset it to upstream/nightly * push it to upstream. This triggers GitHub Actions which:
  3. While the release is in progress, fill in the changelog
  4. Commit & push the changelog
  5. Run cargo xtask publish-release-notes <CHANGELOG> -- this will convert the changelog entry in AsciiDoc to Markdown and update the body of GitHub Releases entry.
  6. Tweet
  7. Inside rust-analyzer, run cargo xtask promote -- this will create a PR to rust-lang/rust updating rust-analyzer's subtree. Self-approve the PR.

If the GitHub Actions release fails because of a transient problem like a timeout, you can re-run the job from the Actions console. If it fails because of something that needs to be fixed, remove the release tag (if needed), fix the problem, then start over. Make sure to remove the new changelog post created when running cargo xtask release a second time.

We release "nightly" every night automatically and promote the latest nightly to "stable" manually, every week.

We don't do "patch" releases, unless something truly egregious comes up. To do a patch release, cherry-pick the fix on top of the current release branch and push the branch. There's no need to write a changelog for a patch release, it's OK to include the notes about the fix into the next weekly one. Note: we tag releases by dates, releasing a patch release on the same day should work (by overwriting a tag), but I am not 100% sure.

Permissions

There are three sets of people with extra permissions:

Note that at the time being you need to be a member of the org yourself to view the links.