Run proc macro expansion in a separate thread (for the thread-local interner)

This commit is contained in:
Amos Wenger 2022-07-21 18:11:50 +02:00
parent 05d8f5fee7
commit 32ee097580
3 changed files with 36 additions and 3 deletions

View file

@ -24,6 +24,7 @@ tt = { path = "../tt", version = "0.0.0" }
mbe = { path = "../mbe", version = "0.0.0" }
paths = { path = "../paths", version = "0.0.0" }
proc-macro-api = { path = "../proc-macro-api", version = "0.0.0" }
crossbeam = "0.8.1"
[dev-dependencies]
expect-test = "1.4.0"

View file

@ -63,9 +63,16 @@ impl ProcMacroSrv {
let macro_body = task.macro_body.to_subtree();
let attributes = task.attributes.map(|it| it.to_subtree());
let result = expander
.expand(&task.macro_name, &macro_body, attributes.as_ref())
.map(|it| FlatTree::new(&it));
let result = crossbeam::scope(|s| {
s.spawn(|_| {
expander
.expand(&task.macro_name, &macro_body, attributes.as_ref())
.map(|it| FlatTree::new(&it))
})
.join()
.unwrap()
})
.unwrap();
prev_env.rollback();