From 48c492af7ec8ff6af4fe2b38f83aa007c9f7f0b8 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 15 May 2021 20:18:54 +0200 Subject: Fix compilation of hir and ide crates --- crates/hir/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/hir/src') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index d443b124c..21b1a8e4a 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -2223,8 +2223,8 @@ impl Type { walk_type(db, self, &mut cb); } - pub fn could_unify_with(&self, other: &Type) -> bool { - could_unify(&self.ty, &other.ty) + pub fn could_unify_with(&self, db: &dyn HirDatabase, other: &Type) -> bool { + could_unify(db, self.env.clone(), &self.ty, &other.ty) } } -- cgit v1.2.3 From 8397734cfe26793d3e9f9ec5f8392655a4b8e106 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 15 May 2021 20:28:07 +0200 Subject: Fix HIR expecting errors to unify with anything --- crates/hir/src/lib.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'crates/hir/src') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 21b1a8e4a..1429384cb 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -2051,11 +2051,7 @@ impl Type { name: Option<&Name>, mut callback: impl FnMut(&Ty, AssocItem) -> Option, ) -> Option { - // There should be no inference vars in types passed here - // FIXME check that? - // FIXME replace Unknown by bound vars here - let canonical = - Canonical { value: self.ty.clone(), binders: CanonicalVarKinds::empty(&Interner) }; + let canonical = hir_ty::replace_errors_with_variables(self.ty.clone()); let env = self.env.clone(); let krate = krate.id; @@ -2224,7 +2220,8 @@ impl Type { } pub fn could_unify_with(&self, db: &dyn HirDatabase, other: &Type) -> bool { - could_unify(db, self.env.clone(), &self.ty, &other.ty) + let tys = hir_ty::replace_errors_with_variables((self.ty.clone(), other.ty.clone())); + could_unify(db, self.env.clone(), &tys) } } -- cgit v1.2.3 From 1250ddc5cf58ff0a6bbf7c07e5bd9f7cc7db5a09 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 16 May 2021 15:50:28 +0200 Subject: Rework obligation handling We can't do the easy hack that we did before anymore, where we kept track of whether any inference variables changed since the last time we rechecked obligations. Instead, we store the obligations in canonicalized form; that way we can easily check the inference variables to see whether they have changed since the goal was canonicalized. --- crates/hir/src/lib.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'crates/hir/src') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 1429384cb..52d72c3c5 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1712,15 +1712,17 @@ impl Type { resolver: &Resolver, ty: Ty, ) -> Type { - let environment = - resolver.generic_def().map_or_else(Default::default, |d| db.trait_environment(d)); + let environment = resolver + .generic_def() + .map_or_else(|| Arc::new(TraitEnvironment::empty(krate)), |d| db.trait_environment(d)); Type { krate, env: environment, ty } } fn new(db: &dyn HirDatabase, krate: CrateId, lexical_env: impl HasResolver, ty: Ty) -> Type { let resolver = lexical_env.resolver(db.upcast()); - let environment = - resolver.generic_def().map_or_else(Default::default, |d| db.trait_environment(d)); + let environment = resolver + .generic_def() + .map_or_else(|| Arc::new(TraitEnvironment::empty(krate)), |d| db.trait_environment(d)); Type { krate, env: environment, ty } } -- cgit v1.2.3