From 0e19b061d4829d4ba68d6f8ade86e6bee51a084b Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 9 Jul 2021 17:35:57 +0200 Subject: [PATCH] Fix warnings --- zed/src/worktree.rs | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/zed/src/worktree.rs b/zed/src/worktree.rs index b65275ba1ee12163ea94c91365e9b8698beeaae3..22293efb5a8765510291733a2fd97c64ab2905b2 100644 --- a/zed/src/worktree.rs +++ b/zed/src/worktree.rs @@ -14,7 +14,7 @@ use crate::{ use ::ignore::gitignore::Gitignore; use anyhow::{anyhow, Context, Result}; use atomic::Ordering::SeqCst; -use futures::{future, stream, Stream, StreamExt}; +use futures::{Stream, StreamExt}; pub use fuzzy::{match_paths, PathMatch}; use gpui::{ executor, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext, @@ -23,18 +23,16 @@ use gpui::{ use lazy_static::lazy_static; use parking_lot::Mutex; use postage::{ - broadcast, prelude::{Sink as _, Stream as _}, watch, }; use smol::{ channel::{self, Sender}, io::{AsyncReadExt, AsyncWriteExt}, - lock::RwLock, }; use std::{ cmp::{self, Ordering}, - collections::{BTreeMap, HashMap}, + collections::HashMap, convert::{TryFrom, TryInto}, ffi::{OsStr, OsString}, fmt, @@ -196,12 +194,14 @@ struct InMemoryEntry { content: Option, } +#[cfg(any(test, feature = "test-support"))] struct InMemoryFsState { - entries: BTreeMap, + entries: std::collections::BTreeMap, next_inode: u64, - events_tx: broadcast::Sender, + events_tx: postage::broadcast::Sender, } +#[cfg(any(test, feature = "test-support"))] impl InMemoryFsState { fn validate_path(&self, path: &Path) -> Result<()> { if path.is_absolute() @@ -228,14 +228,16 @@ impl InMemoryFsState { } } +#[cfg(any(test, feature = "test-support"))] pub struct InMemoryFs { - state: RwLock, + state: smol::lock::RwLock, } +#[cfg(any(test, feature = "test-support"))] impl InMemoryFs { pub fn new() -> Self { - let (events_tx, _) = broadcast::channel(2048); - let mut entries = BTreeMap::new(); + let (events_tx, _) = postage::broadcast::channel(2048); + let mut entries = std::collections::BTreeMap::new(); entries.insert( Path::new("/").to_path_buf(), InMemoryEntry { @@ -247,7 +249,7 @@ impl InMemoryFs { }, ); Self { - state: RwLock::new(InMemoryFsState { + state: smol::lock::RwLock::new(InMemoryFsState { entries, next_inode: 1, events_tx, @@ -309,11 +311,12 @@ impl InMemoryFs { } } - pub async fn events(&self) -> broadcast::Receiver { + pub async fn events(&self) -> postage::broadcast::Receiver { self.state.read().await.events_tx.subscribe() } } +#[cfg(any(test, feature = "test-support"))] #[async_trait::async_trait] impl Fs for InMemoryFs { async fn entry( @@ -350,6 +353,8 @@ impl Fs for InMemoryFs { path: &'a Path, abs_path: &'a Path, ) -> Result> + Send>>> { + use futures::{future, stream}; + let state = self.state.read().await; Ok(stream::iter(state.entries.clone()) .filter(move |(child_path, _)| future::ready(child_path.parent() == Some(abs_path))) @@ -2134,7 +2139,7 @@ impl BackgroundScanner { } #[cfg(any(test, feature = "test-support"))] - async fn run_test(mut self, mut events_rx: broadcast::Receiver) { + async fn run_test(mut self, mut events_rx: postage::broadcast::Receiver) { if self.notify.send(ScanState::Scanning).await.is_err() { return; }