mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-28 17:43:20 +03:00
Fix warnings
This commit is contained in:
parent
3d799fe8e7
commit
0e19b061d4
@ -14,7 +14,7 @@ use crate::{
|
|||||||
use ::ignore::gitignore::Gitignore;
|
use ::ignore::gitignore::Gitignore;
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use atomic::Ordering::SeqCst;
|
use atomic::Ordering::SeqCst;
|
||||||
use futures::{future, stream, Stream, StreamExt};
|
use futures::{Stream, StreamExt};
|
||||||
pub use fuzzy::{match_paths, PathMatch};
|
pub use fuzzy::{match_paths, PathMatch};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
executor, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext,
|
executor, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext,
|
||||||
@ -23,18 +23,16 @@ use gpui::{
|
|||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use postage::{
|
use postage::{
|
||||||
broadcast,
|
|
||||||
prelude::{Sink as _, Stream as _},
|
prelude::{Sink as _, Stream as _},
|
||||||
watch,
|
watch,
|
||||||
};
|
};
|
||||||
use smol::{
|
use smol::{
|
||||||
channel::{self, Sender},
|
channel::{self, Sender},
|
||||||
io::{AsyncReadExt, AsyncWriteExt},
|
io::{AsyncReadExt, AsyncWriteExt},
|
||||||
lock::RwLock,
|
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{self, Ordering},
|
cmp::{self, Ordering},
|
||||||
collections::{BTreeMap, HashMap},
|
collections::HashMap,
|
||||||
convert::{TryFrom, TryInto},
|
convert::{TryFrom, TryInto},
|
||||||
ffi::{OsStr, OsString},
|
ffi::{OsStr, OsString},
|
||||||
fmt,
|
fmt,
|
||||||
@ -196,12 +194,14 @@ struct InMemoryEntry {
|
|||||||
content: Option<String>,
|
content: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
struct InMemoryFsState {
|
struct InMemoryFsState {
|
||||||
entries: BTreeMap<PathBuf, InMemoryEntry>,
|
entries: std::collections::BTreeMap<PathBuf, InMemoryEntry>,
|
||||||
next_inode: u64,
|
next_inode: u64,
|
||||||
events_tx: broadcast::Sender<fsevent::Event>,
|
events_tx: postage::broadcast::Sender<fsevent::Event>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
impl InMemoryFsState {
|
impl InMemoryFsState {
|
||||||
fn validate_path(&self, path: &Path) -> Result<()> {
|
fn validate_path(&self, path: &Path) -> Result<()> {
|
||||||
if path.is_absolute()
|
if path.is_absolute()
|
||||||
@ -228,14 +228,16 @@ impl InMemoryFsState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub struct InMemoryFs {
|
pub struct InMemoryFs {
|
||||||
state: RwLock<InMemoryFsState>,
|
state: smol::lock::RwLock<InMemoryFsState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
impl InMemoryFs {
|
impl InMemoryFs {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let (events_tx, _) = broadcast::channel(2048);
|
let (events_tx, _) = postage::broadcast::channel(2048);
|
||||||
let mut entries = BTreeMap::new();
|
let mut entries = std::collections::BTreeMap::new();
|
||||||
entries.insert(
|
entries.insert(
|
||||||
Path::new("/").to_path_buf(),
|
Path::new("/").to_path_buf(),
|
||||||
InMemoryEntry {
|
InMemoryEntry {
|
||||||
@ -247,7 +249,7 @@ impl InMemoryFs {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
Self {
|
Self {
|
||||||
state: RwLock::new(InMemoryFsState {
|
state: smol::lock::RwLock::new(InMemoryFsState {
|
||||||
entries,
|
entries,
|
||||||
next_inode: 1,
|
next_inode: 1,
|
||||||
events_tx,
|
events_tx,
|
||||||
@ -309,11 +311,12 @@ impl InMemoryFs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn events(&self) -> broadcast::Receiver<fsevent::Event> {
|
pub async fn events(&self) -> postage::broadcast::Receiver<fsevent::Event> {
|
||||||
self.state.read().await.events_tx.subscribe()
|
self.state.read().await.events_tx.subscribe()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl Fs for InMemoryFs {
|
impl Fs for InMemoryFs {
|
||||||
async fn entry(
|
async fn entry(
|
||||||
@ -350,6 +353,8 @@ impl Fs for InMemoryFs {
|
|||||||
path: &'a Path,
|
path: &'a Path,
|
||||||
abs_path: &'a Path,
|
abs_path: &'a Path,
|
||||||
) -> Result<Pin<Box<dyn 'a + Stream<Item = Result<Entry>> + Send>>> {
|
) -> Result<Pin<Box<dyn 'a + Stream<Item = Result<Entry>> + Send>>> {
|
||||||
|
use futures::{future, stream};
|
||||||
|
|
||||||
let state = self.state.read().await;
|
let state = self.state.read().await;
|
||||||
Ok(stream::iter(state.entries.clone())
|
Ok(stream::iter(state.entries.clone())
|
||||||
.filter(move |(child_path, _)| future::ready(child_path.parent() == Some(abs_path)))
|
.filter(move |(child_path, _)| future::ready(child_path.parent() == Some(abs_path)))
|
||||||
@ -2134,7 +2139,7 @@ impl BackgroundScanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
async fn run_test(mut self, mut events_rx: broadcast::Receiver<fsevent::Event>) {
|
async fn run_test(mut self, mut events_rx: postage::broadcast::Receiver<fsevent::Event>) {
|
||||||
if self.notify.send(ScanState::Scanning).await.is_err() {
|
if self.notify.send(ScanState::Scanning).await.is_err() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user