diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-05-21 18:51:53 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-05-21 18:51:53 +0100 |
commit | edbde25ca2f13ffacfd006ada7b38618d36d97c6 (patch) | |
tree | b1c5208c74ce56a36c8a9c454b9c479a3312ee94 /crates/hir_ty/src/chalk_db.rs | |
parent | de403b10448e23f232804596538de92fc57203d6 (diff) | |
parent | ef558c97d09b0be8639c92f490e5ad380aa04288 (diff) |
Merge #8856
8856: Use Chalk for unification r=flodiebold a=flodiebold
- use Chalk's unification, get rid of our own `unify`
- rewrite coercion to not use unification internals and to be more analogous to rustc
- fix various coercion bugs
- rewrite handling of obligations, since the old hacky optimization where we noted when an inference variable changes wasn't possible anymore
- stop trying to deeply resolve types all the time during inference, instead only do it shallowly where necessary
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/chalk_db.rs')
-rw-r--r-- | crates/hir_ty/src/chalk_db.rs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/crates/hir_ty/src/chalk_db.rs b/crates/hir_ty/src/chalk_db.rs index 8f054d06b..b108fd559 100644 --- a/crates/hir_ty/src/chalk_db.rs +++ b/crates/hir_ty/src/chalk_db.rs | |||
@@ -344,20 +344,20 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
344 | } | 344 | } |
345 | 345 | ||
346 | fn unification_database(&self) -> &dyn chalk_ir::UnificationDatabase<Interner> { | 346 | fn unification_database(&self) -> &dyn chalk_ir::UnificationDatabase<Interner> { |
347 | self | 347 | &self.db |
348 | } | 348 | } |
349 | } | 349 | } |
350 | 350 | ||
351 | impl<'a> chalk_ir::UnificationDatabase<Interner> for ChalkContext<'a> { | 351 | impl<'a> chalk_ir::UnificationDatabase<Interner> for &'a dyn HirDatabase { |
352 | fn fn_def_variance( | 352 | fn fn_def_variance( |
353 | &self, | 353 | &self, |
354 | fn_def_id: chalk_ir::FnDefId<Interner>, | 354 | fn_def_id: chalk_ir::FnDefId<Interner>, |
355 | ) -> chalk_ir::Variances<Interner> { | 355 | ) -> chalk_ir::Variances<Interner> { |
356 | self.db.fn_def_variance(self.krate, fn_def_id) | 356 | HirDatabase::fn_def_variance(*self, fn_def_id) |
357 | } | 357 | } |
358 | 358 | ||
359 | fn adt_variance(&self, adt_id: chalk_ir::AdtId<Interner>) -> chalk_ir::Variances<Interner> { | 359 | fn adt_variance(&self, adt_id: chalk_ir::AdtId<Interner>) -> chalk_ir::Variances<Interner> { |
360 | self.db.adt_variance(self.krate, adt_id) | 360 | HirDatabase::adt_variance(*self, adt_id) |
361 | } | 361 | } |
362 | } | 362 | } |
363 | 363 | ||
@@ -651,11 +651,7 @@ pub(crate) fn fn_def_datum_query( | |||
651 | Arc::new(datum) | 651 | Arc::new(datum) |
652 | } | 652 | } |
653 | 653 | ||
654 | pub(crate) fn fn_def_variance_query( | 654 | pub(crate) fn fn_def_variance_query(db: &dyn HirDatabase, fn_def_id: FnDefId) -> Variances { |
655 | db: &dyn HirDatabase, | ||
656 | _krate: CrateId, | ||
657 | fn_def_id: FnDefId, | ||
658 | ) -> Variances { | ||
659 | let callable_def: CallableDefId = from_chalk(db, fn_def_id); | 655 | let callable_def: CallableDefId = from_chalk(db, fn_def_id); |
660 | let generic_params = generics(db.upcast(), callable_def.into()); | 656 | let generic_params = generics(db.upcast(), callable_def.into()); |
661 | Variances::from_iter( | 657 | Variances::from_iter( |
@@ -666,7 +662,6 @@ pub(crate) fn fn_def_variance_query( | |||
666 | 662 | ||
667 | pub(crate) fn adt_variance_query( | 663 | pub(crate) fn adt_variance_query( |
668 | db: &dyn HirDatabase, | 664 | db: &dyn HirDatabase, |
669 | _krate: CrateId, | ||
670 | chalk_ir::AdtId(adt_id): AdtId, | 665 | chalk_ir::AdtId(adt_id): AdtId, |
671 | ) -> Variances { | 666 | ) -> Variances { |
672 | let generic_params = generics(db.upcast(), adt_id.into()); | 667 | let generic_params = generics(db.upcast(), adt_id.into()); |