|
3 | 3 | use std::borrow::Cow;
|
4 | 4 |
|
5 | 5 | use 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 | };
|
8 | 9 | use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue};
|
9 | 10 |
|
10 | 11 | use super::{DomainGoal, InferenceContext};
|
11 | 12 | use crate::{
|
12 |
| - fold_tys, AliasEq, AliasTy, BoundVar, Canonical, CanonicalVarKinds, DebruijnIndex, FnPointer, |
13 |
| - FnSubst, InEnvironment, InferenceVar, Interner, Scalar, Substitution, Ty, TyExt, TyKind, |
14 |
| - TypeWalk, WhereClause, |
| 13 | + fold_tys, static_lifetime, AliasEq, AliasTy, BoundVar, Canonical, CanonicalVarKinds, |
| 14 | + DebruijnIndex, FnPointer, FnSubst, InEnvironment, InferenceVar, Interner, Scalar, Substitution, |
| 15 | + Ty, TyExt, TyKind, TypeWalk, WhereClause, |
15 | 16 | };
|
16 | 17 |
|
17 | 18 | impl<'a> InferenceContext<'a> {
|
@@ -139,15 +140,17 @@ impl<T: HasInterner<Interner = Interner>> Canonicalized<T> {
|
139 | 140 | let new_vars = Substitution::from_iter(
|
140 | 141 | &Interner,
|
141 | 142 | solution.binders.iter(&Interner).map(|k| match k.kind {
|
142 |
| - VariableKind::Ty(TyVariableKind::General) => ctx.table.new_type_var(), |
143 |
| - VariableKind::Ty(TyVariableKind::Integer) => ctx.table.new_integer_var(), |
144 |
| - VariableKind::Ty(TyVariableKind::Float) => ctx.table.new_float_var(), |
145 |
| - // HACK: Chalk can sometimes return new lifetime variables. We |
146 |
| - // want to just skip them, but to not mess up the indices of |
147 |
| - // other variables, we'll just create a new type variable in |
148 |
| - // their place instead. This should not matter (we never see the |
149 |
| - // actual *uses* of the lifetime variable). |
150 |
| - VariableKind::Lifetime => ctx.table.new_type_var(), |
| 143 | + VariableKind::Ty(TyVariableKind::General) => { |
| 144 | + ctx.table.new_type_var().cast(&Interner) |
| 145 | + } |
| 146 | + VariableKind::Ty(TyVariableKind::Integer) => { |
| 147 | + ctx.table.new_integer_var().cast(&Interner) |
| 148 | + } |
| 149 | + VariableKind::Ty(TyVariableKind::Float) => { |
| 150 | + ctx.table.new_float_var().cast(&Interner) |
| 151 | + } |
| 152 | + // Chalk can sometimes return new lifetime variables. We just use the static lifetime everywhere |
| 153 | + VariableKind::Lifetime => static_lifetime().cast(&Interner), |
151 | 154 | _ => panic!("const variable in solution"),
|
152 | 155 | }),
|
153 | 156 | );
|
|
0 commit comments