aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-04-08 12:58:03 +0100
committerFlorian Diebold <[email protected]>2021-04-08 13:23:17 +0100
commita163554857db677e892c211b41deda676a6d1511 (patch)
tree7b2d2cadebdf4decb5fabe83ea1bd48c28ec56e6 /crates
parenta838a60caaa5351d7543bcbebb1aa976b0b73f39 (diff)
Fix `Canonicalized::apply_solution`
Now that we're using Chalk's `substitute` which actually knows about lifetimes, the hack doesn't work anymore, but we can put in a proper lifetime.
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_ty/src/infer/unify.rs29
1 files changed, 16 insertions, 13 deletions
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs
index 648af4ebf..3b9c4a495 100644
--- a/crates/hir_ty/src/infer/unify.rs
+++ b/crates/hir_ty/src/infer/unify.rs
@@ -3,15 +3,16 @@
3use std::borrow::Cow; 3use std::borrow::Cow;
4 4
5use chalk_ir::{ 5use chalk_ir::{
6 fold::Fold, interner::HasInterner, FloatTy, IntTy, TyVariableKind, UniverseIndex, VariableKind, 6 cast::Cast, fold::Fold, interner::HasInterner, FloatTy, IntTy, TyVariableKind, UniverseIndex,
7 VariableKind,
7}; 8};
8use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue}; 9use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue};
9 10
10use super::{DomainGoal, InferenceContext}; 11use super::{DomainGoal, InferenceContext};
11use crate::{ 12use crate::{
12 fold_tys, AliasEq, AliasTy, BoundVar, Canonical, CanonicalVarKinds, DebruijnIndex, FnPointer, 13 fold_tys, static_lifetime, AliasEq, AliasTy, BoundVar, Canonical, CanonicalVarKinds,
13 FnSubst, InEnvironment, InferenceVar, Interner, Scalar, Substitution, Ty, TyExt, TyKind, 14 DebruijnIndex, FnPointer, FnSubst, InEnvironment, InferenceVar, Interner, Scalar, Substitution,
14 TypeWalk, WhereClause, 15 Ty, TyExt, TyKind, TypeWalk, WhereClause,
15}; 16};
16 17
17impl<'a> InferenceContext<'a> { 18impl<'a> InferenceContext<'a> {
@@ -139,15 +140,17 @@ impl<T: HasInterner<Interner = Interner>> Canonicalized<T> {
139 let new_vars = Substitution::from_iter( 140 let new_vars = Substitution::from_iter(
140 &Interner, 141 &Interner,
141 solution.binders.iter(&Interner).map(|k| match k.kind { 142 solution.binders.iter(&Interner).map(|k| match k.kind {
142 VariableKind::Ty(TyVariableKind::General) => ctx.table.new_type_var(), 143 VariableKind::Ty(TyVariableKind::General) => {
143 VariableKind::Ty(TyVariableKind::Integer) => ctx.table.new_integer_var(), 144 ctx.table.new_type_var().cast(&Interner)
144 VariableKind::Ty(TyVariableKind::Float) => ctx.table.new_float_var(), 145 }
145 // HACK: Chalk can sometimes return new lifetime variables. We 146 VariableKind::Ty(TyVariableKind::Integer) => {
146 // want to just skip them, but to not mess up the indices of 147 ctx.table.new_integer_var().cast(&Interner)
147 // other variables, we'll just create a new type variable in 148 }
148 // their place instead. This should not matter (we never see the 149 VariableKind::Ty(TyVariableKind::Float) => {
149 // actual *uses* of the lifetime variable). 150 ctx.table.new_float_var().cast(&Interner)
150 VariableKind::Lifetime => ctx.table.new_type_var(), 151 }
152 // Chalk can sometimes return new lifetime variables. We just use the static lifetime everywhere
153 VariableKind::Lifetime => static_lifetime().cast(&Interner),
151 _ => panic!("const variable in solution"), 154 _ => panic!("const variable in solution"),
152 }), 155 }),
153 ); 156 );