diff options
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index e8e3211fc..840cfdfc8 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -989,6 +989,17 @@ impl TypeParam { | |||
989 | ty: InEnvironment { value: ty, environment }, | 989 | ty: InEnvironment { value: ty, environment }, |
990 | } | 990 | } |
991 | } | 991 | } |
992 | |||
993 | pub fn default(self, db: &dyn HirDatabase) -> Option<Type> { | ||
994 | let params = db.generic_defaults(self.id.parent); | ||
995 | let local_idx = hir_ty::param_idx(db, self.id)?; | ||
996 | let resolver = self.id.parent.resolver(db.upcast()); | ||
997 | let environment = TraitEnvironment::lower(db, &resolver); | ||
998 | params.get(local_idx).cloned().map(|ty| Type { | ||
999 | krate: self.id.parent.module(db.upcast()).krate, | ||
1000 | ty: InEnvironment { value: ty, environment }, | ||
1001 | }) | ||
1002 | } | ||
992 | } | 1003 | } |
993 | 1004 | ||
994 | // FIXME: rename from `ImplDef` to `Impl` | 1005 | // FIXME: rename from `ImplDef` to `Impl` |