Skip to content

Commit 7f3f296

Browse files
authored
Enable clippy::await_holding_lock (#9362)
This PR enables the [`clippy::await_holding_lock`](https://rust-lang.github.io/rust-clippy/master/index.html#/await_holding_lock) rule and fixes the outstanding violations. Release Notes: - N/A
1 parent b0ce25b commit 7f3f296

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ style = "allow"
406406
# Individual rules that have violations in the codebase:
407407
almost_complete_range = "allow"
408408
arc_with_non_send_sync = "allow"
409-
await_holding_lock = "allow"
410409
borrowed_box = "allow"
411410
derive_ord_xor_partial_ord = "allow"
412411
eq_op = "allow"

crates/project/src/project.rs

+23-17
Original file line numberDiff line numberDiff line change
@@ -5235,16 +5235,19 @@ impl Project {
52355235
project_id.ok_or_else(|| anyhow!("Remote project without remote_id"))?;
52365236

52375237
for completion_index in completion_indices {
5238-
let completions_guard = completions.read();
5239-
let completion = &completions_guard[completion_index];
5240-
if completion.documentation.is_some() {
5241-
continue;
5242-
}
5238+
let (server_id, completion) = {
5239+
let completions_guard = completions.read();
5240+
let completion = &completions_guard[completion_index];
5241+
if completion.documentation.is_some() {
5242+
continue;
5243+
}
52435244

5244-
did_resolve = true;
5245-
let server_id = completion.server_id;
5246-
let completion = completion.lsp_completion.clone();
5247-
drop(completions_guard);
5245+
did_resolve = true;
5246+
let server_id = completion.server_id;
5247+
let completion = completion.lsp_completion.clone();
5248+
5249+
(server_id, completion)
5250+
};
52485251

52495252
Self::resolve_completion_documentation_remote(
52505253
project_id,
@@ -5259,15 +5262,18 @@ impl Project {
52595262
}
52605263
} else {
52615264
for completion_index in completion_indices {
5262-
let completions_guard = completions.read();
5263-
let completion = &completions_guard[completion_index];
5264-
if completion.documentation.is_some() {
5265-
continue;
5266-
}
5265+
let (server_id, completion) = {
5266+
let completions_guard = completions.read();
5267+
let completion = &completions_guard[completion_index];
5268+
if completion.documentation.is_some() {
5269+
continue;
5270+
}
5271+
5272+
let server_id = completion.server_id;
5273+
let completion = completion.lsp_completion.clone();
52675274

5268-
let server_id = completion.server_id;
5269-
let completion = completion.lsp_completion.clone();
5270-
drop(completions_guard);
5275+
(server_id, completion)
5276+
};
52715277

52725278
let server = this
52735279
.read_with(&mut cx, |project, _| {

0 commit comments

Comments
 (0)