diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-01 12:57:26 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-01 12:57:26 +0000 |
commit | cda13d54613006c7985da0489878605300ba05b8 (patch) | |
tree | 81a8fc4b890192c41f00f7731929e781c3cb790a /crates/hir_ty/src/traits/chalk | |
parent | 1c7b2b8c0748c9548500d0dc08c8da1d1a36c81a (diff) | |
parent | 4b7fc693150f333cefe0e69d93271807f32741c4 (diff) |
Merge #7823
7823: Being Ty::InferenceVar closer to chalk equivalent r=flodiebold a=Veykril
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/traits/chalk')
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 60d74e21a..995ff6a9a 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -17,7 +17,7 @@ use crate::{ | |||
17 | primitive::UintTy, | 17 | primitive::UintTy, |
18 | traits::{Canonical, Obligation}, | 18 | traits::{Canonical, Obligation}, |
19 | CallableDefId, FnPointer, FnSig, GenericPredicate, InEnvironment, OpaqueTy, OpaqueTyId, | 19 | CallableDefId, FnPointer, FnSig, GenericPredicate, InEnvironment, OpaqueTy, OpaqueTyId, |
20 | ProjectionPredicate, ProjectionTy, Scalar, Substs, TraitEnvironment, TraitRef, Ty, TyKind, | 20 | ProjectionPredicate, ProjectionTy, Scalar, Substs, TraitEnvironment, TraitRef, Ty, |
21 | }; | 21 | }; |
22 | 22 | ||
23 | use super::interner::*; | 23 | use super::interner::*; |
@@ -107,7 +107,7 @@ impl ToChalk for Ty { | |||
107 | .to_ty::<Interner>(&Interner) | 107 | .to_ty::<Interner>(&Interner) |
108 | } | 108 | } |
109 | Ty::Bound(idx) => chalk_ir::TyKind::BoundVar(idx).intern(&Interner), | 109 | Ty::Bound(idx) => chalk_ir::TyKind::BoundVar(idx).intern(&Interner), |
110 | Ty::Infer(_infer_ty) => panic!("uncanonicalized infer ty"), | 110 | Ty::InferenceVar(..) => panic!("uncanonicalized infer ty"), |
111 | Ty::Dyn(predicates) => { | 111 | Ty::Dyn(predicates) => { |
112 | let where_clauses = chalk_ir::QuantifiedWhereClauses::from_iter( | 112 | let where_clauses = chalk_ir::QuantifiedWhereClauses::from_iter( |
113 | &Interner, | 113 | &Interner, |
@@ -532,20 +532,12 @@ where | |||
532 | type Chalk = chalk_ir::Canonical<T::Chalk>; | 532 | type Chalk = chalk_ir::Canonical<T::Chalk>; |
533 | 533 | ||
534 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical<T::Chalk> { | 534 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical<T::Chalk> { |
535 | let kinds = self | 535 | let kinds = self.kinds.iter().map(|&tk| { |
536 | .kinds | 536 | chalk_ir::CanonicalVarKind::new( |
537 | .iter() | 537 | chalk_ir::VariableKind::Ty(tk), |
538 | .map(|k| match k { | 538 | chalk_ir::UniverseIndex::ROOT, |
539 | TyKind::General => chalk_ir::TyVariableKind::General, | 539 | ) |
540 | TyKind::Integer => chalk_ir::TyVariableKind::Integer, | 540 | }); |
541 | TyKind::Float => chalk_ir::TyVariableKind::Float, | ||
542 | }) | ||
543 | .map(|tk| { | ||
544 | chalk_ir::CanonicalVarKind::new( | ||
545 | chalk_ir::VariableKind::Ty(tk), | ||
546 | chalk_ir::UniverseIndex::ROOT, | ||
547 | ) | ||
548 | }); | ||
549 | let value = self.value.to_chalk(db); | 541 | let value = self.value.to_chalk(db); |
550 | chalk_ir::Canonical { | 542 | chalk_ir::Canonical { |
551 | value, | 543 | value, |
@@ -558,17 +550,13 @@ where | |||
558 | .binders | 550 | .binders |
559 | .iter(&Interner) | 551 | .iter(&Interner) |
560 | .map(|k| match k.kind { | 552 | .map(|k| match k.kind { |
561 | chalk_ir::VariableKind::Ty(tk) => match tk { | 553 | chalk_ir::VariableKind::Ty(tk) => tk, |
562 | chalk_ir::TyVariableKind::General => TyKind::General, | ||
563 | chalk_ir::TyVariableKind::Integer => TyKind::Integer, | ||
564 | chalk_ir::TyVariableKind::Float => TyKind::Float, | ||
565 | }, | ||
566 | // HACK: Chalk can sometimes return new lifetime variables. We | 554 | // HACK: Chalk can sometimes return new lifetime variables. We |
567 | // want to just skip them, but to not mess up the indices of | 555 | // want to just skip them, but to not mess up the indices of |
568 | // other variables, we'll just create a new type variable in | 556 | // other variables, we'll just create a new type variable in |
569 | // their place instead. This should not matter (we never see the | 557 | // their place instead. This should not matter (we never see the |
570 | // actual *uses* of the lifetime variable). | 558 | // actual *uses* of the lifetime variable). |
571 | chalk_ir::VariableKind::Lifetime => TyKind::General, | 559 | chalk_ir::VariableKind::Lifetime => chalk_ir::TyVariableKind::General, |
572 | chalk_ir::VariableKind::Const(_) => panic!("unexpected const from Chalk"), | 560 | chalk_ir::VariableKind::Const(_) => panic!("unexpected const from Chalk"), |
573 | }) | 561 | }) |
574 | .collect(); | 562 | .collect(); |