aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-04-05 17:49:26 +0100
committerFlorian Diebold <[email protected]>2021-04-05 18:21:01 +0100
commit30a339e038bfd94d8c91f79287be9b7db4f0cb4e (patch)
tree7e026ded541b94f2908d61a8037ed62f2df91625 /crates/hir
parent05eba0db3dd76f016aabdd49af6211e70a1812ed (diff)
Add Interner parameter to Binders::substitute
Diffstat (limited to 'crates/hir')
-rw-r--r--crates/hir/src/display.rs4
-rw-r--r--crates/hir/src/lib.rs6
-rw-r--r--crates/hir/src/source_analyzer.rs4
3 files changed, 8 insertions, 6 deletions
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::{
9 write_bounds_like_dyn_trait_with_prefix, write_visibility, HirDisplay, HirDisplayError, 9 write_bounds_like_dyn_trait_with_prefix, write_visibility, HirDisplay, HirDisplayError,
10 HirFormatter, 10 HirFormatter,
11}; 11};
12use hir_ty::Interner;
12use syntax::ast::{self, NameOwner}; 13use syntax::ast::{self, NameOwner};
13 14
14use crate::{ 15use crate::{
@@ -235,7 +236,8 @@ impl HirDisplay for TypeParam {
235 write!(f, "{}", self.name(f.db))?; 236 write!(f, "{}", self.name(f.db))?;
236 let bounds = f.db.generic_predicates_for_param(self.id); 237 let bounds = f.db.generic_predicates_for_param(self.id);
237 let substs = TyBuilder::type_params_subst(f.db, self.id.parent); 238 let substs = TyBuilder::type_params_subst(f.db, self.id.parent);
238 let predicates = bounds.iter().cloned().map(|b| b.substitute(&substs)).collect::<Vec<_>>(); 239 let predicates =
240 bounds.iter().cloned().map(|b| b.substitute(&Interner, &substs)).collect::<Vec<_>>();
239 if !(predicates.is_empty() || f.omit_verbose_types()) { 241 if !(predicates.is_empty() || f.omit_verbose_types()) {
240 write_bounds_like_dyn_trait_with_prefix(":", &predicates, f)?; 242 write_bounds_like_dyn_trait_with_prefix(":", &predicates, f)?;
241 } 243 }
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 {
516 VariantDef::Variant(it) => it.parent.id.into(), 516 VariantDef::Variant(it) => it.parent.id.into(),
517 }; 517 };
518 let substs = TyBuilder::type_params_subst(db, generic_def_id); 518 let substs = TyBuilder::type_params_subst(db, generic_def_id);
519 let ty = db.field_types(var_id)[self.id].clone().substitute(&substs); 519 let ty = db.field_types(var_id)[self.id].clone().substitute(&Interner, &substs);
520 Type::new(db, self.parent.module(db).id.krate(), var_id, ty) 520 Type::new(db, self.parent.module(db).id.krate(), var_id, ty)
521 } 521 }
522 522
@@ -1503,7 +1503,7 @@ impl TypeParam {
1503 let krate = self.id.parent.module(db.upcast()).krate(); 1503 let krate = self.id.parent.module(db.upcast()).krate();
1504 let ty = params.get(local_idx)?.clone(); 1504 let ty = params.get(local_idx)?.clone();
1505 let subst = TyBuilder::type_params_subst(db, self.id.parent); 1505 let subst = TyBuilder::type_params_subst(db, self.id.parent);
1506 let ty = ty.substitute(&subst.prefix(local_idx)); 1506 let ty = ty.substitute(&Interner, &subst.prefix(local_idx));
1507 Some(Type::new_with_resolver_inner(db, krate, &resolver, ty)) 1507 Some(Type::new_with_resolver_inner(db, krate, &resolver, ty))
1508 } 1508 }
1509} 1509}
@@ -1916,7 +1916,7 @@ impl Type {
1916 .iter() 1916 .iter()
1917 .map(|(local_id, ty)| { 1917 .map(|(local_id, ty)| {
1918 let def = Field { parent: variant_id.into(), id: local_id }; 1918 let def = Field { parent: variant_id.into(), id: local_id };
1919 let ty = ty.clone().substitute(substs); 1919 let ty = ty.clone().substitute(&Interner, substs);
1920 (def, self.derived(ty)) 1920 (def, self.derived(ty))
1921 }) 1921 })
1922 .collect() 1922 .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::{
20use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile}; 20use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile};
21use hir_ty::{ 21use hir_ty::{
22 diagnostics::{record_literal_missing_fields, record_pattern_missing_fields}, 22 diagnostics::{record_literal_missing_fields, record_pattern_missing_fields},
23 InferenceResult, Substitution, TyLoweringContext, 23 InferenceResult, Interner, Substitution, TyLoweringContext,
24}; 24};
25use syntax::{ 25use syntax::{
26 ast::{self, AstNode}, 26 ast::{self, AstNode},
@@ -339,7 +339,7 @@ impl SourceAnalyzer {
339 .into_iter() 339 .into_iter()
340 .map(|local_id| { 340 .map(|local_id| {
341 let field = FieldId { parent: variant, local_id }; 341 let field = FieldId { parent: variant, local_id };
342 let ty = field_types[local_id].clone().substitute(substs); 342 let ty = field_types[local_id].clone().substitute(&Interner, substs);
343 (field.into(), Type::new_with_resolver_inner(db, krate, &self.resolver, ty)) 343 (field.into(), Type::new_with_resolver_inner(db, krate, &self.resolver, ty))
344 }) 344 })
345 .collect() 345 .collect()