mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Update architecture.md for mbe and proc-macro
This commit is contained in:
parent
df7f5e9421
commit
504a54b222
1 changed files with 11 additions and 0 deletions
|
@ -254,6 +254,17 @@ A single `rust-analyzer` process can serve many projects, so it is important tha
|
||||||
These crates implement macros as token tree -> token tree transforms.
|
These crates implement macros as token tree -> token tree transforms.
|
||||||
They are independent from the rest of the code.
|
They are independent from the rest of the code.
|
||||||
|
|
||||||
|
`tt` crate defined `TokenTree`, a single token or a delimited sequence of token trees.
|
||||||
|
`mbe` crate contains tools for transforming between syntax trees and token tree.
|
||||||
|
And it also handles the actual parsing and expansion of declarative macro (a-la "Macros By Example" or mbe).
|
||||||
|
|
||||||
|
For proc macros, we pass the token trees by loading the corresponding dynamic library (which built by `cargo`).
|
||||||
|
That's why the client (`proc_macro_api`) and server (`proc_macro_srv`) model are used to run proc-macro in separate process in background.
|
||||||
|
|
||||||
|
**Architecture Invariant:**
|
||||||
|
Bad proc macros may panic or segfault accidentally. So we run it in another process and recover it from fatal error.
|
||||||
|
And they may be non-deterministic which conflict how `salsa` works, so special attention is required.
|
||||||
|
|
||||||
### `crates/cfg`
|
### `crates/cfg`
|
||||||
|
|
||||||
This crate is responsible for parsing, evaluation and general definition of `cfg` attributes.
|
This crate is responsible for parsing, evaluation and general definition of `cfg` attributes.
|
||||||
|
|
Loading…
Reference in a new issue