From 30a339e038bfd94d8c91f79287be9b7db4f0cb4e Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Mon, 5 Apr 2021 18:49:26 +0200 Subject: Add Interner parameter to Binders::substitute --- crates/hir/src/display.rs | 4 +++- crates/hir/src/lib.rs | 6 +++--- crates/hir/src/source_analyzer.rs | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'crates/hir') diff --git a/crates/hir/src/display.rs b/crates/hir/src/display.rs index d4e477a85..01a4d205f 100644 --- a/crates/hir/src/display.rs +++ b/crates/hir/src/display.rs @@ -9,6 +9,7 @@ use hir_ty::display::{ write_bounds_like_dyn_trait_with_prefix, write_visibility, HirDisplay, HirDisplayError, HirFormatter, }; +use hir_ty::Interner; use syntax::ast::{self, NameOwner}; use crate::{ @@ -235,7 +236,8 @@ impl HirDisplay for TypeParam { write!(f, "{}", self.name(f.db))?; let bounds = f.db.generic_predicates_for_param(self.id); let substs = TyBuilder::type_params_subst(f.db, self.id.parent); - let predicates = bounds.iter().cloned().map(|b| b.substitute(&substs)).collect::>(); + let predicates = + bounds.iter().cloned().map(|b| b.substitute(&Interner, &substs)).collect::>(); if !(predicates.is_empty() || f.omit_verbose_types()) { write_bounds_like_dyn_trait_with_prefix(":", &predicates, f)?; } diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index add1b55c2..003821981 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -516,7 +516,7 @@ impl Field { VariantDef::Variant(it) => it.parent.id.into(), }; let substs = TyBuilder::type_params_subst(db, generic_def_id); - let ty = db.field_types(var_id)[self.id].clone().substitute(&substs); + let ty = db.field_types(var_id)[self.id].clone().substitute(&Interner, &substs); Type::new(db, self.parent.module(db).id.krate(), var_id, ty) } @@ -1503,7 +1503,7 @@ impl TypeParam { let krate = self.id.parent.module(db.upcast()).krate(); let ty = params.get(local_idx)?.clone(); let subst = TyBuilder::type_params_subst(db, self.id.parent); - let ty = ty.substitute(&subst.prefix(local_idx)); + let ty = ty.substitute(&Interner, &subst.prefix(local_idx)); Some(Type::new_with_resolver_inner(db, krate, &resolver, ty)) } } @@ -1916,7 +1916,7 @@ impl Type { .iter() .map(|(local_id, ty)| { let def = Field { parent: variant_id.into(), id: local_id }; - let ty = ty.clone().substitute(substs); + let ty = ty.clone().substitute(&Interner, substs); (def, self.derived(ty)) }) .collect() diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs index 82807ea09..4ce1c2080 100644 --- a/crates/hir/src/source_analyzer.rs +++ b/crates/hir/src/source_analyzer.rs @@ -20,7 +20,7 @@ use hir_def::{ use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile}; use hir_ty::{ diagnostics::{record_literal_missing_fields, record_pattern_missing_fields}, - InferenceResult, Substitution, TyLoweringContext, + InferenceResult, Interner, Substitution, TyLoweringContext, }; use syntax::{ ast::{self, AstNode}, @@ -339,7 +339,7 @@ impl SourceAnalyzer { .into_iter() .map(|local_id| { let field = FieldId { parent: variant, local_id }; - let ty = field_types[local_id].clone().substitute(substs); + let ty = field_types[local_id].clone().substitute(&Interner, substs); (field.into(), Type::new_with_resolver_inner(db, krate, &self.resolver, ty)) }) .collect() -- cgit v1.2.3