Use std::panic::resume_unwind

This commit is contained in:
Amos Wenger 2022-07-21 21:35:15 +02:00
parent 48bcc229bf
commit 39db9cdb7d

View File

@ -64,15 +64,23 @@ pub fn expand(&mut self, task: ExpandMacro) -> Result<FlatTree, PanicMessage> {
let macro_body = task.macro_body.to_subtree();
let attributes = task.attributes.map(|it| it.to_subtree());
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();
let res = s
.spawn(|_| {
expander
.expand(&task.macro_name, &macro_body, attributes.as_ref())
.map(|it| FlatTree::new(&it))
})
.join();
match res {
Ok(res) => res,
Err(e) => std::panic::resume_unwind(e),
}
});
let result = match result {
Ok(result) => result,
Err(e) => std::panic::resume_unwind(e),
};
prev_env.rollback();