diff options
Diffstat (limited to 'crates/hir')
-rw-r--r-- | crates/hir/src/lib.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index d443b124c..52d72c3c5 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -1712,15 +1712,17 @@ impl Type { | |||
1712 | resolver: &Resolver, | 1712 | resolver: &Resolver, |
1713 | ty: Ty, | 1713 | ty: Ty, |
1714 | ) -> Type { | 1714 | ) -> Type { |
1715 | let environment = | 1715 | let environment = resolver |
1716 | resolver.generic_def().map_or_else(Default::default, |d| db.trait_environment(d)); | 1716 | .generic_def() |
1717 | .map_or_else(|| Arc::new(TraitEnvironment::empty(krate)), |d| db.trait_environment(d)); | ||
1717 | Type { krate, env: environment, ty } | 1718 | Type { krate, env: environment, ty } |
1718 | } | 1719 | } |
1719 | 1720 | ||
1720 | fn new(db: &dyn HirDatabase, krate: CrateId, lexical_env: impl HasResolver, ty: Ty) -> Type { | 1721 | fn new(db: &dyn HirDatabase, krate: CrateId, lexical_env: impl HasResolver, ty: Ty) -> Type { |
1721 | let resolver = lexical_env.resolver(db.upcast()); | 1722 | let resolver = lexical_env.resolver(db.upcast()); |
1722 | let environment = | 1723 | let environment = resolver |
1723 | resolver.generic_def().map_or_else(Default::default, |d| db.trait_environment(d)); | 1724 | .generic_def() |
1725 | .map_or_else(|| Arc::new(TraitEnvironment::empty(krate)), |d| db.trait_environment(d)); | ||
1724 | Type { krate, env: environment, ty } | 1726 | Type { krate, env: environment, ty } |
1725 | } | 1727 | } |
1726 | 1728 | ||
@@ -2051,11 +2053,7 @@ impl Type { | |||
2051 | name: Option<&Name>, | 2053 | name: Option<&Name>, |
2052 | mut callback: impl FnMut(&Ty, AssocItem) -> Option<T>, | 2054 | mut callback: impl FnMut(&Ty, AssocItem) -> Option<T>, |
2053 | ) -> Option<T> { | 2055 | ) -> Option<T> { |
2054 | // There should be no inference vars in types passed here | 2056 | let canonical = hir_ty::replace_errors_with_variables(self.ty.clone()); |
2055 | // FIXME check that? | ||
2056 | // FIXME replace Unknown by bound vars here | ||
2057 | let canonical = | ||
2058 | Canonical { value: self.ty.clone(), binders: CanonicalVarKinds::empty(&Interner) }; | ||
2059 | 2057 | ||
2060 | let env = self.env.clone(); | 2058 | let env = self.env.clone(); |
2061 | let krate = krate.id; | 2059 | let krate = krate.id; |
@@ -2223,8 +2221,9 @@ impl Type { | |||
2223 | walk_type(db, self, &mut cb); | 2221 | walk_type(db, self, &mut cb); |
2224 | } | 2222 | } |
2225 | 2223 | ||
2226 | pub fn could_unify_with(&self, other: &Type) -> bool { | 2224 | pub fn could_unify_with(&self, db: &dyn HirDatabase, other: &Type) -> bool { |
2227 | could_unify(&self.ty, &other.ty) | 2225 | let tys = hir_ty::replace_errors_with_variables((self.ty.clone(), other.ty.clone())); |
2226 | could_unify(db, self.env.clone(), &tys) | ||
2228 | } | 2227 | } |
2229 | } | 2228 | } |
2230 | 2229 | ||