diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-15 19:11:51 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-15 19:11:51 +0000 |
commit | 1889b3c7b52c1070734dc449d4119c5e5cf991a4 (patch) | |
tree | b92568825de2a5cb2950295d35fac8e3bd9fac15 /crates/ra_hir_def/src/lib.rs | |
parent | 0516a32ed0f8add1a999be579ff9d8966a241f67 (diff) | |
parent | b21829f7edd71fb14911fc6ba47fe715757e415f (diff) |
Merge #2264
2264: move impls to hir-def r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/lib.rs')
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 3fab7965c..0a59c4ad7 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -13,6 +13,7 @@ pub mod path; | |||
13 | pub mod type_ref; | 13 | pub mod type_ref; |
14 | pub mod builtin_type; | 14 | pub mod builtin_type; |
15 | pub mod adt; | 15 | pub mod adt; |
16 | pub mod imp; | ||
16 | pub mod diagnostics; | 17 | pub mod diagnostics; |
17 | pub mod expr; | 18 | pub mod expr; |
18 | pub mod body; | 19 | pub mod body; |
@@ -321,6 +322,18 @@ impl AstItemDef<ast::TypeAliasDef> for TypeAliasId { | |||
321 | } | 322 | } |
322 | } | 323 | } |
323 | 324 | ||
325 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
326 | pub struct ImplId(salsa::InternId); | ||
327 | impl_intern_key!(ImplId); | ||
328 | impl AstItemDef<ast::ImplBlock> for ImplId { | ||
329 | fn intern(db: &impl InternDatabase, loc: ItemLoc<ast::ImplBlock>) -> Self { | ||
330 | db.intern_impl(loc) | ||
331 | } | ||
332 | fn lookup_intern(self, db: &impl InternDatabase) -> ItemLoc<ast::ImplBlock> { | ||
333 | db.lookup_intern_impl(self) | ||
334 | } | ||
335 | } | ||
336 | |||
324 | macro_rules! impl_froms { | 337 | macro_rules! impl_froms { |
325 | ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => { | 338 | ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => { |
326 | $( | 339 | $( |
@@ -384,3 +397,15 @@ pub enum DefWithBodyId { | |||
384 | } | 397 | } |
385 | 398 | ||
386 | impl_froms!(DefWithBodyId: FunctionId, ConstId, StaticId); | 399 | impl_froms!(DefWithBodyId: FunctionId, ConstId, StaticId); |
400 | |||
401 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | ||
402 | pub enum AssocItemId { | ||
403 | FunctionId(FunctionId), | ||
404 | ConstId(ConstId), | ||
405 | TypeAliasId(TypeAliasId), | ||
406 | } | ||
407 | // FIXME: not every function, ... is actually an assoc item. maybe we should make | ||
408 | // sure that you can only turn actual assoc items into AssocItemIds. This would | ||
409 | // require not implementing From, and instead having some checked way of | ||
410 | // casting them, and somehow making the constructors private, which would be annoying. | ||
411 | impl_froms!(AssocItemId: FunctionId, ConstId, TypeAliasId); | ||