mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Auto merge of #13445 - notJoon:modify-dead-links, r=lnicola
fix) update broken links in guide.md Hi, I Just fixed some broken links in `guide.md`. In most cases, it is not connected by an old version (expecially `guide-2019-01`) of the link, so I made some modifications. Thanks for your time :)
This commit is contained in:
commit
8142d1f606
1 changed files with 25 additions and 25 deletions
|
@ -338,7 +338,7 @@ The algorithm for building a tree of modules is to start with a crate root
|
||||||
declarations and recursively process child modules. This is handled by the
|
declarations and recursively process child modules. This is handled by the
|
||||||
[`module_tree_query`], with two slight variations.
|
[`module_tree_query`], with two slight variations.
|
||||||
|
|
||||||
[`module_tree_query`]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/hir/src/module_tree.rs#L116-L123
|
[`module_tree_query`]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/module_tree.rs#L115-L133
|
||||||
|
|
||||||
First, rust-analyzer builds a module tree for all crates in a source root
|
First, rust-analyzer builds a module tree for all crates in a source root
|
||||||
simultaneously. The main reason for this is historical (`module_tree` predates
|
simultaneously. The main reason for this is historical (`module_tree` predates
|
||||||
|
@ -361,7 +361,7 @@ the same, we don't have to re-execute [`module_tree_query`]. In fact, we only
|
||||||
need to re-execute it when we add/remove new files or when we change mod
|
need to re-execute it when we add/remove new files or when we change mod
|
||||||
declarations.
|
declarations.
|
||||||
|
|
||||||
[`submodules_query`]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/hir/src/module_tree.rs#L41
|
[`submodules_query`]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/module_tree.rs#L41
|
||||||
|
|
||||||
We store the resulting modules in a `Vec`-based indexed arena. The indices in
|
We store the resulting modules in a `Vec`-based indexed arena. The indices in
|
||||||
the arena becomes module IDs. And this brings us to the next topic:
|
the arena becomes module IDs. And this brings us to the next topic:
|
||||||
|
@ -389,8 +389,8 @@ integers which can "intern" a location and return an integer ID back. The salsa
|
||||||
database we use includes a couple of [interners]. How to "garbage collect"
|
database we use includes a couple of [interners]. How to "garbage collect"
|
||||||
unused locations is an open question.
|
unused locations is an open question.
|
||||||
|
|
||||||
[`LocationInterner`]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/base_db/src/loc2id.rs#L65-L71
|
[`LocationInterner`]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_db/src/loc2id.rs#L65-L71
|
||||||
[interners]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/hir/src/db.rs#L22-L23
|
[interners]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/db.rs#L22-L23
|
||||||
|
|
||||||
For example, we use `LocationInterner` to assign IDs to definitions of functions,
|
For example, we use `LocationInterner` to assign IDs to definitions of functions,
|
||||||
structs, enums, etc. The location, [`DefLoc`] contains two bits of information:
|
structs, enums, etc. The location, [`DefLoc`] contains two bits of information:
|
||||||
|
@ -404,7 +404,7 @@ using offsets, text ranges or syntax trees as keys and values for queries. What
|
||||||
we do instead is we store "index" of the item among all of the items of a file
|
we do instead is we store "index" of the item among all of the items of a file
|
||||||
(so, a positional based ID, but localized to a single file).
|
(so, a positional based ID, but localized to a single file).
|
||||||
|
|
||||||
[`DefLoc`]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/hir/src/ids.rs#L127-L139
|
[`DefLoc`]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/ids.rs#L129-L139
|
||||||
|
|
||||||
One thing we've glossed over for the time being is support for macros. We have
|
One thing we've glossed over for the time being is support for macros. We have
|
||||||
only proof of concept handling of macros at the moment, but they are extremely
|
only proof of concept handling of macros at the moment, but they are extremely
|
||||||
|
@ -437,7 +437,7 @@ terms of `HirFileId`! This does not recur infinitely though: any chain of
|
||||||
`HirFileId`s bottoms out in `HirFileId::FileId`, that is, some source file
|
`HirFileId`s bottoms out in `HirFileId::FileId`, that is, some source file
|
||||||
actually written by the user.
|
actually written by the user.
|
||||||
|
|
||||||
[`HirFileId`]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/hir/src/ids.rs#L18-L125
|
[`HirFileId`]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/ids.rs#L31-L93
|
||||||
|
|
||||||
Now that we understand how to identify a definition, in a source or in a
|
Now that we understand how to identify a definition, in a source or in a
|
||||||
macro-generated file, we can discuss name resolution a bit.
|
macro-generated file, we can discuss name resolution a bit.
|
||||||
|
@ -451,14 +451,13 @@ each module into a position-independent representation which does not change if
|
||||||
we modify bodies of the items. After that we [loop] resolving all imports until
|
we modify bodies of the items. After that we [loop] resolving all imports until
|
||||||
we've reached a fixed point.
|
we've reached a fixed point.
|
||||||
|
|
||||||
[lower]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres/lower.rs#L113-L117
|
[lower]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/lower.rs#L113-L147
|
||||||
[loop]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres.rs#L186-L196
|
[loop]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres.rs#L186-L196
|
||||||
|
|
||||||
And, given all our preparation with IDs and a position-independent representation,
|
And, given all our preparation with IDs and a position-independent representation,
|
||||||
it is satisfying to [test] that typing inside function body does not invalidate
|
it is satisfying to [test] that typing inside function body does not invalidate
|
||||||
name resolution results.
|
name resolution results.
|
||||||
|
|
||||||
[test]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres/tests.rs#L376
|
[test]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/tests.rs#L376
|
||||||
|
|
||||||
An interesting fact about name resolution is that it "erases" all of the
|
An interesting fact about name resolution is that it "erases" all of the
|
||||||
intermediate paths from the imports: in the end, we know which items are defined
|
intermediate paths from the imports: in the end, we know which items are defined
|
||||||
|
@ -493,10 +492,10 @@ there's an intermediate [projection query] which returns only the first
|
||||||
position-independent part of the lowering. The result of this query is stable.
|
position-independent part of the lowering. The result of this query is stable.
|
||||||
Naturally, name resolution [uses] this stable projection query.
|
Naturally, name resolution [uses] this stable projection query.
|
||||||
|
|
||||||
[imports]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres/lower.rs#L52-L59
|
[imports]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/lower.rs#L52-L59
|
||||||
[`SourceMap`]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres/lower.rs#L52-L59
|
[`SourceMap`]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/lower.rs#L52-L59
|
||||||
[projection query]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres/lower.rs#L97-L103
|
[projection query]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/lower.rs#L97-L103
|
||||||
[uses]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/hir/src/query_definitions.rs#L49
|
[uses]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/query_definitions.rs#L49
|
||||||
|
|
||||||
## Type inference
|
## Type inference
|
||||||
|
|
||||||
|
@ -518,10 +517,10 @@ construct a mapping from `ExprId`s to types.
|
||||||
|
|
||||||
[@flodiebold]: https://github.com/flodiebold
|
[@flodiebold]: https://github.com/flodiebold
|
||||||
[#327]: https://github.com/rust-lang/rust-analyzer/pull/327
|
[#327]: https://github.com/rust-lang/rust-analyzer/pull/327
|
||||||
[lower the AST]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/hir/src/expr.rs
|
[lower the AST]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/expr.rs
|
||||||
[positional ID]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/hir/src/expr.rs#L13-L15
|
[positional ID]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/expr.rs#L13-L15
|
||||||
[a source map]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/hir/src/expr.rs#L41-L44
|
[a source map]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/expr.rs#L41-L44
|
||||||
[type inference]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/hir/src/ty.rs#L1208-L1223
|
[type inference]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/ty.rs#L1208-L1223
|
||||||
|
|
||||||
## Tying it all together: completion
|
## Tying it all together: completion
|
||||||
|
|
||||||
|
@ -563,10 +562,11 @@ the type to completion.
|
||||||
[catch]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L436-L442
|
[catch]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L436-L442
|
||||||
[the handler]: https://salsa.zulipchat.com/#narrow/stream/181542-rfcs.2Fsalsa-query-group/topic/design.20next.20steps
|
[the handler]: https://salsa.zulipchat.com/#narrow/stream/181542-rfcs.2Fsalsa-query-group/topic/design.20next.20steps
|
||||||
[ask analysis for completion]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/lib.rs#L439-L444
|
[ask analysis for completion]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/lib.rs#L439-L444
|
||||||
[completion implementation]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/completion.rs#L46-L62
|
[ask analysis for completion]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/lib.rs#L439-L444
|
||||||
[`CompletionContext`]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/completion/completion_context.rs#L14-L37
|
[completion implementation]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion.rs#L46-L62
|
||||||
["IntelliJ Trick"]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/completion/completion_context.rs#L72-L75
|
[`CompletionContext`]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion/completion_context.rs#L14-L37
|
||||||
[find an ancestor `fn` node]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/completion/completion_context.rs#L116-L120
|
["IntelliJ Trick"]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion/completion_context.rs#L72-L75
|
||||||
[semantic model]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/completion/completion_context.rs#L123
|
[find an ancestor `fn` node]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion/completion_context.rs#L116-L120
|
||||||
[series of independent completion routines]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/completion.rs#L52-L59
|
[semantic model]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion/completion_context.rs#L123
|
||||||
[`complete_dot`]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/completion/complete_dot.rs#L6-L22
|
[series of independent completion routines]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion.rs#L52-L59
|
||||||
|
[`complete_dot`]: https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion/complete_dot.rs#L6-L22
|
||||||
|
|
Loading…
Reference in a new issue