aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/code_model.rs4
-rw-r--r--crates/ra_hir_ty/src/lib.rs5
2 files changed, 7 insertions, 2 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 3936f5aaa..cdbf475b3 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -992,8 +992,8 @@ impl TypeParam {
992 992
993 pub fn default(self, db: &dyn HirDatabase) -> Option<Ty> { 993 pub fn default(self, db: &dyn HirDatabase) -> Option<Ty> {
994 let params = db.generic_defaults(self.id.parent); 994 let params = db.generic_defaults(self.id.parent);
995 let local_idx: u32 = self.id.local_id.into_raw().into(); 995 let local_idx = hir_ty::param_idx(db, self.id)?;
996 params.get(local_idx as usize).map(|d| d.clone()) 996 params.get(local_idx).map(|d| d.clone())
997 } 997 }
998} 998}
999 999
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs
index e8f3482fe..ccc4348f4 100644
--- a/crates/ra_hir_ty/src/lib.rs
+++ b/crates/ra_hir_ty/src/lib.rs
@@ -427,6 +427,11 @@ impl Substs {
427 } 427 }
428} 428}
429 429
430/// Return an index of a parameter in the generic type parameter list by it's id.
431pub fn param_idx(db: &dyn HirDatabase, id: TypeParamId) -> Option<usize> {
432 generics(db.upcast(), id.parent).param_idx(id)
433}
434
430#[derive(Debug, Clone)] 435#[derive(Debug, Clone)]
431pub struct SubstsBuilder { 436pub struct SubstsBuilder {
432 vec: Vec<Ty>, 437 vec: Vec<Ty>,