diff options
author | Aleksey Kladov <[email protected]> | 2019-11-21 13:23:02 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-21 13:23:02 +0000 |
commit | 4daf931111029cee9bb43691f88c32f0aa47a802 (patch) | |
tree | 65c477fc2d09c912a05072db40c99187c7d8ec0d /crates/ra_hir/src/code_model.rs | |
parent | 4f8f3393bc3dd9a480319a1b9d66c0778ab30b1e (diff) |
Remove old hir::generics module
Diffstat (limited to 'crates/ra_hir/src/code_model.rs')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 92860fb59..5690040a7 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -27,7 +27,6 @@ use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner}; | |||
27 | use crate::{ | 27 | use crate::{ |
28 | db::{AstDatabase, DefDatabase, HirDatabase}, | 28 | db::{AstDatabase, DefDatabase, HirDatabase}, |
29 | expr::{BindingAnnotation, Body, BodySourceMap, ExprValidator, Pat, PatId}, | 29 | expr::{BindingAnnotation, Body, BodySourceMap, ExprValidator, Pat, PatId}, |
30 | generics::{GenericDef, HasGenericParams}, | ||
31 | ids::{ | 30 | ids::{ |
32 | AstItemDef, ConstId, EnumId, FunctionId, MacroDefId, StaticId, StructId, TraitId, | 31 | AstItemDef, ConstId, EnumId, FunctionId, MacroDefId, StaticId, StructId, TraitId, |
33 | TypeAliasId, | 32 | TypeAliasId, |
@@ -835,7 +834,7 @@ impl Trait { | |||
835 | // lifetime problems, but since there usually shouldn't be more than a | 834 | // lifetime problems, but since there usually shouldn't be more than a |
836 | // few direct traits this should be fine (we could even use some kind of | 835 | // few direct traits this should be fine (we could even use some kind of |
837 | // SmallVec if performance is a concern) | 836 | // SmallVec if performance is a concern) |
838 | self.generic_params(db) | 837 | db.generic_params(self.id.into()) |
839 | .where_predicates | 838 | .where_predicates |
840 | .iter() | 839 | .iter() |
841 | .filter_map(|pred| match &pred.type_ref { | 840 | .filter_map(|pred| match &pred.type_ref { |
@@ -975,16 +974,6 @@ pub enum AssocItem { | |||
975 | // casting them, and somehow making the constructors private, which would be annoying. | 974 | // casting them, and somehow making the constructors private, which would be annoying. |
976 | impl_froms!(AssocItem: Function, Const, TypeAlias); | 975 | impl_froms!(AssocItem: Function, Const, TypeAlias); |
977 | 976 | ||
978 | impl From<AssocItem> for crate::generics::GenericDef { | ||
979 | fn from(item: AssocItem) -> Self { | ||
980 | match item { | ||
981 | AssocItem::Function(f) => f.into(), | ||
982 | AssocItem::Const(c) => c.into(), | ||
983 | AssocItem::TypeAlias(t) => t.into(), | ||
984 | } | ||
985 | } | ||
986 | } | ||
987 | |||
988 | impl AssocItem { | 977 | impl AssocItem { |
989 | pub fn module(self, db: &impl DefDatabase) -> Module { | 978 | pub fn module(self, db: &impl DefDatabase) -> Module { |
990 | match self { | 979 | match self { |
@@ -1004,6 +993,39 @@ impl AssocItem { | |||
1004 | } | 993 | } |
1005 | } | 994 | } |
1006 | 995 | ||
996 | #[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] | ||
997 | pub enum GenericDef { | ||
998 | Function(Function), | ||
999 | Adt(Adt), | ||
1000 | Trait(Trait), | ||
1001 | TypeAlias(TypeAlias), | ||
1002 | ImplBlock(ImplBlock), | ||
1003 | // enum variants cannot have generics themselves, but their parent enums | ||
1004 | // can, and this makes some code easier to write | ||
1005 | EnumVariant(EnumVariant), | ||
1006 | // consts can have type parameters from their parents (i.e. associated consts of traits) | ||
1007 | Const(Const), | ||
1008 | } | ||
1009 | impl_froms!( | ||
1010 | GenericDef: Function, | ||
1011 | Adt(Struct, Enum, Union), | ||
1012 | Trait, | ||
1013 | TypeAlias, | ||
1014 | ImplBlock, | ||
1015 | EnumVariant, | ||
1016 | Const | ||
1017 | ); | ||
1018 | |||
1019 | impl From<AssocItem> for GenericDef { | ||
1020 | fn from(item: AssocItem) -> Self { | ||
1021 | match item { | ||
1022 | AssocItem::Function(f) => f.into(), | ||
1023 | AssocItem::Const(c) => c.into(), | ||
1024 | AssocItem::TypeAlias(t) => t.into(), | ||
1025 | } | ||
1026 | } | ||
1027 | } | ||
1028 | |||
1007 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | 1029 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
1008 | pub struct Local { | 1030 | pub struct Local { |
1009 | pub(crate) parent: DefWithBody, | 1031 | pub(crate) parent: DefWithBody, |