aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/dev/debugging.md2
-rw-r--r--docs/dev/lsp-extensions.md3
-rw-r--r--docs/dev/style.md61
-rw-r--r--docs/user/generated_diagnostic.adoc105
-rw-r--r--docs/user/manual.adoc22
5 files changed, 171 insertions, 22 deletions
diff --git a/docs/dev/debugging.md b/docs/dev/debugging.md
index 59a83f7d7..8c48fd5a1 100644
--- a/docs/dev/debugging.md
+++ b/docs/dev/debugging.md
@@ -53,7 +53,7 @@ To apply changes to an already running debug process, press <kbd>Ctrl+Shift+P</k
53 53
54- A list of running processes should appear. Select the `rust-analyzer` from this repo. 54- A list of running processes should appear. Select the `rust-analyzer` from this repo.
55 55
56- Navigate to `crates/rust-analyzer/src/main_loop.rs` and add a breakpoint to the `on_task` function. 56- Navigate to `crates/rust-analyzer/src/main_loop.rs` and add a breakpoint to the `on_request` function.
57 57
58- Go back to the `[Extension Development Host]` instance and hover over a Rust variable and your breakpoint should hit. 58- Go back to the `[Extension Development Host]` instance and hover over a Rust variable and your breakpoint should hit.
59 59
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md
index 43a69d6ce..780f5cb91 100644
--- a/docs/dev/lsp-extensions.md
+++ b/docs/dev/lsp-extensions.md
@@ -392,7 +392,10 @@ rust-analyzer supports only one `kind`, `"cargo"`. The `args` for `"cargo"` look
392{ 392{
393 workspaceRoot?: string; 393 workspaceRoot?: string;
394 cargoArgs: string[]; 394 cargoArgs: string[];
395 cargoExtraArgs: string[];
395 executableArgs: string[]; 396 executableArgs: string[];
397 expectTest?: boolean;
398 overrideCargo?: string;
396} 399}
397``` 400```
398 401
diff --git a/docs/dev/style.md b/docs/dev/style.md
index 883a6845d..7a64a0d22 100644
--- a/docs/dev/style.md
+++ b/docs/dev/style.md
@@ -366,27 +366,66 @@ People read things from top to bottom, so place most important things first.
366 366
367Specifically, if all items except one are private, always put the non-private item on top. 367Specifically, if all items except one are private, always put the non-private item on top.
368 368
369Put `struct`s and `enum`s first, functions and impls last.
370
371Do
372
373```rust 369```rust
374// Good 370// Good
375struct Foo { 371pub(crate) fn frobnicate() {
376 bars: Vec<Bar> 372 Helper::act()
373}
374
375#[derive(Default)]
376struct Helper { stuff: i32 }
377
378impl Helper {
379 fn act(&self) {
380
381 }
382}
383
384// Not as good
385#[derive(Default)]
386struct Helper { stuff: i32 }
387
388pub(crate) fn frobnicate() {
389 Helper::act()
377} 390}
378 391
379struct Bar; 392impl Helper {
393 fn act(&self) {
394
395 }
396}
380``` 397```
381 398
382rather than 399If there's a mixture of private and public items, put public items first.
400If function bodies are folded in the editor, the source code should read as documentation for the public API.
401
402Put `struct`s and `enum`s first, functions and impls last. Order types declarations in top-down manner.
383 403
384```rust 404```rust
405// Good
406struct Parent {
407 children: Vec<Child>
408}
409
410struct Child;
411
412impl Parent {
413}
414
415impl Child {
416}
417
385// Not as good 418// Not as good
386struct Bar; 419struct Child;
387 420
388struct Foo { 421impl Child {
389 bars: Vec<Bar> 422}
423
424struct Parent {
425 children: Vec<Child>
426}
427
428impl Parent {
390} 429}
391``` 430```
392 431
diff --git a/docs/user/generated_diagnostic.adoc b/docs/user/generated_diagnostic.adoc
new file mode 100644
index 000000000..34c4f98a3
--- /dev/null
+++ b/docs/user/generated_diagnostic.adoc
@@ -0,0 +1,105 @@
1//Generated file, do not edit by hand, see `xtask/src/codegen`
2=== break-outside-of-loop
3**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L219[diagnostics.rs]
4
5This diagnostic is triggered if `break` keyword is used outside of a loop.
6
7
8=== inactive-code
9**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_def/src/diagnostics.rs#L98[diagnostics.rs]
10
11This diagnostic is shown for code with inactive `#[cfg]` attributes.
12
13
14=== incorrect-ident-case
15**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L319[diagnostics.rs]
16
17This diagnostic is triggered if item name doesn't follow https://doc.rust-lang.org/1.0.0/style/style/naming/README.html[Rust naming convention].
18
19
20=== mismatched-arg-count
21**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L267[diagnostics.rs]
22
23This diagnostic is triggered if function is invoked with an incorrect amount of arguments.
24
25
26=== missing-match-arm
27**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L162[diagnostics.rs]
28
29This diagnostic is triggered if `match` block is missing one or more match arms.
30
31
32=== missing-ok-in-tail-expr
33**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L187[diagnostics.rs]
34
35This diagnostic is triggered if block that should return `Result` returns a value not wrapped in `Ok`.
36
37Example:
38
39```rust
40fn foo() -> Result<u8, ()> {
41 10
42}
43```
44
45
46=== missing-pat-fields
47**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L113[diagnostics.rs]
48
49This diagnostic is triggered if pattern lacks some fields that exist in the corresponding structure.
50
51Example:
52
53```rust
54struct A { a: u8, b: u8 }
55
56let a = A { a: 10, b: 20 };
57
58if let A { a } = a {
59 // ...
60}
61```
62
63
64=== missing-structure-fields
65**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L66[diagnostics.rs]
66
67This diagnostic is triggered if record lacks some fields that exist in the corresponding structure.
68
69Example:
70
71```rust
72struct A { a: u8, b: u8 }
73
74let a = A { a: 10 };
75```
76
77
78=== missing-unsafe
79**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L243[diagnostics.rs]
80
81This diagnostic is triggered if operation marked as `unsafe` is used outside of `unsafe` function or block.
82
83
84=== no-such-field
85**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/diagnostics.rs#L39[diagnostics.rs]
86
87This diagnostic is triggered if created structure does not have field provided in record.
88
89
90=== unresolved-extern-crate
91**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_def/src/diagnostics.rs#L43[diagnostics.rs]
92
93This diagnostic is triggered if rust-analyzer is unable to discover referred extern crate.
94
95
96=== unresolved-import
97**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_def/src/diagnostics.rs#L67[diagnostics.rs]
98
99This diagnostic is triggered if rust-analyzer is unable to discover imported module.
100
101
102=== unresolved-module
103**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_def/src/diagnostics.rs#L18[diagnostics.rs]
104
105This diagnostic is triggered if rust-analyzer is unable to discover referred module.
diff --git a/docs/user/manual.adoc b/docs/user/manual.adoc
index 46e7bd091..b9d907a4a 100644
--- a/docs/user/manual.adoc
+++ b/docs/user/manual.adoc
@@ -116,6 +116,7 @@ Here are some useful self-diagnostic commands:
116* **Rust Analyzer: Show RA Version** shows the version of `rust-analyzer` binary. 116* **Rust Analyzer: Show RA Version** shows the version of `rust-analyzer` binary.
117* **Rust Analyzer: Status** prints some statistics about the server, and dependency information for the current file. 117* **Rust Analyzer: Status** prints some statistics about the server, and dependency information for the current file.
118* To enable server-side logging, run with `env RA_LOG=info` and see `Output > Rust Analyzer Language Server` in VS Code's panel. 118* To enable server-side logging, run with `env RA_LOG=info` and see `Output > Rust Analyzer Language Server` in VS Code's panel.
119* To log project loading (sysroot & `cargo metadata`), set `RA_LOG=project_model=debug`.
119* To log all LSP requests, add `"rust-analyzer.trace.server": "verbose"` to the settings and look for `Rust Analyzer Language Server Trace` in the panel. 120* To log all LSP requests, add `"rust-analyzer.trace.server": "verbose"` to the settings and look for `Rust Analyzer Language Server Trace` in the panel.
120* To enable client-side logging, add `"rust-analyzer.trace.extension": true` to the settings and open `Output > Rust Analyzer Client` in the panel. 121* To enable client-side logging, add `"rust-analyzer.trace.extension": true` to the settings and open `Output > Rust Analyzer Client` in the panel.
121 122
@@ -260,16 +261,7 @@ If you get an error saying `No such file or directory: 'rust-analyzer'`, see the
260 261
261=== GNOME Builder 262=== GNOME Builder
262 263
263Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>. 264GNOME Builder 3.37.1 and newer has native `rust-analyzer` support. If the LSP binary is not available, GNOME Builder can install it when opening a Rust file.
264
265Gnome Builder currently has support for RLS, and there's no way to configure the language server executable. A future version might support `rust-analyzer` out of the box.
266
2671. Rename, symlink or copy the `rust-analyzer` binary to `rls` and place it somewhere Builder can find (in `PATH`, or under `~/.cargo/bin`).
2682. Enable the Rust Builder plugin.
269
270==== GNOME Builder (Nightly)
271
272https://nightly.gnome.org/repo/appstream/org.gnome.Builder.flatpakref[GNOME Builder (Nightly)] has now native support for `rust-analyzer` out of the box. If the `rust-analyzer` binary is not available, GNOME Builder can install it when opening a Rust source file.
273 265
274== Non-Cargo Based Projects 266== Non-Cargo Based Projects
275 267
@@ -295,6 +287,9 @@ interface JsonProject {
295} 287}
296 288
297interface Crate { 289interface Crate {
290 /// Optional crate name used for display purposes, without affecting semantics.
291 /// See the `deps` key for semantically-significant crate names.
292 display_name?: string;
298 /// Path to the root module of the crate. 293 /// Path to the root module of the crate.
299 root_module: string; 294 root_module: string;
300 /// Edition of the crate. 295 /// Edition of the crate.
@@ -371,6 +366,13 @@ Cursor position or selection is signified by `┃` character.
371 366
372include::./generated_assists.adoc[] 367include::./generated_assists.adoc[]
373 368
369== Diagnostics
370
371While most errors and warnings provided by rust-analyzer come from the `cargo check` integration, there's a growing number of diagnostics implemented using rust-analyzer's own analysis.
372These diagnostics don't respect `#[allow]` or `#[deny]` attributes yet, but can be turned off using the `rust-analyzer.diagnostics.enable`, `rust-analyzer.diagnostics.enableExperimental` or `rust-analyzer.diagnostics.disabled` settings.
373
374include::./generated_diagnostic.adoc[]
375
374== Editor Features 376== Editor Features
375=== VS Code 377=== VS Code
376 378