From 7503c5528f20f7404bac6f70bcf2120edb54dc52 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 15 Oct 2018 21:54:12 +0300 Subject: fix tests --- crates/ra_analysis/src/db/mod.rs | 11 +---------- crates/ra_analysis/src/imp.rs | 19 +++++++++++++++++++ crates/ra_analysis/src/roots.rs | 1 - crates/ra_analysis/tests/tests.rs | 2 +- 4 files changed, 21 insertions(+), 12 deletions(-) (limited to 'crates') diff --git a/crates/ra_analysis/src/db/mod.rs b/crates/ra_analysis/src/db/mod.rs index c84bfa7a8..081510daa 100644 --- a/crates/ra_analysis/src/db/mod.rs +++ b/crates/ra_analysis/src/db/mod.rs @@ -61,21 +61,12 @@ salsa::query_group! { } } -#[derive(Default, Debug)] +#[derive(Default, Debug, PartialEq, Eq)] pub(crate) struct FileSet { pub(crate) files: FxHashSet, pub(crate) resolver: FileResolverImp, } -impl PartialEq for FileSet { - fn eq(&self, other: &FileSet) -> bool { - self.files == other.files - } -} - -impl Eq for FileSet { -} - impl Hash for FileSet { fn hash(&self, hasher: &mut H) { let mut files = self.files.iter().cloned().collect::>(); diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 26f5e175b..6e6c022d9 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -3,6 +3,7 @@ use std::{ Arc, atomic::{AtomicBool, Ordering::SeqCst}, }, + hash::{Hash, Hasher}, fmt, collections::VecDeque, iter, @@ -29,6 +30,21 @@ pub(crate) struct FileResolverImp { inner: Arc } +impl PartialEq for FileResolverImp { + fn eq(&self, other: &FileResolverImp) -> bool { + self.inner() == other.inner() + } +} + +impl Eq for FileResolverImp { +} + +impl Hash for FileResolverImp { + fn hash(&self, hasher: &mut H) { + self.inner().hash(hasher); + } +} + impl FileResolverImp { pub(crate) fn new(inner: Arc) -> FileResolverImp { FileResolverImp { inner } @@ -39,6 +55,9 @@ impl FileResolverImp { pub(crate) fn resolve(&self, file_id: FileId, path: &RelativePath) -> Option { self.inner.resolve(file_id, path) } + fn inner(&self) -> *const FileResolver { + &*self.inner + } } impl Default for FileResolverImp { diff --git a/crates/ra_analysis/src/roots.rs b/crates/ra_analysis/src/roots.rs index 692a07ccd..766548c70 100644 --- a/crates/ra_analysis/src/roots.rs +++ b/crates/ra_analysis/src/roots.rs @@ -78,7 +78,6 @@ impl SourceRoot for WritableSourceRoot { fn contains(&self, file_id: FileId) -> bool { let db = self.db.read(); let files = &db.file_set(()).files; - eprintln!("files = {:?}", files); files.contains(&file_id) } fn lines(&self, file_id: FileId) -> Arc { diff --git a/crates/ra_analysis/tests/tests.rs b/crates/ra_analysis/tests/tests.rs index 755640fb4..2d3679fa9 100644 --- a/crates/ra_analysis/tests/tests.rs +++ b/crates/ra_analysis/tests/tests.rs @@ -238,4 +238,4 @@ fn bar() { assert_eq!(desc.params, vec!["&self".to_string(), "x".to_string()]); assert_eq!(desc.ret_type, None); assert_eq!(param, Some(1)); -} \ No newline at end of file +} -- cgit v1.2.3