Skip to content

Commit 4087535

Browse files
committed
Auto merge of rust-lang#12891 - brennanvincent:expander_stack, r=lnicola
Use large stack on expander thread I have verified that this fixes rust-lang#12884 for me. Hat tip to `@bjorn3` for identifying the cause of the issue.
2 parents 9a1ec45 + f83738e commit 4087535

File tree

1 file changed

+10
-3
lines changed
  • crates/proc-macro-srv/src

1 file changed

+10
-3
lines changed

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

+10-3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ pub(crate) struct ProcMacroSrv {
3939
expanders: HashMap<(PathBuf, SystemTime), dylib::Expander>,
4040
}
4141

42+
const EXPANDER_STACK_SIZE: usize = 8 * 1024 * 1024;
43+
4244
impl ProcMacroSrv {
4345
pub fn expand(&mut self, task: ExpandMacro) -> Result<FlatTree, PanicMessage> {
4446
let expander = self.expander(task.lib.as_ref()).map_err(|err| {
@@ -66,13 +68,18 @@ impl ProcMacroSrv {
6668
// FIXME: replace this with std's scoped threads once they stabilize
6769
// (then remove dependency on crossbeam)
6870
let result = crossbeam::scope(|s| {
69-
let res = s
71+
let res = match s
72+
.builder()
73+
.stack_size(EXPANDER_STACK_SIZE)
74+
.name(task.macro_name.clone())
7075
.spawn(|_| {
7176
expander
7277
.expand(&task.macro_name, &macro_body, attributes.as_ref())
7378
.map(|it| FlatTree::new(&it))
74-
})
75-
.join();
79+
}) {
80+
Ok(handle) => handle.join(),
81+
Err(e) => std::panic::resume_unwind(Box::new(e)),
82+
};
7683

7784
match res {
7885
Ok(res) => res,

0 commit comments

Comments
 (0)