]> git.lizzy.rs Git - rust.git/commitdiff
Remove more dead code
authorAleksey Kladov <aleksey.kladov@gmail.com>
Sun, 8 Dec 2019 11:58:43 +0000 (12:58 +0100)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Sun, 8 Dec 2019 16:45:14 +0000 (17:45 +0100)
crates/ra_assists/src/test_db.rs
crates/ra_hir/src/debug.rs [deleted file]
crates/ra_hir/src/lib.rs
crates/ra_ide/src/db.rs

index 523259fd46318af0e6cfe2f4f90e08fd76927e87..d5249f3088597a484f04f491bb26f2c66f3ba8af 100644 (file)
@@ -43,5 +43,3 @@ fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> {
         FileLoaderDelegate(self).relevant_crates(file_id)
     }
 }
-
-impl hir::debug::HirDebugHelper for TestDB {}
diff --git a/crates/ra_hir/src/debug.rs b/crates/ra_hir/src/debug.rs
deleted file mode 100644 (file)
index 6cd5c8c..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-//! XXX: This does not work at the moment.
-//!
-//! printf debugging infrastructure for rust-analyzer.
-//!
-//! When you print a hir type, like a module, using `eprintln!("{:?}", module)`,
-//! you usually get back a numeric ID, which doesn't tell you much:
-//! `Module(92)`.
-//!
-//! This module adds convenience `debug` methods to various types, which resolve
-//! the id to a human-readable location info:
-//!
-//! ```not_rust
-//! eprintln!("{:?}", module.debug(db));
-//! =>
-//! Module { name: collections, path: "liballoc/collections/mod.rs" }
-//! ```
-//!
-//! Note that to get this info, we might need to execute queries! So
-//!
-//! * don't use the `debug` methods for logging
-//! * when debugging, be aware that interference is possible.
-
-use std::fmt;
-
-use hir_expand::HirFileId;
-use ra_db::{CrateId, FileId};
-
-use crate::{db::HirDatabase, Crate, Module, Name};
-
-impl Crate {
-    pub fn debug(self, db: &impl HirDebugDatabase) -> impl fmt::Debug + '_ {
-        debug_fn(move |fmt| db.debug_crate(self, fmt))
-    }
-}
-
-impl Module {
-    pub fn debug(self, db: &impl HirDebugDatabase) -> impl fmt::Debug + '_ {
-        debug_fn(move |fmt| db.debug_module(self, fmt))
-    }
-}
-
-pub trait HirDebugHelper: HirDatabase {
-    fn crate_name(&self, _krate: CrateId) -> Option<String> {
-        None
-    }
-    fn file_path(&self, _file_id: FileId) -> Option<String> {
-        None
-    }
-}
-
-pub trait HirDebugDatabase {
-    fn debug_crate(&self, krate: Crate, fmt: &mut fmt::Formatter<'_>) -> fmt::Result;
-    fn debug_module(&self, module: Module, fmt: &mut fmt::Formatter<'_>) -> fmt::Result;
-    fn debug_hir_file_id(&self, file_id: HirFileId, fmt: &mut fmt::Formatter<'_>) -> fmt::Result;
-}
-
-impl<DB: HirDebugHelper> HirDebugDatabase for DB {
-    fn debug_crate(&self, krate: Crate, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
-        let mut builder = fmt.debug_tuple("Crate");
-        match self.crate_name(krate.id) {
-            Some(name) => builder.field(&name),
-            None => builder.field(&krate.id),
-        }
-        .finish()
-    }
-
-    fn debug_module(&self, module: Module, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
-        let file_id = module.definition_source(self).file_id.original_file(self);
-        let path = self.file_path(file_id).unwrap_or_else(|| "N/A".to_string());
-        fmt.debug_struct("Module")
-            .field("name", &module.name(self).unwrap_or_else(Name::missing))
-            .field("path", &path)
-            .finish()
-    }
-
-    fn debug_hir_file_id(&self, file_id: HirFileId, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
-        let original = file_id.original_file(self);
-        let path = self.file_path(original).unwrap_or_else(|| "N/A".to_string());
-        let is_macro = file_id != original.into();
-        fmt.debug_struct("HirFileId").field("path", &path).field("macro", &is_macro).finish()
-    }
-}
-
-fn debug_fn(f: impl Fn(&mut fmt::Formatter<'_>) -> fmt::Result) -> impl fmt::Debug {
-    struct DebugFn<F>(F);
-
-    impl<F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result> fmt::Debug for DebugFn<F> {
-        fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
-            (&self.0)(fmt)
-        }
-    }
-
-    DebugFn(f)
-}
index 946299ba08a64243032443bdaf6e362d79801455..e7602ee305e0660d3384e4a2c4d1549b2c1260a6 100644 (file)
@@ -26,8 +26,6 @@ fn from(it: $sv) -> $e {
     }
 }
 
-pub mod debug;
-
 pub mod db;
 pub mod source_binder;
 
index f739ebecd3b6541a0b28a94000b1f89c0ccb3b22..47d0aed6fb59426733e58241b698769efaa0c518 100644 (file)
@@ -5,7 +5,7 @@
 use ra_db::{
     salsa::{self, Database, Durability},
     Canceled, CheckCanceled, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath,
-    SourceDatabase, SourceDatabaseExt, SourceRootId,
+    SourceDatabase, SourceRootId,
 };
 use rustc_hash::FxHashMap;
 
@@ -49,18 +49,6 @@ fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> {
     }
 }
 
-impl hir::debug::HirDebugHelper for RootDatabase {
-    fn crate_name(&self, krate: CrateId) -> Option<String> {
-        self.debug_data.crate_names.get(&krate).cloned()
-    }
-    fn file_path(&self, file_id: FileId) -> Option<String> {
-        let source_root_id = self.file_source_root(file_id);
-        let source_root_path = self.debug_data.root_paths.get(&source_root_id)?;
-        let file_path = self.file_relative_path(file_id);
-        Some(format!("{}/{}", source_root_path, file_path))
-    }
-}
-
 impl salsa::Database for RootDatabase {
     fn salsa_runtime(&self) -> &salsa::Runtime<RootDatabase> {
         &self.runtime