Auto merge of #16918 - Veykril:utf8-paths, r=Veykril
fix: Don't assert paths being utf8 when filtering them in the watcher Closes https://github.com/rust-lang/rust-analyzer/issues/16914
This commit is contained in:
commit
5577612fd0
@ -13,7 +13,7 @@
|
|||||||
pub use camino::*;
|
pub use camino::*;
|
||||||
|
|
||||||
/// Wrapper around an absolute [`Utf8PathBuf`].
|
/// Wrapper around an absolute [`Utf8PathBuf`].
|
||||||
#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
|
#[derive(Debug, Clone, Ord, PartialOrd, Eq, Hash)]
|
||||||
pub struct AbsPathBuf(Utf8PathBuf);
|
pub struct AbsPathBuf(Utf8PathBuf);
|
||||||
|
|
||||||
impl From<AbsPathBuf> for Utf8PathBuf {
|
impl From<AbsPathBuf> for Utf8PathBuf {
|
||||||
@ -92,9 +92,9 @@ fn try_from(path: &str) -> Result<AbsPathBuf, Utf8PathBuf> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq<AbsPath> for AbsPathBuf {
|
impl<P: AsRef<Path> + ?Sized> PartialEq<P> for AbsPathBuf {
|
||||||
fn eq(&self, other: &AbsPath) -> bool {
|
fn eq(&self, other: &P) -> bool {
|
||||||
self.as_path() == other
|
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`].
|
/// Wrapper around an absolute [`Utf8Path`].
|
||||||
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
|
#[derive(Debug, Ord, PartialOrd, Eq, Hash)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct AbsPath(Utf8Path);
|
pub struct AbsPath(Utf8Path);
|
||||||
|
|
||||||
|
impl<P: AsRef<Path> + ?Sized> PartialEq<P> for AbsPath {
|
||||||
|
fn eq(&self, other: &P) -> bool {
|
||||||
|
self.0.as_std_path() == other.as_ref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl AsRef<Utf8Path> for AbsPath {
|
impl AsRef<Utf8Path> for AbsPath {
|
||||||
fn as_ref(&self) -> &Utf8Path {
|
fn as_ref(&self) -> &Utf8Path {
|
||||||
&self.0
|
&self.0
|
||||||
|
@ -406,7 +406,7 @@ pub fn packages(&self) -> impl ExactSizeIterator<Item = Package> + '_ {
|
|||||||
pub fn target_by_root(&self, root: &AbsPath) -> Option<Target> {
|
pub fn target_by_root(&self, root: &AbsPath) -> Option<Target> {
|
||||||
self.packages()
|
self.packages()
|
||||||
.filter(|&pkg| self[pkg].is_member)
|
.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()
|
.copied()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
use crossbeam_channel::{never, select, unbounded, Receiver, Sender};
|
use crossbeam_channel::{never, select, unbounded, Receiver, Sender};
|
||||||
use notify::{Config, RecommendedWatcher, RecursiveMode, Watcher};
|
use notify::{Config, RecommendedWatcher, RecursiveMode, Watcher};
|
||||||
use paths::{AbsPath, AbsPathBuf, Utf8Path};
|
use paths::{AbsPath, AbsPathBuf};
|
||||||
use vfs::loader;
|
use vfs::loader;
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ fn load_entry(
|
|||||||
if !entry.file_type().is_dir() {
|
if !entry.file_type().is_dir() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let path = AbsPath::assert(Utf8Path::from_path(entry.path()).unwrap());
|
let path = entry.path();
|
||||||
root == path
|
root == path
|
||||||
|| dirs.exclude.iter().chain(&dirs.include).all(|it| it != path)
|
|| dirs.exclude.iter().chain(&dirs.include).all(|it| it != path)
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user