Remove exposing unification

This commit is contained in:
adamrk 2020-09-02 22:33:54 +02:00
parent d9bb86ad7d
commit e11cd8fe35
4 changed files with 1 additions and 23 deletions

View File

@ -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)]

View File

@ -26,9 +26,6 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
#[salsa::invoke(crate::infer::infer_query)]
fn infer_query(&self, def: DefWithBodyId) -> Arc<InferenceResult>;
#[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<Ty>;

View File

@ -78,19 +78,6 @@ pub(crate) fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> Arc<Infer
Arc::new(ctx.resolve_all())
}
pub(crate) fn can_unify(db: &dyn HirDatabase, def: DefWithBodyId, ty1: Ty, ty2: Ty) -> 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),

View File

@ -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();
}