diff options
author | Aleksey Kladov <[email protected]> | 2019-11-24 12:20:59 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-24 12:20:59 +0000 |
commit | 151180057b0304ee4dee75401e8f1aaa7aaaec21 (patch) | |
tree | f61f810aa5f0c9cda0f07bd15d8f03b2d3b5ee83 /crates/ra_hir_def | |
parent | e0b06cb672b7aae770fea24e4a5efdbec8cbf5c6 (diff) |
Simplify
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 15 |
1 files changed, 0 insertions, 15 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 89f1ceb58..f60feb5fa 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -94,25 +94,10 @@ impl<'a, DB> LocationCtx<&'a DB> { | |||
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | impl<'a, DB: AstDatabase + InternDatabase> LocationCtx<&'a DB> { | ||
98 | pub fn to_def<N, DEF>(self, ast: &N) -> DEF | ||
99 | where | ||
100 | N: AstNode, | ||
101 | DEF: AstItemDef<N>, | ||
102 | { | ||
103 | DEF::from_ast(self, ast) | ||
104 | } | ||
105 | } | ||
106 | |||
107 | pub trait AstItemDef<N: AstNode>: salsa::InternKey + Clone { | 97 | pub trait AstItemDef<N: AstNode>: salsa::InternKey + Clone { |
108 | fn intern(db: &impl InternDatabase, loc: ItemLoc<N>) -> Self; | 98 | fn intern(db: &impl InternDatabase, loc: ItemLoc<N>) -> Self; |
109 | fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc<N>; | 99 | fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc<N>; |
110 | 100 | ||
111 | fn from_ast(ctx: LocationCtx<&(impl AstDatabase + InternDatabase)>, ast: &N) -> Self { | ||
112 | let items = ctx.db.ast_id_map(ctx.file_id); | ||
113 | let item_id = items.ast_id(ast); | ||
114 | Self::from_ast_id(ctx, item_id) | ||
115 | } | ||
116 | fn from_ast_id(ctx: LocationCtx<&impl InternDatabase>, ast_id: FileAstId<N>) -> Self { | 101 | fn from_ast_id(ctx: LocationCtx<&impl InternDatabase>, ast_id: FileAstId<N>) -> Self { |
117 | let loc = ItemLoc { module: ctx.module, ast_id: AstId::new(ctx.file_id, ast_id) }; | 102 | let loc = ItemLoc { module: ctx.module, ast_id: AstId::new(ctx.file_id, ast_id) }; |
118 | Self::intern(ctx.db, loc) | 103 | Self::intern(ctx.db, loc) |