mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Run proc macro expansion in a separate thread (for the thread-local interner)
This commit is contained in:
parent
05d8f5fee7
commit
32ee097580
3 changed files with 36 additions and 3 deletions
25
Cargo.lock
generated
25
Cargo.lock
generated
|
@ -247,6 +247,20 @@ dependencies = [
|
|||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ae5588f6b3c3cb05239e90bd110f257254aecd01e4635400391aeae07497845"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-channel",
|
||||
"crossbeam-deque",
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-queue",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.5"
|
||||
|
@ -282,6 +296,16 @@ dependencies = [
|
|||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-queue"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.10"
|
||||
|
@ -1162,6 +1186,7 @@ dependencies = [
|
|||
name = "proc-macro-srv"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"crossbeam",
|
||||
"expect-test",
|
||||
"libloading",
|
||||
"mbe",
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
let result = crossbeam::scope(|s| {
|
||||
s.spawn(|_| {
|
||||
expander
|
||||
.expand(&task.macro_name, ¯o_body, attributes.as_ref())
|
||||
.map(|it| FlatTree::new(&it));
|
||||
.map(|it| FlatTree::new(&it))
|
||||
})
|
||||
.join()
|
||||
.unwrap()
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
prev_env.rollback();
|
||||
|
||||
|
|
Loading…
Reference in a new issue