Use async_maybe! instead of inline IIFEs (#6906)

This PR replaces instances where we were using an async IIFE with the
`async_maybe!` macro.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-01-27 20:49:56 -05:00 committed by GitHub
parent 5b9cc26194
commit bbdf401a78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 55 additions and 44 deletions

View file

@ -9,6 +9,7 @@ use regex::Regex;
use smol::fs::{self, File};
use std::{any::Any, borrow::Cow, env::consts, path::PathBuf, str, sync::Arc};
use util::{
async_maybe,
fs::remove_matching,
github::{latest_github_release, GitHubLspBinaryVersion},
ResultExt,
@ -272,7 +273,7 @@ impl LspAdapter for RustLspAdapter {
}
async fn get_cached_server_binary(container_dir: PathBuf) -> Option<LanguageServerBinary> {
(|| async move {
async_maybe!({
let mut last = None;
let mut entries = fs::read_dir(&container_dir).await?;
while let Some(entry) = entries.next().await {
@ -283,7 +284,7 @@ async fn get_cached_server_binary(container_dir: PathBuf) -> Option<LanguageServ
path: last.ok_or_else(|| anyhow!("no cached binary"))?,
arguments: Default::default(),
})
})()
})
.await
.log_err()
}