mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Auto merge of #12891 - brennanvincent:expander_stack, r=lnicola
Use large stack on expander thread I have verified that this fixes #12884 for me. Hat tip to `@bjorn3` for identifying the cause of the issue.
This commit is contained in:
commit
40875353a5
@ -39,6 +39,8 @@ pub(crate) struct ProcMacroSrv {
|
|||||||
expanders: HashMap<(PathBuf, SystemTime), dylib::Expander>,
|
expanders: HashMap<(PathBuf, SystemTime), dylib::Expander>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const EXPANDER_STACK_SIZE: usize = 8 * 1024 * 1024;
|
||||||
|
|
||||||
impl ProcMacroSrv {
|
impl ProcMacroSrv {
|
||||||
pub fn expand(&mut self, task: ExpandMacro) -> Result<FlatTree, PanicMessage> {
|
pub fn expand(&mut self, task: ExpandMacro) -> Result<FlatTree, PanicMessage> {
|
||||||
let expander = self.expander(task.lib.as_ref()).map_err(|err| {
|
let expander = self.expander(task.lib.as_ref()).map_err(|err| {
|
||||||
@ -66,13 +68,18 @@ impl ProcMacroSrv {
|
|||||||
// FIXME: replace this with std's scoped threads once they stabilize
|
// FIXME: replace this with std's scoped threads once they stabilize
|
||||||
// (then remove dependency on crossbeam)
|
// (then remove dependency on crossbeam)
|
||||||
let result = crossbeam::scope(|s| {
|
let result = crossbeam::scope(|s| {
|
||||||
let res = s
|
let res = match s
|
||||||
|
.builder()
|
||||||
|
.stack_size(EXPANDER_STACK_SIZE)
|
||||||
|
.name(task.macro_name.clone())
|
||||||
.spawn(|_| {
|
.spawn(|_| {
|
||||||
expander
|
expander
|
||||||
.expand(&task.macro_name, ¯o_body, attributes.as_ref())
|
.expand(&task.macro_name, ¯o_body, attributes.as_ref())
|
||||||
.map(|it| FlatTree::new(&it))
|
.map(|it| FlatTree::new(&it))
|
||||||
})
|
}) {
|
||||||
.join();
|
Ok(handle) => handle.join(),
|
||||||
|
Err(e) => std::panic::resume_unwind(Box::new(e)),
|
||||||
|
};
|
||||||
|
|
||||||
match res {
|
match res {
|
||||||
Ok(res) => res,
|
Ok(res) => res,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user