Skip to content

Commit 0e002fe

Browse files
committed
Auto merge of rust-lang#15549 - Veykril:unwind-if-cancelled, r=Veykril
Add a few more `db.unwind_if_cancelled()` calls Judging from a profile sent by a friend, the borrowck query took up a significant amount of time in their project which might be the cause for some unresponsiveness as nothing in the mir stack currently unwinds on cancellation
2 parents 8a29d07 + 0bf0563 commit 0e002fe

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

crates/hir-ty/src/mir/borrowck.rs

+2
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ fn moved_out_of_ref(db: &dyn HirDatabase, body: &MirBody) -> Vec<MovedOutOfRef>
120120
Operand::Constant(_) | Operand::Static(_) => (),
121121
};
122122
for (_, block) in body.basic_blocks.iter() {
123+
db.unwind_if_cancelled();
123124
for statement in &block.statements {
124125
match &statement.kind {
125126
StatementKind::Assign(_, r) => match r {
@@ -318,6 +319,7 @@ fn ever_initialized_map(
318319
dfs(db, body, body.start_block, l, &mut result);
319320
}
320321
for l in body.locals.iter().map(|it| it.0) {
322+
db.unwind_if_cancelled();
321323
if !result[body.start_block].contains_idx(l) {
322324
result[body.start_block].insert(l, false);
323325
dfs(db, body, body.start_block, l, &mut result);

crates/hir/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,7 @@ impl DefWithBody {
14461446
}
14471447

14481448
pub fn diagnostics(self, db: &dyn HirDatabase, acc: &mut Vec<AnyDiagnostic>) {
1449+
db.unwind_if_cancelled();
14491450
let krate = self.module(db).id.krate();
14501451

14511452
let (body, source_map) = db.body_with_source_map(self.into());

0 commit comments

Comments
 (0)