Skip to content

Commit 124513e

Browse files
authored
Describe why and how to use a separate build directory for rust-analyzer (#2106)
1 parent 5a25078 commit 124513e

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

Diff for: src/building/suggested.md

+25-4
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,35 @@ checking time. For example, if you are working on the compiler, you can override
3737
the command to `x check compiler --json-output` to only check the compiler part.
3838
You can run `x check --help --verbose` to see the available parts.
3939

40-
If you have enough free disk space and you would like to be able to run `x`
41-
commands while rust-analyzer runs in the background, you can also add
42-
`--build-dir build-rust-analyzer` to the `overrideCommand` to avoid x locking.
43-
4440
Running `./x setup editor` will prompt you to create a project-local LSP config
4541
file for one of the supported editors. You can also create the config file as a
4642
step of running `./x setup`.
4743

44+
### Using a separate build directory for rust-analyzer
45+
46+
By default, when rust-analyzer runs a check or format command, it will share
47+
the same build directory as manual command-line builds. This can be inconvenient
48+
for two reasons:
49+
- Each build will lock the build directory and force the other to wait, so it
50+
becomes impossible to run command-line builds while rust-analyzer is running
51+
commands in the background.
52+
- There is an increased risk of one of the builds deleting previously-built
53+
artifacts due to conflicting compiler flags or other settings, forcing
54+
additional rebuilds in some cases.
55+
56+
To avoid these problems:
57+
- Add `--build-dir=build-rust-analyzer` to all of the custom `x` commands in
58+
your editor's rust-analyzer configuration.
59+
(Feel free to choose a different directory name if desired.)
60+
- Modify the `rust-analyzer.procMacro.server` setting so that it points to the
61+
copy of `rust-analyzer-proc-macro-srv` in that other build directory.
62+
63+
Using separate build directories for command-line builds and rust-analyzer
64+
requires extra disk space, and also means that running `./x clean` on the
65+
command-line will not clean out the separate build directory. To clean the
66+
separate build directory, run `./x clean --build-dir=build-rust-analyzer`
67+
instead.
68+
4869
### Visual Studio Code
4970

5071
Selecting `vscode` in `./x setup editor` will prompt you to create a

0 commit comments

Comments
 (0)