diff options
author | Aleksey Kladov <[email protected]> | 2019-11-20 09:25:02 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-20 09:34:48 +0000 |
commit | e1a6e38767c1e47e5e88a97a9ef5b4547390803c (patch) | |
tree | be32707506b562828759e3c9dc72414796a817ca /crates/ra_hir_def/src/lib.rs | |
parent | 0e771915faf057ec4561224b75ec9b5be93d71c8 (diff) |
Move Generics to hir_def
Diffstat (limited to 'crates/ra_hir_def/src/lib.rs')
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 50caf4f83..dffc82ff8 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -17,6 +17,7 @@ pub mod imp; | |||
17 | pub mod diagnostics; | 17 | pub mod diagnostics; |
18 | pub mod expr; | 18 | pub mod expr; |
19 | pub mod body; | 19 | pub mod body; |
20 | pub mod generics; | ||
20 | 21 | ||
21 | #[cfg(test)] | 22 | #[cfg(test)] |
22 | mod test_db; | 23 | mod test_db; |
@@ -408,3 +409,26 @@ pub enum AssocItemId { | |||
408 | // require not implementing From, and instead having some checked way of | 409 | // require not implementing From, and instead having some checked way of |
409 | // casting them, and somehow making the constructors private, which would be annoying. | 410 | // casting them, and somehow making the constructors private, which would be annoying. |
410 | impl_froms!(AssocItemId: FunctionId, ConstId, TypeAliasId); | 411 | impl_froms!(AssocItemId: FunctionId, ConstId, TypeAliasId); |
412 | |||
413 | #[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] | ||
414 | pub enum GenericDefId { | ||
415 | FunctionId(FunctionId), | ||
416 | AdtId(AdtId), | ||
417 | TraitId(TraitId), | ||
418 | TypeAliasId(TypeAliasId), | ||
419 | ImplId(ImplId), | ||
420 | // enum variants cannot have generics themselves, but their parent enums | ||
421 | // can, and this makes some code easier to write | ||
422 | EnumVariantId(EnumVariantId), | ||
423 | // consts can have type parameters from their parents (i.e. associated consts of traits) | ||
424 | ConstId(ConstId), | ||
425 | } | ||
426 | impl_froms!( | ||
427 | GenericDefId: FunctionId, | ||
428 | AdtId(StructId, EnumId, UnionId), | ||
429 | TraitId, | ||
430 | TypeAliasId, | ||
431 | ImplId, | ||
432 | EnumVariantId, | ||
433 | ConstId | ||
434 | ); | ||