migrate to salsas interning

This commit is contained in:
Aleksey Kladov 2019-04-09 22:51:22 +03:00
parent 2fc2d4373b
commit 6b993a9760
8 changed files with 109 additions and 111 deletions

View file

@ -9,7 +9,7 @@ use rustc_hash::FxHashMap;
use ra_db::{
CrateGraph, FileId, SourceRoot, SourceRootId, SourceDatabase, salsa,
};
use ra_hir::{db, HirInterner};
use ra_hir::db;
use ra_project_model::ProjectWorkspace;
use ra_vfs::{Vfs, VfsChange};
use vfs_filter::IncludeRustFiles;
@ -20,7 +20,6 @@ type Result<T> = std::result::Result<T, failure::Error>;
#[derive(Debug)]
pub struct BatchDatabase {
runtime: salsa::Runtime<BatchDatabase>,
interner: Arc<HirInterner>,
}
impl salsa::Database for BatchDatabase {
@ -29,12 +28,6 @@ impl salsa::Database for BatchDatabase {
}
}
impl AsRef<HirInterner> for BatchDatabase {
fn as_ref(&self) -> &HirInterner {
&self.interner
}
}
fn vfs_file_to_id(f: ra_vfs::VfsFile) -> FileId {
FileId(f.0.into())
}
@ -44,8 +37,7 @@ fn vfs_root_to_id(r: ra_vfs::VfsRoot) -> SourceRootId {
impl BatchDatabase {
pub fn load(crate_graph: CrateGraph, vfs: &mut Vfs) -> BatchDatabase {
let mut db =
BatchDatabase { runtime: salsa::Runtime::default(), interner: Default::default() };
let mut db = BatchDatabase { runtime: salsa::Runtime::default() };
db.set_crate_graph(Arc::new(crate_graph));
// wait until Vfs has loaded all roots