Skip to content

Commit 32ee097

Browse files
Run proc macro expansion in a separate thread (for the thread-local interner)
1 parent 05d8f5f commit 32ee097

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

Cargo.lock

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/proc-macro-srv/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ tt = { path = "../tt", version = "0.0.0" }
2424
mbe = { path = "../mbe", version = "0.0.0" }
2525
paths = { path = "../paths", version = "0.0.0" }
2626
proc-macro-api = { path = "../proc-macro-api", version = "0.0.0" }
27+
crossbeam = "0.8.1"
2728

2829
[dev-dependencies]
2930
expect-test = "1.4.0"

crates/proc-macro-srv/src/lib.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,16 @@ impl ProcMacroSrv {
6363

6464
let macro_body = task.macro_body.to_subtree();
6565
let attributes = task.attributes.map(|it| it.to_subtree());
66-
let result = expander
67-
.expand(&task.macro_name, &macro_body, attributes.as_ref())
68-
.map(|it| FlatTree::new(&it));
66+
let result = crossbeam::scope(|s| {
67+
s.spawn(|_| {
68+
expander
69+
.expand(&task.macro_name, &macro_body, attributes.as_ref())
70+
.map(|it| FlatTree::new(&it))
71+
})
72+
.join()
73+
.unwrap()
74+
})
75+
.unwrap();
6976

7077
prev_env.rollback();
7178

0 commit comments

Comments
 (0)