diff options
Diffstat (limited to 'docs/dev/README.md')
-rw-r--r-- | docs/dev/README.md | 76 |
1 files changed, 39 insertions, 37 deletions
diff --git a/docs/dev/README.md b/docs/dev/README.md index 57162a47d..9c0eb1358 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md | |||
@@ -1,7 +1,7 @@ | |||
1 | # Contributing Quick Start | 1 | # Contributing Quick Start |
2 | 2 | ||
3 | Rust Analyzer is an ordinary Rust project, which is organized as a Cargo | 3 | Rust Analyzer is an ordinary Rust project, which is organized as a Cargo workspace, builds on stable and doesn't depend on C libraries. |
4 | workspace, builds on stable and doesn't depend on C libraries. So, just | 4 | So, just |
5 | 5 | ||
6 | ``` | 6 | ``` |
7 | $ cargo test | 7 | $ cargo test |
@@ -13,9 +13,8 @@ To learn more about how rust-analyzer works, see [./architecture.md](./architect | |||
13 | It also explains the high-level layout of the source code. | 13 | It also explains the high-level layout of the source code. |
14 | Do skim through that document. | 14 | Do skim through that document. |
15 | 15 | ||
16 | We also publish rustdoc docs to pages: | 16 | We also publish rustdoc docs to pages: https://rust-analyzer.github.io/rust-analyzer/ide/. |
17 | 17 | Note though, that internal documentation is very incomplete. | |
18 | https://rust-analyzer.github.io/rust-analyzer/ide/ | ||
19 | 18 | ||
20 | Various organizational and process issues are discussed in this document. | 19 | Various organizational and process issues are discussed in this document. |
21 | 20 | ||
@@ -25,7 +24,7 @@ Rust Analyzer is a part of [RLS-2.0 working | |||
25 | group](https://github.com/rust-lang/compiler-team/tree/6a769c13656c0a6959ebc09e7b1f7c09b86fb9c0/working-groups/rls-2.0). | 24 | group](https://github.com/rust-lang/compiler-team/tree/6a769c13656c0a6959ebc09e7b1f7c09b86fb9c0/working-groups/rls-2.0). |
26 | Discussion happens in this Zulip stream: | 25 | Discussion happens in this Zulip stream: |
27 | 26 | ||
28 | https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0 | 27 | https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer |
29 | 28 | ||
30 | # Issue Labels | 29 | # Issue Labels |
31 | 30 | ||
@@ -33,6 +32,8 @@ https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0 | |||
33 | are good issues to get into the project. | 32 | are good issues to get into the project. |
34 | * [E-has-instructions](https://github.com/rust-analyzer/rust-analyzer/issues?q=is%3Aopen+is%3Aissue+label%3AE-has-instructions) | 33 | * [E-has-instructions](https://github.com/rust-analyzer/rust-analyzer/issues?q=is%3Aopen+is%3Aissue+label%3AE-has-instructions) |
35 | issues have links to the code in question and tests. | 34 | issues have links to the code in question and tests. |
35 | * [Broken Window](https://github.com/rust-analyzer/rust-analyzer/issues?q=is:issue+is:open+label:%22Broken+Window%22) | ||
36 | are issues which are not critical by themselves, but which should be fixed ASAP regardless, to avoid accumulation of technical debt. | ||
36 | * [E-easy](https://github.com/rust-analyzer/rust-analyzer/issues?q=is%3Aopen+is%3Aissue+label%3AE-easy), | 37 | * [E-easy](https://github.com/rust-analyzer/rust-analyzer/issues?q=is%3Aopen+is%3Aissue+label%3AE-easy), |
37 | [E-medium](https://github.com/rust-analyzer/rust-analyzer/issues?q=is%3Aopen+is%3Aissue+label%3AE-medium), | 38 | [E-medium](https://github.com/rust-analyzer/rust-analyzer/issues?q=is%3Aopen+is%3Aissue+label%3AE-medium), |
38 | [E-hard](https://github.com/rust-analyzer/rust-analyzer/issues?q=is%3Aopen+is%3Aissue+label%3AE-hard), | 39 | [E-hard](https://github.com/rust-analyzer/rust-analyzer/issues?q=is%3Aopen+is%3Aissue+label%3AE-hard), |
@@ -49,21 +50,28 @@ https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0 | |||
49 | Also a kind of fun. | 50 | Also a kind of fun. |
50 | These issues should generally include a link to a Zulip discussion thread. | 51 | These issues should generally include a link to a Zulip discussion thread. |
51 | 52 | ||
52 | # CI | 53 | # Code Style & Review Process |
54 | |||
55 | Do see [./style.md](./style.md). | ||
53 | 56 | ||
54 | We use GitHub Actions for CI. Most of the things, including formatting, are checked by | 57 | # Cookbook |
55 | `cargo test` so, if `cargo test` passes locally, that's a good sign that CI will | 58 | |
56 | be green as well. The only exception is that some long-running tests are skipped locally by default. | 59 | ## CI |
60 | |||
61 | We use GitHub Actions for CI. | ||
62 | Most of the things, including formatting, are checked by `cargo test`. | ||
63 | If `cargo test` passes locally, that's a good sign that CI will be green as well. | ||
64 | The only exception is that some long-running tests are skipped locally by default. | ||
57 | Use `env RUN_SLOW_TESTS=1 cargo test` to run the full suite. | 65 | Use `env RUN_SLOW_TESTS=1 cargo test` to run the full suite. |
58 | 66 | ||
59 | We use bors-ng to enforce the [not rocket science](https://graydon2.dreamwidth.org/1597.html) rule. | 67 | We use bors-ng to enforce the [not rocket science](https://graydon2.dreamwidth.org/1597.html) rule. |
60 | 68 | ||
61 | # Launching rust-analyzer | 69 | ## Launching rust-analyzer |
62 | 70 | ||
63 | Debugging the language server can be tricky. | 71 | Debugging the language server can be tricky. |
64 | LSP is rather chatty, so driving it from the command line is not really feasible, driving it via VS Code requires interacting with two processes. | 72 | LSP is rather chatty, so driving it from the command line is not really feasible, driving it via VS Code requires interacting with two processes. |
65 | 73 | ||
66 | For this reason, the best way to see how rust-analyzer works is to find a relevant test and execute it. | 74 | For this reason, the best way to see how rust-analyzer works is to **find a relevant test and execute it**. |
67 | VS Code & Emacs include an action for running a single test. | 75 | VS Code & Emacs include an action for running a single test. |
68 | 76 | ||
69 | Launching a VS Code instance with a locally built language server is also possible. | 77 | Launching a VS Code instance with a locally built language server is also possible. |
@@ -107,12 +115,7 @@ cd editors/code | |||
107 | npm ci | 115 | npm ci |
108 | npm run lint | 116 | npm run lint |
109 | ``` | 117 | ``` |
110 | 118 | ## How to ... | |
111 | # Code Style & Review Process | ||
112 | |||
113 | Do see [./style.md](./style.md). | ||
114 | |||
115 | # How to ... | ||
116 | 119 | ||
117 | * ... add an assist? [#7535](https://github.com/rust-analyzer/rust-analyzer/pull/7535) | 120 | * ... add an assist? [#7535](https://github.com/rust-analyzer/rust-analyzer/pull/7535) |
118 | * ... add a new protocol extension? [#4569](https://github.com/rust-analyzer/rust-analyzer/pull/4569) | 121 | * ... add a new protocol extension? [#4569](https://github.com/rust-analyzer/rust-analyzer/pull/4569) |
@@ -120,33 +123,30 @@ Do see [./style.md](./style.md). | |||
120 | * ... add a new completion? [#6964](https://github.com/rust-analyzer/rust-analyzer/pull/6964) | 123 | * ... add a new completion? [#6964](https://github.com/rust-analyzer/rust-analyzer/pull/6964) |
121 | * ... allow new syntax in the parser? [#7338](https://github.com/rust-analyzer/rust-analyzer/pull/7338) | 124 | * ... allow new syntax in the parser? [#7338](https://github.com/rust-analyzer/rust-analyzer/pull/7338) |
122 | 125 | ||
123 | # Logging | 126 | ## Logging |
124 | 127 | ||
125 | Logging is done by both rust-analyzer and VS Code, so it might be tricky to | 128 | Logging is done by both rust-analyzer and VS Code, so it might be tricky to figure out where logs go. |
126 | figure out where logs go. | ||
127 | 129 | ||
128 | Inside rust-analyzer, we use the standard `log` crate for logging, and | 130 | Inside rust-analyzer, we use the standard `log` crate for logging, and `env_logger` for logging frontend. |
129 | `env_logger` for logging frontend. By default, log goes to stderr, but the | 131 | By default, log goes to stderr, but the stderr itself is processed by VS Code. |
130 | stderr itself is processed by VS Code. | 132 | `--log-file <PATH>` CLI argument allows logging to file. |
131 | 133 | ||
132 | To see stderr in the running VS Code instance, go to the "Output" tab of the | 134 | To see stderr in the running VS Code instance, go to the "Output" tab of the panel and select `rust-analyzer`. |
133 | panel and select `rust-analyzer`. This shows `eprintln!` as well. Note that | 135 | This shows `eprintln!` as well. |
134 | `stdout` is used for the actual protocol, so `println!` will break things. | 136 | Note that `stdout` is used for the actual protocol, so `println!` will break things. |
135 | 137 | ||
136 | To log all communication between the server and the client, there are two choices: | 138 | To log all communication between the server and the client, there are two choices: |
137 | 139 | ||
138 | * you can log on the server side, by running something like | 140 | * You can log on the server side, by running something like |
139 | ``` | 141 | ``` |
140 | env RA_LOG=lsp_server=debug code . | 142 | env RA_LOG=lsp_server=debug code . |
141 | ``` | 143 | ``` |
142 | 144 | * You can log on the client side, by enabling `"rust-analyzer.trace.server": "verbose"` workspace setting. | |
143 | * you can log on the client side, by enabling `"rust-analyzer.trace.server": | 145 | These logs are shown in a separate tab in the output and could be used with LSP inspector. |
144 | "verbose"` workspace setting. These logs are shown in a separate tab in the | 146 | Kudos to [@DJMcNab](https://github.com/DJMcNab) for setting this awesome infra up! |
145 | output and could be used with LSP inspector. Kudos to | ||
146 | [@DJMcNab](https://github.com/DJMcNab) for setting this awesome infra up! | ||
147 | 147 | ||
148 | 148 | ||
149 | There are also two VS Code commands which might be of interest: | 149 | There are also several VS Code commands which might be of interest: |
150 | 150 | ||
151 | * `Rust Analyzer: Status` shows some memory-usage statistics. | 151 | * `Rust Analyzer: Status` shows some memory-usage statistics. |
152 | 152 | ||
@@ -164,7 +164,7 @@ There are also two VS Code commands which might be of interest: | |||
164 | 164 | ||
165 | ![demo](https://user-images.githubusercontent.com/36276403/78225773-6636a480-74d3-11ea-9d9f-1c9d42da03b0.png) | 165 | ![demo](https://user-images.githubusercontent.com/36276403/78225773-6636a480-74d3-11ea-9d9f-1c9d42da03b0.png) |
166 | 166 | ||
167 | # Profiling | 167 | ## Profiling |
168 | 168 | ||
169 | We have a built-in hierarchical profiler, you can enable it by using `RA_PROFILE` env-var: | 169 | We have a built-in hierarchical profiler, you can enable it by using `RA_PROFILE` env-var: |
170 | 170 | ||
@@ -192,7 +192,9 @@ $ cargo run --release -p rust-analyzer -- analysis-bench ../chalk/ --highlight . | |||
192 | $ cargo run --release -p rust-analyzer -- analysis-bench ../chalk/ --complete ../chalk/chalk-engine/src/logic.rs:94:0 | 192 | $ cargo run --release -p rust-analyzer -- analysis-bench ../chalk/ --complete ../chalk/chalk-engine/src/logic.rs:94:0 |
193 | ``` | 193 | ``` |
194 | 194 | ||
195 | # Release Process | 195 | Look for `fn benchmark_xxx` tests for a quick way to reproduce performance problems. |
196 | |||
197 | ## Release Process | ||
196 | 198 | ||
197 | Release process is handled by `release`, `dist` and `promote` xtasks, `release` being the main one. | 199 | Release process is handled by `release`, `dist` and `promote` xtasks, `release` being the main one. |
198 | 200 | ||
@@ -229,7 +231,7 @@ Make sure to remove the new changelog post created when running `cargo xtask rel | |||
229 | We release "nightly" every night automatically and promote the latest nightly to "stable" manually, every week. | 231 | We release "nightly" every night automatically and promote the latest nightly to "stable" manually, every week. |
230 | We don't do "patch" releases, unless something truly egregious comes up. | 232 | We don't do "patch" releases, unless something truly egregious comes up. |
231 | 233 | ||
232 | # Permissions | 234 | ## Permissions |
233 | 235 | ||
234 | There are three sets of people with extra permissions: | 236 | There are three sets of people with extra permissions: |
235 | 237 | ||