aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-20 17:31:05 +0000
committerAleksey Kladov <[email protected]>2019-01-21 08:27:01 +0000
commitce47d6b7b68a658bd65211a07aab7baaffff4a50 (patch)
tree8194d092c302a5e0ded959a916dc5b3548bd7d17
parent743384204055fcf20ec8957e056215b4d9fb36f2 (diff)
reach fixed-point for rust-analyzer spelling
-rw-r--r--guide.md16
1 files changed, 8 insertions, 8 deletions
diff --git a/guide.md b/guide.md
index d5ae2d1e0..cbdbff6d0 100644
--- a/guide.md
+++ b/guide.md
@@ -2,7 +2,7 @@
2 2
3## About the guide 3## About the guide
4 4
5This guide describes the current state of `rust-analyzer` as of 2019-01-20 5This 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
7architectural solutions related to the problem of building IDE-first compiler 7architectural solutions related to the problem of building IDE-first compiler
8for Rust. 8for Rust.
@@ -11,7 +11,7 @@ for Rust.
11 11
12## The big picture 12## The big picture
13 13
14On the highest possible level, rust analyzer is a stateful component. A client may 14On the highest possible level, rust-analyzer is a stateful component. A client may
15apply changes to the analyzer (new contents of `foo.rs` file is "fn main() {}") 15apply changes to the analyzer (new contents of `foo.rs` file is "fn main() {}")
16and it may ask semantic questions about the current state (what is the 16and it may ask semantic questions about the current state (what is the
17definition of the identifier with offset 92 in file `bar.rs`?). Two important 17definition 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
117Rust the set of "input" files is not necessary known up-front. In theory, you 117Rust the set of "input" files is not necessary known up-front. In theory, you
118can have `#[path="/dev/random"] mod foo;`. 118can have `#[path="/dev/random"] mod foo;`.
119 119
120To solve (or explicitly refuse to solve) these problems rust analyzer uses the 120To solve (or explicitly refuse to solve) these problems rust-analyzer uses the
121concept of source root. Roughly speaking, source roots is a contents of a 121concept of source root. Roughly speaking, source roots is a contents of a
122directory on a file systems, like `/home/matklad/projects/rustraytracer/**.rs`. 122directory 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
283An important property of the Rust language is that each file can be parsed in 283An important property of the Rust language is that each file can be parsed in
284isolation. Unlike, say, `C++`, an `include` can't change the meaning of the 284isolation. Unlike, say, `C++`, an `include` can't change the meaning of the
285syntax. For this reason, Rust analyzer can build a syntax tree for each "source 285syntax. For this reason, rust-analyzer can build a syntax tree for each "source
286file", which could then be reused by several semantic models if this file 286file", which could then be reused by several semantic models if this file
287happens to be a part of several crates. 287happens to be a part of several crates.
288 288
289Rust analyzer uses a similar representation of syntax trees to that of `Roslyn` 289Rust-analyzer uses a similar representation of syntax trees to that of `Roslyn`
290and Swift's new [libsyntax]. Swift's docs give an excellent overview of the 290and Swift's new [libsyntax]. Swift's docs give an excellent overview of the
291approach, so I skip this part here and instead outline the main characteristics 291approach, so I skip this part here and instead outline the main characteristics
292of the syntax trees: 292of 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
336First, rust analyzer builds a module tree for all crates in a source root 336First, rust-analyzer builds a module tree for all crates in a source root
337simultaneously. The main reason for this is historical (`module_tree` predates 337simultaneously. 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
339part of any crate. That is, if you create a file but do not include it as a 339part 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
496First of all, implementation of type inference in rust analyzer was spearheaded 496First of all, implementation of type inference in rust-analyzer was spearheaded
497by [@flodiebold]. [#327] was an awesome Christmas present, thank you, Florian! 497by [@flodiebold]. [#327] was an awesome Christmas present, thank you, Florian!
498 498
499Type inference runs on per-function granularity and uses the patterns we've 499Type 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
521To conclude the overview of the rust analyzer, let's trace the request for 521To 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
524We start by [receiving a message] from the language client. We decode the 524We start by [receiving a message] from the language client. We decode the