diff options
Diffstat (limited to 'crates/ra_hir/src/ids.rs')
-rw-r--r-- | crates/ra_hir/src/ids.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index 033af1632..b7215ac03 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs | |||
@@ -9,7 +9,7 @@ use ra_prof::profile; | |||
9 | use mbe::MacroRules; | 9 | use mbe::MacroRules; |
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{ |
12 | Module, DefDatabase, AstId, FileAstId, AstDatabase, Source, | 12 | Module, DefDatabase, AstId, FileAstId, AstDatabase, Source, InternDatabase, |
13 | }; | 13 | }; |
14 | 14 | ||
15 | /// hir makes heavy use of ids: integer (u32) handlers to various things. You | 15 | /// hir makes heavy use of ids: integer (u32) handlers to various things. You |
@@ -37,7 +37,7 @@ pub struct HirFileId(HirFileIdRepr); | |||
37 | impl HirFileId { | 37 | impl HirFileId { |
38 | /// For macro-expansion files, returns the file original source file the | 38 | /// For macro-expansion files, returns the file original source file the |
39 | /// expansion originated from. | 39 | /// expansion originated from. |
40 | pub fn original_file(self, db: &impl AstDatabase) -> FileId { | 40 | pub fn original_file(self, db: &impl InternDatabase) -> FileId { |
41 | match self.0 { | 41 | match self.0 { |
42 | HirFileIdRepr::File(file_id) => file_id, | 42 | HirFileIdRepr::File(file_id) => file_id, |
43 | HirFileIdRepr::Macro(macro_file) => { | 43 | HirFileIdRepr::Macro(macro_file) => { |
@@ -187,7 +187,7 @@ pub struct MacroCallLoc { | |||
187 | } | 187 | } |
188 | 188 | ||
189 | impl MacroCallId { | 189 | impl MacroCallId { |
190 | pub(crate) fn loc(self, db: &impl AstDatabase) -> MacroCallLoc { | 190 | pub(crate) fn loc(self, db: &impl InternDatabase) -> MacroCallLoc { |
191 | db.lookup_intern_macro(self) | 191 | db.lookup_intern_macro(self) |
192 | } | 192 | } |
193 | 193 | ||
@@ -198,7 +198,7 @@ impl MacroCallId { | |||
198 | } | 198 | } |
199 | 199 | ||
200 | impl MacroCallLoc { | 200 | impl MacroCallLoc { |
201 | pub(crate) fn id(self, db: &impl AstDatabase) -> MacroCallId { | 201 | pub(crate) fn id(self, db: &impl InternDatabase) -> MacroCallId { |
202 | db.intern_macro(self) | 202 | db.intern_macro(self) |
203 | } | 203 | } |
204 | } | 204 | } |
@@ -235,10 +235,13 @@ pub(crate) struct LocationCtx<DB> { | |||
235 | file_id: HirFileId, | 235 | file_id: HirFileId, |
236 | } | 236 | } |
237 | 237 | ||
238 | impl<'a, DB: DefDatabase + AstDatabase> LocationCtx<&'a DB> { | 238 | impl<'a, DB: DefDatabase> LocationCtx<&'a DB> { |
239 | pub(crate) fn new(db: &'a DB, module: Module, file_id: HirFileId) -> LocationCtx<&'a DB> { | 239 | pub(crate) fn new(db: &'a DB, module: Module, file_id: HirFileId) -> LocationCtx<&'a DB> { |
240 | LocationCtx { db, module, file_id } | 240 | LocationCtx { db, module, file_id } |
241 | } | 241 | } |
242 | } | ||
243 | |||
244 | impl<'a, DB: DefDatabase + AstDatabase> LocationCtx<&'a DB> { | ||
242 | pub(crate) fn to_def<N, DEF>(self, ast: &N) -> DEF | 245 | pub(crate) fn to_def<N, DEF>(self, ast: &N) -> DEF |
243 | where | 246 | where |
244 | N: AstNode, | 247 | N: AstNode, |
@@ -257,10 +260,7 @@ pub(crate) trait AstItemDef<N: AstNode>: salsa::InternKey + Clone { | |||
257 | let item_id = items.ast_id(ast); | 260 | let item_id = items.ast_id(ast); |
258 | Self::from_ast_id(ctx, item_id) | 261 | Self::from_ast_id(ctx, item_id) |
259 | } | 262 | } |
260 | fn from_ast_id( | 263 | fn from_ast_id(ctx: LocationCtx<&impl DefDatabase>, ast_id: FileAstId<N>) -> Self { |
261 | ctx: LocationCtx<&(impl AstDatabase + DefDatabase)>, | ||
262 | ast_id: FileAstId<N>, | ||
263 | ) -> Self { | ||
264 | let loc = ItemLoc { module: ctx.module, ast_id: ast_id.with_file_id(ctx.file_id) }; | 264 | let loc = ItemLoc { module: ctx.module, ast_id: ast_id.with_file_id(ctx.file_id) }; |
265 | Self::intern(ctx.db, loc) | 265 | Self::intern(ctx.db, loc) |
266 | } | 266 | } |