From e11cd8fe35fbb4fcaf7859f4cef2dbd94ff7d230 Mon Sep 17 00:00:00 2001 From: adamrk Date: Wed, 2 Sep 2020 22:33:54 +0200 Subject: Remove exposing unification --- crates/hir/src/code_model.rs | 6 ------ crates/hir_ty/src/db.rs | 3 --- crates/hir_ty/src/infer.rs | 13 ------------- crates/ide/src/completion/presentation.rs | 2 +- 4 files changed, 1 insertion(+), 23 deletions(-) (limited to 'crates') diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index afbf78b3b..dc3a1699f 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs @@ -1118,12 +1118,6 @@ impl Local { ast.map_left(|it| it.cast().unwrap().to_node(&root)).map_right(|it| it.to_node(&root)) }) } - - pub fn can_unify(self, other: Type, db: &dyn HirDatabase) -> bool { - let def = DefWithBodyId::from(self.parent); - let infer = db.infer(def); - db.can_unify(def, infer[self.pat_id].clone(), other.ty.value) - } } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] diff --git a/crates/hir_ty/src/db.rs b/crates/hir_ty/src/db.rs index 57e60c53b..25cf9eb7f 100644 --- a/crates/hir_ty/src/db.rs +++ b/crates/hir_ty/src/db.rs @@ -26,9 +26,6 @@ pub trait HirDatabase: DefDatabase + Upcast { #[salsa::invoke(crate::infer::infer_query)] fn infer_query(&self, def: DefWithBodyId) -> Arc; - #[salsa::invoke(crate::infer::can_unify)] - fn can_unify(&self, def: DefWithBodyId, ty1: Ty, ty2: Ty) -> bool; - #[salsa::invoke(crate::lower::ty_query)] #[salsa::cycle(crate::lower::ty_recover)] fn ty(&self, def: TyDefId) -> Binders; diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index d461e077b..2db05ae78 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs @@ -78,19 +78,6 @@ pub(crate) fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> Arc bool { - let resolver = def.resolver(db.upcast()); - let mut ctx = InferenceContext::new(db, def, resolver); - - let ty1 = ctx.canonicalizer().canonicalize_ty(ty1).value; - let ty2 = ctx.canonicalizer().canonicalize_ty(ty2).value; - let mut kinds = Vec::from(ty1.kinds.to_vec()); - kinds.extend_from_slice(ty2.kinds.as_ref()); - let tys = crate::Canonical::new((ty1.value, ty2.value), kinds); - - unify(&tys).is_some() -} - #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] enum ExprOrPatId { ExprId(ExprId), diff --git a/crates/ide/src/completion/presentation.rs b/crates/ide/src/completion/presentation.rs index 059fdfdc9..c7d460465 100644 --- a/crates/ide/src/completion/presentation.rs +++ b/crates/ide/src/completion/presentation.rs @@ -194,7 +194,7 @@ impl Completions { fn add_arg(arg: &str, ty: &Type, ctx: &CompletionContext) -> String { if let Some(derefed_ty) = ty.remove_ref() { for (name, local) in ctx.locals.iter() { - if name == arg && local.can_unify(derefed_ty.clone(), ctx.db) { + if name == arg && local.ty(ctx.db) == derefed_ty { return (if ty.is_mutable_reference() { "&mut " } else { "&" }).to_string() + &arg.to_string(); } -- cgit v1.2.3