5149: Implement Chalk variable kinds r=flodiebold a=flodiebold

This means we need to keep track of the kinds (general/int/float) of variables in `Canonical`, which requires some more ceremony. (It also exposes some places where we're not really dealing with canonicalization correctly -- another thing to be cleaned up when we switch to using Chalk's types directly.)

Should fix the last remaining issue of #2534.

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
This commit is contained in:
bors[bot] 2020-07-01 18:41:06 +00:00 committed by GitHub
commit a33eefa3b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 140 additions and 71 deletions

View file

@ -1189,7 +1189,7 @@ impl Type {
None => return false,
};
let canonical_ty = Canonical { value: self.ty.value.clone(), num_vars: 0 };
let canonical_ty = Canonical { value: self.ty.value.clone(), kinds: Arc::new([]) };
method_resolution::implements_trait(
&canonical_ty,
db,
@ -1213,7 +1213,7 @@ impl Type {
self.ty.environment.clone(),
hir_ty::Obligation::Trait(trait_ref),
),
num_vars: 0,
kinds: Arc::new([]),
};
db.trait_solve(self.krate, goal).is_some()
@ -1288,7 +1288,7 @@ impl Type {
pub fn autoderef<'a>(&'a self, db: &'a dyn HirDatabase) -> impl Iterator<Item = Type> + 'a {
// There should be no inference vars in types passed here
// FIXME check that?
let canonical = Canonical { value: self.ty.value.clone(), num_vars: 0 };
let canonical = Canonical { value: self.ty.value.clone(), kinds: Arc::new([]) };
let environment = self.ty.environment.clone();
let ty = InEnvironment { value: canonical, environment };
autoderef(db, Some(self.krate), ty)
@ -1329,7 +1329,7 @@ impl Type {
// 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.value.clone(), num_vars: 0 };
let canonical = Canonical { value: self.ty.value.clone(), kinds: Arc::new([]) };
let env = self.ty.environment.clone();
let krate = krate.id;
@ -1360,7 +1360,7 @@ impl Type {
// 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.value.clone(), num_vars: 0 };
let canonical = Canonical { value: self.ty.value.clone(), kinds: Arc::new([]) };
let env = self.ty.environment.clone();
let krate = krate.id;