diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-02-07 04:54:31 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-07 04:54:31 +0000 |
commit | 720abf15ec06220daa7da484953b36cb9d6e8fe2 (patch) | |
tree | 9bc445d1e21a2775dc8d4041e428d80de1f95939 /docs/dev/architecture.md | |
parent | 0a2a124474063ea180990ef767e3e838d4800a38 (diff) | |
parent | a0475f10d8ea9133a456421186055097e2d732b8 (diff) |
Merge #7585
7585: More information for mbe in architecture.md r=edwin0cheng a=edwin0cheng
bors r+
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'docs/dev/architecture.md')
-rw-r--r-- | docs/dev/architecture.md | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md index 1c892e13a..6ccb4a27f 100644 --- a/docs/dev/architecture.md +++ b/docs/dev/architecture.md | |||
@@ -258,8 +258,13 @@ They are independent from the rest of the code. | |||
258 | `mbe` crate contains tools for transforming between syntax trees and token tree. | 258 | `mbe` crate contains tools for transforming between syntax trees and token tree. |
259 | And it also handles the actual parsing and expansion of declarative macro (a-la "Macros By Example" or mbe). | 259 | And it also handles the actual parsing and expansion of declarative macro (a-la "Macros By Example" or mbe). |
260 | 260 | ||
261 | For proc macros, we pass the token trees by loading the corresponding dynamic library (which built by `cargo`). | 261 | For proc macros, the client-server model are used. |
262 | 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. | 262 | We pass an argument `--proc-macro` to `rust-analyzer` binary to start a separate process (`proc_macro_srv`). |
263 | And the client (`proc_macro_api`) provides an interface to talk to that server separately. | ||
264 | |||
265 | And then token trees are passed from client, and the server will load the corresponding dynamic library (which built by `cargo`). | ||
266 | And due to the fact the api for getting result from proc macro are always unstable in `rustc`, | ||
267 | we maintain our own copy (and paste) of that part of code to allow us to build the whole thing in stable rust. | ||
263 | 268 | ||
264 | **Architecture Invariant:** | 269 | **Architecture Invariant:** |
265 | Bad proc macros may panic or segfault accidentally. So we run it in another process and recover it from fatal error. | 270 | Bad proc macros may panic or segfault accidentally. So we run it in another process and recover it from fatal error. |