From 54d3e47318930c7a443b1498ff88d365920abe39 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 28 Oct 2019 20:29:57 +0300 Subject: weaken requirements of AstDef --- crates/ra_hir/src/ids.rs | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index 499dcafea..518ea32e9 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs @@ -11,7 +11,7 @@ use ra_prof::profile; use ra_syntax::{ast, AstNode, Parse, SyntaxNode}; use crate::{ - db::{AstDatabase, DefDatabase, InternDatabase}, + db::{AstDatabase, InternDatabase}, AstId, Crate, FileAstId, Module, Source, }; @@ -238,13 +238,13 @@ pub(crate) struct LocationCtx { file_id: HirFileId, } -impl<'a, DB: DefDatabase> LocationCtx<&'a DB> { +impl<'a, DB> LocationCtx<&'a DB> { pub(crate) fn new(db: &'a DB, module: Module, file_id: HirFileId) -> LocationCtx<&'a DB> { LocationCtx { db, module, file_id } } } -impl<'a, DB: DefDatabase + AstDatabase> LocationCtx<&'a DB> { +impl<'a, DB: AstDatabase> LocationCtx<&'a DB> { pub(crate) fn to_def(self, ast: &N) -> DEF where N: AstNode, @@ -255,24 +255,24 @@ impl<'a, DB: DefDatabase + AstDatabase> LocationCtx<&'a DB> { } pub(crate) trait AstItemDef: salsa::InternKey + Clone { - fn intern(db: &impl DefDatabase, loc: ItemLoc) -> Self; - fn lookup_intern(self, db: &impl DefDatabase) -> ItemLoc; + fn intern(db: &impl InternDatabase, loc: ItemLoc) -> Self; + fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc; - fn from_ast(ctx: LocationCtx<&(impl AstDatabase + DefDatabase)>, ast: &N) -> Self { + fn from_ast(ctx: LocationCtx<&impl AstDatabase>, ast: &N) -> Self { let items = ctx.db.ast_id_map(ctx.file_id); let item_id = items.ast_id(ast); Self::from_ast_id(ctx, item_id) } - fn from_ast_id(ctx: LocationCtx<&impl DefDatabase>, ast_id: FileAstId) -> Self { + fn from_ast_id(ctx: LocationCtx<&impl InternDatabase>, ast_id: FileAstId) -> Self { let loc = ItemLoc { module: ctx.module, ast_id: ast_id.with_file_id(ctx.file_id) }; Self::intern(ctx.db, loc) } - fn source(self, db: &(impl AstDatabase + DefDatabase)) -> Source { + fn source(self, db: &impl AstDatabase) -> Source { let loc = self.lookup_intern(db); let ast = loc.ast_id.to_node(db); Source { file_id: loc.ast_id.file_id(), ast } } - fn module(self, db: &impl DefDatabase) -> Module { + fn module(self, db: &impl InternDatabase) -> Module { let loc = self.lookup_intern(db); loc.module } @@ -283,10 +283,10 @@ pub struct FunctionId(salsa::InternId); impl_intern_key!(FunctionId); impl AstItemDef for FunctionId { - fn intern(db: &impl DefDatabase, loc: ItemLoc) -> Self { + fn intern(db: &impl InternDatabase, loc: ItemLoc) -> Self { db.intern_function(loc) } - fn lookup_intern(self, db: &impl DefDatabase) -> ItemLoc { + fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc { db.lookup_intern_function(self) } } @@ -295,10 +295,10 @@ impl AstItemDef for FunctionId { pub struct StructId(salsa::InternId); impl_intern_key!(StructId); impl AstItemDef for StructId { - fn intern(db: &impl DefDatabase, loc: ItemLoc) -> Self { + fn intern(db: &impl InternDatabase, loc: ItemLoc) -> Self { db.intern_struct(loc) } - fn lookup_intern(self, db: &impl DefDatabase) -> ItemLoc { + fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc { db.lookup_intern_struct(self) } } @@ -307,10 +307,10 @@ impl AstItemDef for StructId { pub struct EnumId(salsa::InternId); impl_intern_key!(EnumId); impl AstItemDef for EnumId { - fn intern(db: &impl DefDatabase, loc: ItemLoc) -> Self { + fn intern(db: &impl InternDatabase, loc: ItemLoc) -> Self { db.intern_enum(loc) } - fn lookup_intern(self, db: &impl DefDatabase) -> ItemLoc { + fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc { db.lookup_intern_enum(self) } } @@ -319,10 +319,10 @@ impl AstItemDef for EnumId { pub struct ConstId(salsa::InternId); impl_intern_key!(ConstId); impl AstItemDef for ConstId { - fn intern(db: &impl DefDatabase, loc: ItemLoc) -> Self { + fn intern(db: &impl InternDatabase, loc: ItemLoc) -> Self { db.intern_const(loc) } - fn lookup_intern(self, db: &impl DefDatabase) -> ItemLoc { + fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc { db.lookup_intern_const(self) } } @@ -331,10 +331,10 @@ impl AstItemDef for ConstId { pub struct StaticId(salsa::InternId); impl_intern_key!(StaticId); impl AstItemDef for StaticId { - fn intern(db: &impl DefDatabase, loc: ItemLoc) -> Self { + fn intern(db: &impl InternDatabase, loc: ItemLoc) -> Self { db.intern_static(loc) } - fn lookup_intern(self, db: &impl DefDatabase) -> ItemLoc { + fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc { db.lookup_intern_static(self) } } @@ -343,10 +343,10 @@ impl AstItemDef for StaticId { pub struct TraitId(salsa::InternId); impl_intern_key!(TraitId); impl AstItemDef for TraitId { - fn intern(db: &impl DefDatabase, loc: ItemLoc) -> Self { + fn intern(db: &impl InternDatabase, loc: ItemLoc) -> Self { db.intern_trait(loc) } - fn lookup_intern(self, db: &impl DefDatabase) -> ItemLoc { + fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc { db.lookup_intern_trait(self) } } @@ -355,10 +355,10 @@ impl AstItemDef for TraitId { pub struct TypeAliasId(salsa::InternId); impl_intern_key!(TypeAliasId); impl AstItemDef for TypeAliasId { - fn intern(db: &impl DefDatabase, loc: ItemLoc) -> Self { + fn intern(db: &impl InternDatabase, loc: ItemLoc) -> Self { db.intern_type_alias(loc) } - fn lookup_intern(self, db: &impl DefDatabase) -> ItemLoc { + fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc { db.lookup_intern_type_alias(self) } } -- cgit v1.2.3