diff --git a/crates/paths/src/lib.rs b/crates/paths/src/lib.rs index 3ffe4e11e96..2d3653401d2 100644 --- a/crates/paths/src/lib.rs +++ b/crates/paths/src/lib.rs @@ -13,7 +13,7 @@ pub use camino::*; /// Wrapper around an absolute [`Utf8PathBuf`]. -#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] +#[derive(Debug, Clone, Ord, PartialOrd, Eq, Hash)] pub struct AbsPathBuf(Utf8PathBuf); impl From for Utf8PathBuf { @@ -92,9 +92,9 @@ fn try_from(path: &str) -> Result { } } -impl PartialEq for AbsPathBuf { - fn eq(&self, other: &AbsPath) -> bool { - self.as_path() == other +impl + ?Sized> PartialEq

for AbsPathBuf { + fn eq(&self, other: &P) -> bool { + self.0.as_std_path() == other.as_ref() } } @@ -144,10 +144,16 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } /// Wrapper around an absolute [`Utf8Path`]. -#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Hash)] +#[derive(Debug, Ord, PartialOrd, Eq, Hash)] #[repr(transparent)] pub struct AbsPath(Utf8Path); +impl + ?Sized> PartialEq

for AbsPath { + fn eq(&self, other: &P) -> bool { + self.0.as_std_path() == other.as_ref() + } +} + impl AsRef for AbsPath { fn as_ref(&self) -> &Utf8Path { &self.0 diff --git a/crates/project-model/src/cargo_workspace.rs b/crates/project-model/src/cargo_workspace.rs index 957366b6104..51c1b094f7b 100644 --- a/crates/project-model/src/cargo_workspace.rs +++ b/crates/project-model/src/cargo_workspace.rs @@ -406,7 +406,7 @@ pub fn packages(&self) -> impl ExactSizeIterator + '_ { pub fn target_by_root(&self, root: &AbsPath) -> Option { self.packages() .filter(|&pkg| self[pkg].is_member) - .find_map(|pkg| self[pkg].targets.iter().find(|&&it| &self[it].root == root)) + .find_map(|pkg| self[pkg].targets.iter().find(|&&it| self[it].root == root)) .copied() } diff --git a/crates/vfs-notify/src/lib.rs b/crates/vfs-notify/src/lib.rs index 1f25b0e5346..4cfdec2b5c5 100644 --- a/crates/vfs-notify/src/lib.rs +++ b/crates/vfs-notify/src/lib.rs @@ -13,7 +13,7 @@ use crossbeam_channel::{never, select, unbounded, Receiver, Sender}; use notify::{Config, RecommendedWatcher, RecursiveMode, Watcher}; -use paths::{AbsPath, AbsPathBuf, Utf8Path}; +use paths::{AbsPath, AbsPathBuf}; use vfs::loader; use walkdir::WalkDir; @@ -205,7 +205,7 @@ fn load_entry( if !entry.file_type().is_dir() { return true; } - let path = AbsPath::assert(Utf8Path::from_path(entry.path()).unwrap()); + let path = entry.path(); root == path || dirs.exclude.iter().chain(&dirs.include).all(|it| it != path) });