aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/lib.rs')
-rw-r--r--crates/hir_ty/src/lib.rs28
1 files changed, 2 insertions, 26 deletions
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index ebdcc4804..6d6443ca3 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -41,7 +41,7 @@ use hir_def::{
41use crate::{ 41use crate::{
42 db::HirDatabase, 42 db::HirDatabase,
43 display::HirDisplay, 43 display::HirDisplay,
44 utils::{generics, make_mut_slice, Generics}, 44 utils::{generics, make_mut_slice},
45}; 45};
46 46
47pub use autoderef::autoderef; 47pub use autoderef::autoderef;
@@ -464,33 +464,9 @@ impl Substitution {
464 } 464 }
465 465
466 /// Return Substs that replace each parameter by itself (i.e. `Ty::Param`). 466 /// Return Substs that replace each parameter by itself (i.e. `Ty::Param`).
467 pub(crate) fn type_params_for_generics(
468 db: &dyn HirDatabase,
469 generic_params: &Generics,
470 ) -> Substitution {
471 Substitution::from_iter(
472 &Interner,
473 generic_params
474 .iter()
475 .map(|(id, _)| TyKind::Placeholder(to_placeholder_idx(db, id)).intern(&Interner)),
476 )
477 }
478
479 /// Return Substs that replace each parameter by itself (i.e. `Ty::Param`).
480 pub fn type_params(db: &dyn HirDatabase, def: impl Into<GenericDefId>) -> Substitution { 467 pub fn type_params(db: &dyn HirDatabase, def: impl Into<GenericDefId>) -> Substitution {
481 let params = generics(db.upcast(), def.into()); 468 let params = generics(db.upcast(), def.into());
482 Substitution::type_params_for_generics(db, &params) 469 params.type_params_subst(db)
483 }
484
485 /// Return Substs that replace each parameter by a bound variable.
486 pub(crate) fn bound_vars(generic_params: &Generics, debruijn: DebruijnIndex) -> Substitution {
487 Substitution::from_iter(
488 &Interner,
489 generic_params
490 .iter()
491 .enumerate()
492 .map(|(idx, _)| TyKind::BoundVar(BoundVar::new(debruijn, idx)).intern(&Interner)),
493 )
494 } 470 }
495} 471}
496 472