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/ty.rs | |
parent | 4f8f3393bc3dd9a480319a1b9d66c0778ab30b1e (diff) |
Remove old hir::generics module
Diffstat (limited to 'crates/ra_hir/src/ty.rs')
-rw-r--r-- | crates/ra_hir/src/ty.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index 36ece723f..95b8df181 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -17,12 +17,11 @@ use std::ops::Deref; | |||
17 | use std::sync::Arc; | 17 | use std::sync::Arc; |
18 | use std::{fmt, iter, mem}; | 18 | use std::{fmt, iter, mem}; |
19 | 19 | ||
20 | use hir_def::{generics::GenericParams, AdtId}; | ||
21 | |||
20 | use crate::{ | 22 | use crate::{ |
21 | db::HirDatabase, | 23 | db::HirDatabase, expr::ExprId, util::make_mut_slice, Adt, Crate, DefWithBody, FloatTy, |
22 | expr::ExprId, | 24 | GenericDef, IntTy, Mutability, Name, Trait, TypeAlias, Uncertain, |
23 | generics::{GenericParams, HasGenericParams}, | ||
24 | util::make_mut_slice, | ||
25 | Adt, Crate, DefWithBody, FloatTy, IntTy, Mutability, Name, Trait, TypeAlias, Uncertain, | ||
26 | }; | 25 | }; |
27 | use display::{HirDisplay, HirFormatter}; | 26 | use display::{HirDisplay, HirFormatter}; |
28 | 27 | ||
@@ -131,15 +130,15 @@ impl TypeCtor { | |||
131 | | TypeCtor::Closure { .. } // 1 param representing the signature of the closure | 130 | | TypeCtor::Closure { .. } // 1 param representing the signature of the closure |
132 | => 1, | 131 | => 1, |
133 | TypeCtor::Adt(adt) => { | 132 | TypeCtor::Adt(adt) => { |
134 | let generic_params = adt.generic_params(db); | 133 | let generic_params = db.generic_params(AdtId::from(adt).into()); |
135 | generic_params.count_params_including_parent() | 134 | generic_params.count_params_including_parent() |
136 | } | 135 | } |
137 | TypeCtor::FnDef(callable) => { | 136 | TypeCtor::FnDef(callable) => { |
138 | let generic_params = callable.generic_params(db); | 137 | let generic_params = db.generic_params(callable.into()); |
139 | generic_params.count_params_including_parent() | 138 | generic_params.count_params_including_parent() |
140 | } | 139 | } |
141 | TypeCtor::AssociatedType(type_alias) => { | 140 | TypeCtor::AssociatedType(type_alias) => { |
142 | let generic_params = type_alias.generic_params(db); | 141 | let generic_params = db.generic_params(type_alias.id.into()); |
143 | generic_params.count_params_including_parent() | 142 | generic_params.count_params_including_parent() |
144 | } | 143 | } |
145 | TypeCtor::FnPtr { num_args } => num_args as usize + 1, | 144 | TypeCtor::FnPtr { num_args } => num_args as usize + 1, |
@@ -168,7 +167,7 @@ impl TypeCtor { | |||
168 | } | 167 | } |
169 | } | 168 | } |
170 | 169 | ||
171 | pub fn as_generic_def(self) -> Option<crate::generics::GenericDef> { | 170 | pub fn as_generic_def(self) -> Option<crate::GenericDef> { |
172 | match self { | 171 | match self { |
173 | TypeCtor::Bool | 172 | TypeCtor::Bool |
174 | | TypeCtor::Char | 173 | | TypeCtor::Char |
@@ -348,8 +347,9 @@ impl Substs { | |||
348 | ) | 347 | ) |
349 | } | 348 | } |
350 | 349 | ||
351 | pub fn build_for_def(db: &impl HirDatabase, def: impl HasGenericParams) -> SubstsBuilder { | 350 | pub fn build_for_def(db: &impl HirDatabase, def: impl Into<GenericDef>) -> SubstsBuilder { |
352 | let params = def.generic_params(db); | 351 | let def = def.into(); |
352 | let params = db.generic_params(def.into()); | ||
353 | let param_count = params.count_params_including_parent(); | 353 | let param_count = params.count_params_including_parent(); |
354 | Substs::builder(param_count) | 354 | Substs::builder(param_count) |
355 | } | 355 | } |