You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/dev/README.md
+20-20Lines changed: 20 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Contributing Quick Start
2
2
3
-
Rust Analyzer is just a usual rust project, which is organized as a Cargo
3
+
Rust Analyzer is an ordinary Rust project, which is organized as a Cargo
4
4
workspace, builds on stable and doesn't depend on C libraries. So, just
5
5
6
6
```
@@ -65,31 +65,31 @@ directory).
65
65
66
66
# Launching rust-analyzer
67
67
68
-
Debugging language server can be tricky: LSP is rather chatty, so driving it
68
+
Debugging the language server can be tricky: LSP is rather chatty, so driving it
69
69
from the command line is not really feasible, driving it via VS Code requires
70
70
interacting with two processes.
71
71
72
72
For this reason, the best way to see how rust-analyzer works is to find a
73
73
relevant test and execute it (VS Code includes an action for running a single
74
74
test).
75
75
76
-
However, launching a VS Code instance with locally build language server is
76
+
However, launching a VS Code instance with a locally built language server is
77
77
possible. There's **"Run Extension (Debug Build)"** launch configuration for this.
78
78
79
79
In general, I use one of the following workflows for fixing bugs and
80
80
implementing features.
81
81
82
82
If the problem concerns only internal parts of rust-analyzer (i.e. I don't need
83
-
to touch `rust-analyzer` crate or TypeScript code), there is a unit-test for it.
83
+
to touch the `rust-analyzer` crate or TypeScript code), there is a unit-test for it.
84
84
So, I use **Rust Analyzer: Run** action in VS Code to run this single test, and
85
85
then just do printf-driven development/debugging. As a sanity check after I'm
86
86
done, I use `cargo xtask install --server` and **Reload Window** action in VS
87
87
Code to sanity check that the thing works as I expect.
88
88
89
89
If the problem concerns only the VS Code extension, I use **Run Installed Extension**
90
90
launch configuration from `launch.json`. Notably, this uses the usual
91
-
`rust-analyzer` binary from `PATH`. For this it is important to have the following
92
-
in `setting.json` file:
91
+
`rust-analyzer` binary from `PATH`. For this, it is important to have the following
92
+
in your `settings.json` file:
93
93
```json
94
94
{
95
95
"rust-analyzer.serverPath": "rust-analyzer"
@@ -107,7 +107,7 @@ things up, sometimes I open a temporary hello-world project which has
107
107
`"rust-analyzer.withSysroot": false` in `.code/settings.json`. This flag causes
108
108
rust-analyzer to skip loading the sysroot, which greatly reduces the amount of
109
109
things rust-analyzer needs to do, and makes printf's more useful. Note that you
110
-
should only use `eprint!` family of macros for debugging: stdout is used for LSP
110
+
should only use the `eprint!` family of macros for debugging: stdout is used for LSP
111
111
communication, and `print!` would break it.
112
112
113
113
If I need to fix something simultaneously in the server and in the client, I
@@ -119,20 +119,20 @@ performance optimizations, or for bug minimization.
119
119
120
120
# Code Style & Review Process
121
121
122
-
Our approach to "clean code" is twofold:
122
+
Our approach to "clean code" is two-fold:
123
123
124
124
* We generally don't block PRs on style changes.
125
125
* At the same time, all code in rust-analyzer is constantly refactored.
126
126
127
-
It is explicitly OK for reviewer to flag only some nits in the PR, and than send a followup cleanup PR for things which are easier to explain by example, cc-ing the original author.
128
-
Sending small cleanup PRs (like rename a single local variable) is encouraged.
127
+
It is explicitly OK for a reviewer to flag only some nits in the PR, and then send a follow-up cleanup PR for things which are easier to explain by example, cc-ing the original author.
128
+
Sending small cleanup PRs (like renaming a single local variable) is encouraged.
129
129
130
130
## Scale of Changes
131
131
132
132
Everyone knows that it's better to send small & focused pull requests.
133
133
The problem is, sometimes you *have* to, eg, rewrite the whole compiler, and that just doesn't fit into a set of isolated PRs.
134
134
135
-
The main thing too keep an eye on is the boundaries between various components.
135
+
The main things to keep an eye on are the boundaries between various components.
136
136
There are three kinds of changes:
137
137
138
138
1. Internals of a single component are changed.
@@ -144,20 +144,20 @@ There are three kinds of changes:
144
144
A good example here would be expansion of assist API, for example, to implement lazy assists or assists groups.
145
145
146
146
3. A new dependency between components is introduced.
147
-
Specifically, you add a `pub use` reexport from another crate or you add a new line to `[dependencies]` section of `Cargo.toml`.
147
+
Specifically, you add a `pub use` reexport from another crate or you add a new line to the `[dependencies]` section of `Cargo.toml`.
148
148
A good example here would be adding reference search capability to the assists crates.
149
149
150
150
For the first group, the change is generally merged as long as:
151
151
152
152
* it works for the happy case,
153
153
* it has tests,
154
-
* it doesn't panic for unhappy case.
154
+
* it doesn't panic for the unhappy case.
155
155
156
156
For the second group, the change would be subjected to quite a bit of scrutiny and iteration.
157
157
The new API needs to be right (or at least easy to change later).
158
158
The actual implementation doesn't matter that much.
159
159
It's very important to minimize the amount of changed lines of code for changes of the second kind.
160
-
Often, you start doing change of the first kind, only to realise that you need to elevate to a change of the second kind.
160
+
Often, you start doing a change of the first kind, only to realise that you need to elevate to a change of the second kind.
161
161
In this case, we'll probably ask you to split API changes into a separate PR.
162
162
163
163
Changes of the third group should be pretty rare, so we don't specify any specific process for them.
@@ -239,7 +239,7 @@ struct Foo {
239
239
## Variable Naming
240
240
241
241
We generally use boring and long names for local variables ([yay code completion](https://github.com/rust-analyzer/rust-analyzer/pull/4162#discussion_r417130973)).
242
-
The default name is lowercased named of the type: `global_state: GlobalState`.
242
+
The default name is a lowercased name of the type: `global_state: GlobalState`.
243
243
Avoid ad-hoc acronyms and contractions, but use the ones that exist consistently (`db`, `ctx`, `acc`).
244
244
The default name for "result of the function" local variable is `res`.
0 commit comments