aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2021-02-07 04:49:02 +0000
committerEdwin Cheng <[email protected]>2021-02-07 04:51:30 +0000
commit542e35e39789d45756c4483f07c831ebbb352ebe (patch)
treef9e2f343b08a7e90a3e0306bd0b9fda487a68cca
parent504a54b222553a096c8eaa0cd9efca33d916c275 (diff)
More information for mbe
-rw-r--r--docs/dev/architecture.md9
1 files changed, 7 insertions, 2 deletions
diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md
index 1c892e13a..c5e4acea3 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.
259And it also handles the actual parsing and expansion of declarative macro (a-la "Macros By Example" or mbe). 259And it also handles the actual parsing and expansion of declarative macro (a-la "Macros By Example" or mbe).
260 260
261For proc macros, we pass the token trees by loading the corresponding dynamic library (which built by `cargo`). 261For proc macros, the client-server model are used to run proc-macro.
262That's why the client (`proc_macro_api`) and server (`proc_macro_srv`) model are used to run proc-macro in separate process in background. 262We pass an argument `--proc-macro` to `rust-analyzer` binary to start a separate process (`proc_macro_srv`).
263And the client (`proc_macro_api`) provides an interface to talk to that server separately.
264
265And then token trees are passed from client, and the server will load the corresponding dynamic library (which built by `cargo`).
266And due to the fact the api for getting result from proc macro are always unstable in `rustc`,
267we 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:**
265Bad proc macros may panic or segfault accidentally. So we run it in another process and recover it from fatal error. 270Bad proc macros may panic or segfault accidentally. So we run it in another process and recover it from fatal error.