doc edits
This commit is contained in:
parent
37e0c09f77
commit
4e34e79914
|
|
@ -79,7 +79,7 @@
|
||||||
- [Incremental compilation](./queries/incremental-compilation.md)
|
- [Incremental compilation](./queries/incremental-compilation.md)
|
||||||
- [Incremental compilation In Detail](./queries/incremental-compilation-in-detail.md)
|
- [Incremental compilation In Detail](./queries/incremental-compilation-in-detail.md)
|
||||||
- [Debugging and Testing](./incrcomp-debugging.md)
|
- [Debugging and Testing](./incrcomp-debugging.md)
|
||||||
- [Salsa](./salsa.md)
|
- [Salsa](./queries/salsa.md)
|
||||||
- [Memory Management in Rustc](./memory.md)
|
- [Memory Management in Rustc](./memory.md)
|
||||||
- [Serialization in Rustc](./serialization.md)
|
- [Serialization in Rustc](./serialization.md)
|
||||||
- [Parallel Compilation](./parallel-rustc.md)
|
- [Parallel Compilation](./parallel-rustc.md)
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,11 @@ Matsakis.
|
||||||
|
|
||||||
> As of <!-- date-check --> November 2022, although `Salsa` is inspired by (among
|
> As of <!-- date-check --> November 2022, although `Salsa` is inspired by (among
|
||||||
> other things) `rustc`'s query system, it is not used directly in `rustc`. It
|
> other things) `rustc`'s query system, it is not used directly in `rustc`. It
|
||||||
> _is_ used in [chalk], an implementation of Rust's trait system, and
|
> _is_ used in [chalk], an implementation of Rust's `trait` system, and
|
||||||
> extensively in [`rust-analyzer`], the official implementation of the language
|
> extensively in [`rust-analyzer`], the official implementation of the language
|
||||||
> server protocol for Rust, but there are no medium or long-term concrete
|
> server protocol for Rust, but there are no medium or long-term concrete
|
||||||
> plans to integrate it into the compiler.
|
> plans to integrate it into the compiler.
|
||||||
|
|
||||||
|
|
||||||
[`rust-analyzer`]: https://rust-analyzer.github.io/
|
[`rust-analyzer`]: https://rust-analyzer.github.io/
|
||||||
[chalk]: https://rust-lang.github.io/chalk/book/what_is_chalk.html
|
[chalk]: https://rust-lang.github.io/chalk/book/what_is_chalk.html
|
||||||
|
|
||||||
|
|
@ -33,12 +32,11 @@ The objectives of `Salsa` are:
|
||||||
results as if it had been done from scratch.
|
results as if it had been done from scratch.
|
||||||
|
|
||||||
`Salsa`'s actual model is much richer, allowing many kinds of inputs and many
|
`Salsa`'s actual model is much richer, allowing many kinds of inputs and many
|
||||||
different outputs.
|
different outputs. For example, integrating `Salsa` with an IDE could mean that
|
||||||
For example, integrating `Salsa` with an IDE could mean that the inputs could be
|
the inputs could be manifests (`Cargo.toml`, `rust-toolchain.toml`), entire
|
||||||
the manifest (`Cargo.toml`), entire source files (`foo.rs`), snippets and so
|
source files (`foo.rs`), snippets and so on. The outputs of such an integration
|
||||||
on; the outputs of such an integration could range from a binary executable, to
|
could range from a binary executable, to lints, types (for example, if a user
|
||||||
lints, types (for example, if a user selects a certain variable and wishes to
|
selects a certain variable and wishes to see its type), completions, etc.
|
||||||
see its type), completions, etc.
|
|
||||||
|
|
||||||
## How does it work?
|
## How does it work?
|
||||||
|
|
||||||
|
|
@ -50,8 +48,8 @@ something that the library produces, but, for each derived value there's a
|
||||||
"pure" function that computes the derived value.
|
"pure" function that computes the derived value.
|
||||||
|
|
||||||
For example, there might be a function `ast(x: Path) -> AST`. The produced
|
For example, there might be a function `ast(x: Path) -> AST`. The produced
|
||||||
`AST` isn't a final value, it's an intermediate value that the library would
|
Abstract Syntax Tree (`AST`) isn't a final value, it's an intermediate value
|
||||||
use for the computation.
|
that the library would use for the computation.
|
||||||
|
|
||||||
This means that when you try to compute with the library, `Salsa` is going to
|
This means that when you try to compute with the library, `Salsa` is going to
|
||||||
compute various derived values, and eventually read the input and produce the
|
compute various derived values, and eventually read the input and produce the
|
||||||
|
|
@ -120,13 +118,13 @@ A query group is a set of queries which have been defined together as a unit.
|
||||||
The database is formed by combining query groups. Query groups are akin to
|
The database is formed by combining query groups. Query groups are akin to
|
||||||
"`Salsa` modules".
|
"`Salsa` modules".
|
||||||
|
|
||||||
A set of queries in a query group are just a set of methods in a trait.
|
A set of queries in a query group are just a set of methods in a `trait`.
|
||||||
|
|
||||||
To create a query group a trait annotated with a specific attribute
|
To create a query group a `trait` annotated with a specific attribute
|
||||||
(`#[salsa::query_group(...)]`) has to be created.
|
(`#[salsa::query_group(...)]`) has to be created.
|
||||||
|
|
||||||
An argument must also be provided to said attribute as it will be used by Salsa
|
An argument must also be provided to said attribute as it will be used by `Salsa`
|
||||||
to create a struct to be used later when the database is created.
|
to create a `struct` to be used later when the database is created.
|
||||||
|
|
||||||
Example input query group:
|
Example input query group:
|
||||||
|
|
||||||
|
|
@ -188,11 +186,11 @@ fn ast(db: &impl Parser, name: String) -> String {
|
||||||
```
|
```
|
||||||
|
|
||||||
Eventually, after all the query groups have been defined, the database can be
|
Eventually, after all the query groups have been defined, the database can be
|
||||||
created by declaring a struct.
|
created by declaring a `struct`.
|
||||||
|
|
||||||
To specify which query groups are going to be part of the database an attribute
|
To specify which query groups are going to be part of the database an `attribute`
|
||||||
(`#[salsa::database(...)]`) must be added. The argument of said attribute is a
|
(`#[salsa::database(...)]`) must be added. The argument of said `attribute` is a
|
||||||
list of identifiers, specifying the query groups **storages**.
|
list of `identifiers`, specifying the query groups **storages**.
|
||||||
|
|
||||||
```rust,ignore
|
```rust,ignore
|
||||||
///This attribute specifies which query groups are going to be in the database
|
///This attribute specifies which query groups are going to be in the database
|
||||||
Loading…
Reference in New Issue