diff options
author | Aleksey Kladov <[email protected]> | 2019-01-20 17:31:05 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-21 08:27:01 +0000 |
commit | ce47d6b7b68a658bd65211a07aab7baaffff4a50 (patch) | |
tree | 8194d092c302a5e0ded959a916dc5b3548bd7d17 | |
parent | 743384204055fcf20ec8957e056215b4d9fb36f2 (diff) |
reach fixed-point for rust-analyzer spelling
-rw-r--r-- | guide.md | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | ## About the guide | 3 | ## About the guide |
4 | 4 | ||
5 | This guide describes the current state of `rust-analyzer` as of 2019-01-20 | 5 | This guide describes the current state of rust-analyzer as of 2019-01-20 |
6 | (git tag [guide-2019-01]). Its purpose is to document various problems and | 6 | (git tag [guide-2019-01]). Its purpose is to document various problems and |
7 | architectural solutions related to the problem of building IDE-first compiler | 7 | architectural solutions related to the problem of building IDE-first compiler |
8 | for Rust. | 8 | for Rust. |
@@ -11,7 +11,7 @@ for Rust. | |||
11 | 11 | ||
12 | ## The big picture | 12 | ## The big picture |
13 | 13 | ||
14 | On the highest possible level, rust analyzer is a stateful component. A client may | 14 | On the highest possible level, rust-analyzer is a stateful component. A client may |
15 | apply changes to the analyzer (new contents of `foo.rs` file is "fn main() {}") | 15 | apply changes to the analyzer (new contents of `foo.rs` file is "fn main() {}") |
16 | and it may ask semantic questions about the current state (what is the | 16 | and it may ask semantic questions about the current state (what is the |
17 | definition of the identifier with offset 92 in file `bar.rs`?). Two important | 17 | definition of the identifier with offset 92 in file `bar.rs`?). Two important |
@@ -117,7 +117,7 @@ Yet another problem is that we really-really want to avoid doing IO, but with | |||
117 | Rust the set of "input" files is not necessary known up-front. In theory, you | 117 | Rust the set of "input" files is not necessary known up-front. In theory, you |
118 | can have `#[path="/dev/random"] mod foo;`. | 118 | can have `#[path="/dev/random"] mod foo;`. |
119 | 119 | ||
120 | To solve (or explicitly refuse to solve) these problems rust analyzer uses the | 120 | To solve (or explicitly refuse to solve) these problems rust-analyzer uses the |
121 | concept of source root. Roughly speaking, source roots is a contents of a | 121 | concept of source root. Roughly speaking, source roots is a contents of a |
122 | directory on a file systems, like `/home/matklad/projects/rustraytracer/**.rs`. | 122 | directory on a file systems, like `/home/matklad/projects/rustraytracer/**.rs`. |
123 | 123 | ||
@@ -282,11 +282,11 @@ The first step of building the model is parsing the source code. | |||
282 | 282 | ||
283 | An important property of the Rust language is that each file can be parsed in | 283 | An important property of the Rust language is that each file can be parsed in |
284 | isolation. Unlike, say, `C++`, an `include` can't change the meaning of the | 284 | isolation. Unlike, say, `C++`, an `include` can't change the meaning of the |
285 | syntax. For this reason, Rust analyzer can build a syntax tree for each "source | 285 | syntax. For this reason, rust-analyzer can build a syntax tree for each "source |
286 | file", which could then be reused by several semantic models if this file | 286 | file", which could then be reused by several semantic models if this file |
287 | happens to be a part of several crates. | 287 | happens to be a part of several crates. |
288 | 288 | ||
289 | Rust analyzer uses a similar representation of syntax trees to that of `Roslyn` | 289 | Rust-analyzer uses a similar representation of syntax trees to that of `Roslyn` |
290 | and Swift's new [libsyntax]. Swift's docs give an excellent overview of the | 290 | and Swift's new [libsyntax]. Swift's docs give an excellent overview of the |
291 | approach, so I skip this part here and instead outline the main characteristics | 291 | approach, so I skip this part here and instead outline the main characteristics |
292 | of the syntax trees: | 292 | of the syntax trees: |
@@ -333,7 +333,7 @@ declarations and recursively process child modules. This is handled by the | |||
333 | 333 | ||
334 | [`module_tree_query`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/module_tree.rs#L116-L123 | 334 | [`module_tree_query`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/module_tree.rs#L116-L123 |
335 | 335 | ||
336 | First, rust analyzer builds a module tree for all crates in a source root | 336 | First, rust-analyzer builds a module tree for all crates in a source root |
337 | simultaneously. The main reason for this is historical (`module_tree` predates | 337 | simultaneously. The main reason for this is historical (`module_tree` predates |
338 | `CrateGraph`), but this approach also enables accounting for files which are not | 338 | `CrateGraph`), but this approach also enables accounting for files which are not |
339 | part of any crate. That is, if you create a file but do not include it as a | 339 | part of any crate. That is, if you create a file but do not include it as a |
@@ -493,7 +493,7 @@ Naturally, name resolution [uses] this stable projection query. | |||
493 | 493 | ||
494 | ## Type inference | 494 | ## Type inference |
495 | 495 | ||
496 | First of all, implementation of type inference in rust analyzer was spearheaded | 496 | First of all, implementation of type inference in rust-analyzer was spearheaded |
497 | by [@flodiebold]. [#327] was an awesome Christmas present, thank you, Florian! | 497 | by [@flodiebold]. [#327] was an awesome Christmas present, thank you, Florian! |
498 | 498 | ||
499 | Type inference runs on per-function granularity and uses the patterns we've | 499 | Type inference runs on per-function granularity and uses the patterns we've |
@@ -518,7 +518,7 @@ construct a mapping from `ExprId`s to types. | |||
518 | 518 | ||
519 | ## Tying it all together: completion | 519 | ## Tying it all together: completion |
520 | 520 | ||
521 | To conclude the overview of the rust analyzer, let's trace the request for | 521 | To conclude the overview of the rust-analyzer, let's trace the request for |
522 | (type-inference powered!) code completion! | 522 | (type-inference powered!) code completion! |
523 | 523 | ||
524 | We start by [receiving a message] from the language client. We decode the | 524 | We start by [receiving a message] from the language client. We decode the |