Skip to content

Commit a356c6f

Browse files
committed
[FIX] do not hold the borrow onf ile_info for recursive evaluations
1 parent 3ee9311 commit a356c6f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

server/src/core/python_arch_eval.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,22 @@ impl PythonArchEval {
8787
file_info_rc.borrow_mut().prepare_ast(session);
8888
}
8989
let file_info = (*file_info_rc).borrow();
90-
if file_info.file_info_ast.borrow().indexed_module.is_some() {
90+
let file_info_ast = file_info.file_info_ast.clone();
91+
drop(file_info);
92+
if file_info_ast.borrow().indexed_module.is_some() {
9193
let old_noqa = session.current_noqa.clone();
9294
session.current_noqa = symbol.borrow().get_noqas();
93-
let file_info_ast = file_info.file_info_ast.borrow();
95+
let file_info_ast_bw = file_info_ast.borrow();
9496
let (ast, maybe_func_stmt) = match self.file_mode {
9597
true => {
96-
if file_info_ast.text_hash != symbol.borrow().get_processed_text_hash(){
98+
if file_info_ast_bw.text_hash != symbol.borrow().get_processed_text_hash(){
9799
symbol.borrow_mut().set_build_status(BuildSteps::ARCH_EVAL, BuildStatus::INVALID);
98100
return;
99101
}
100-
(file_info_ast.get_stmts().unwrap(), None)
102+
(file_info_ast_bw.get_stmts().unwrap(), None)
101103
},
102104
false => {
103-
let func_stmt = file_info_ast.indexed_module.as_ref().unwrap().get_by_index(self.sym_stack[0].borrow().node_index().unwrap().load());
105+
let func_stmt = file_info_ast_bw.indexed_module.as_ref().unwrap().get_by_index(self.sym_stack[0].borrow().node_index().unwrap().load());
104106
match func_stmt {
105107
AnyRootNodeRef::Stmt(Stmt::FunctionDef(func_stmt)) => {
106108
(&func_stmt.body, Some(func_stmt))
@@ -120,7 +122,6 @@ impl PythonArchEval {
120122
}
121123
session.current_noqa = old_noqa;
122124
}
123-
drop(file_info);
124125
if self.file_mode {
125126
file_info_rc.borrow_mut().replace_diagnostics(BuildSteps::ARCH_EVAL, self.diagnostics.clone());
126127
PythonArchEvalHooks::on_file_eval(session, &self.entry_point, symbol.clone());

0 commit comments

Comments
 (0)