From b443e5304ec43ae2049c72b694ff62baf4314cbb Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Mon, 5 Apr 2021 21:29:20 +0200 Subject: Remove some unused methods, move some to types.rs --- crates/hir_ty/src/types.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'crates/hir_ty/src/types.rs') diff --git a/crates/hir_ty/src/types.rs b/crates/hir_ty/src/types.rs index 6dffda1ca..4a626d5e7 100644 --- a/crates/hir_ty/src/types.rs +++ b/crates/hir_ty/src/types.rs @@ -360,6 +360,15 @@ impl Binders<&T> { } } +impl Binders { + /// Substitutes all variables. + pub fn substitute(self, interner: &Interner, subst: &Substitution) -> T { + let (value, binders) = self.into_value_and_skipped_binders(); + assert_eq!(subst.len(interner), binders.len(interner)); + value.subst_bound_vars(subst) + } +} + impl std::fmt::Debug for Binders { fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { let Binders { ref binders, ref value } = *self; @@ -375,6 +384,12 @@ pub struct TraitRef { pub substitution: Substitution, } +impl TraitRef { + pub fn self_type_parameter(&self, interner: &Interner) -> &Ty { + &self.substitution.at(interner, 0).assert_ty_ref(interner) + } +} + /// Like `generics::WherePredicate`, but with resolved types: A condition on the /// parameters of a generic item. #[derive(Debug, Clone, PartialEq, Eq, Hash)] -- cgit v1.2.3