From 86484233c04aaa8fb2d4a7fcee550591e06c5fc5 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Sun, 4 May 2025 15:12:21 -0600 Subject: [PATCH] Replace `std::sync::Mutex` with `parking_lot::Mutex` in `languages/src/python.rs` (#29889) This appears to be the only place `std::sync::Mutex` is used, Zed always prefers `parking_lot`. Release Notes: - N/A --- Cargo.lock | 1 + crates/languages/Cargo.toml | 1 + crates/languages/src/python.rs | 12 ++++-------- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80aa1bec3d..614df9cd74 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7992,6 +7992,7 @@ dependencies = [ "log", "lsp", "node_runtime", + "parking_lot", "paths", "pet", "pet-conda", diff --git a/crates/languages/Cargo.toml b/crates/languages/Cargo.toml index af528848d0..8e7b93cd9c 100644 --- a/crates/languages/Cargo.toml +++ b/crates/languages/Cargo.toml @@ -46,6 +46,7 @@ language.workspace = true log.workspace = true lsp.workspace = true node_runtime.workspace = true +parking_lot.workspace = true paths.workspace = true pet-conda.workspace = true pet-core.workspace = true diff --git a/crates/languages/src/python.rs b/crates/languages/src/python.rs index b5ffc7d86c..6d515f2e44 100644 --- a/crates/languages/src/python.rs +++ b/crates/languages/src/python.rs @@ -23,8 +23,8 @@ use serde_json::{Value, json}; use smol::lock::OnceCell; use std::cmp::Ordering; +use parking_lot::Mutex; use std::str::FromStr; -use std::sync::Mutex; use std::{ any::Any, borrow::Cow, @@ -671,7 +671,6 @@ impl ToolchainLister for PythonToolchainProvider { let mut toolchains = reporter .environments .lock() - .ok() .map_or(Vec::new(), |mut guard| std::mem::take(&mut guard)); let wr = worktree_root; @@ -823,7 +822,7 @@ impl pet_core::os_environment::Environment for EnvironmentApi<'_> { } fn get_know_global_search_locations(&self) -> Vec { - if self.global_search_locations.lock().unwrap().is_empty() { + if self.global_search_locations.lock().is_empty() { let mut paths = std::env::split_paths(&self.get_env_var("PATH".to_string()).unwrap_or_default()) .collect::>(); @@ -840,12 +839,9 @@ impl pet_core::os_environment::Environment for EnvironmentApi<'_> { .filter(|p| p.exists()) .collect::>(); - self.global_search_locations - .lock() - .unwrap() - .append(&mut paths); + self.global_search_locations.lock().append(&mut paths); } - self.global_search_locations.lock().unwrap().clone() + self.global_search_locations.lock().clone() } }