aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty.rs')
-rw-r--r--crates/ra_hir/src/ty.rs22
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;
17use std::sync::Arc; 17use std::sync::Arc;
18use std::{fmt, iter, mem}; 18use std::{fmt, iter, mem};
19 19
20use hir_def::{generics::GenericParams, AdtId};
21
20use crate::{ 22use 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};
27use display::{HirDisplay, HirFormatter}; 26use 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 }