mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
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.
This commit is contained in:
parent
a838a60caa
commit
a163554857
1 changed files with 16 additions and 13 deletions
|
@ -3,15 +3,16 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use chalk_ir::{
|
use chalk_ir::{
|
||||||
fold::Fold, interner::HasInterner, FloatTy, IntTy, TyVariableKind, UniverseIndex, VariableKind,
|
cast::Cast, fold::Fold, interner::HasInterner, FloatTy, IntTy, TyVariableKind, UniverseIndex,
|
||||||
|
VariableKind,
|
||||||
};
|
};
|
||||||
use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue};
|
use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue};
|
||||||
|
|
||||||
use super::{DomainGoal, InferenceContext};
|
use super::{DomainGoal, InferenceContext};
|
||||||
use crate::{
|
use crate::{
|
||||||
fold_tys, AliasEq, AliasTy, BoundVar, Canonical, CanonicalVarKinds, DebruijnIndex, FnPointer,
|
fold_tys, static_lifetime, AliasEq, AliasTy, BoundVar, Canonical, CanonicalVarKinds,
|
||||||
FnSubst, InEnvironment, InferenceVar, Interner, Scalar, Substitution, Ty, TyExt, TyKind,
|
DebruijnIndex, FnPointer, FnSubst, InEnvironment, InferenceVar, Interner, Scalar, Substitution,
|
||||||
TypeWalk, WhereClause,
|
Ty, TyExt, TyKind, TypeWalk, WhereClause,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<'a> InferenceContext<'a> {
|
impl<'a> InferenceContext<'a> {
|
||||||
|
@ -139,15 +140,17 @@ impl<T: HasInterner<Interner = Interner>> Canonicalized<T> {
|
||||||
let new_vars = Substitution::from_iter(
|
let new_vars = Substitution::from_iter(
|
||||||
&Interner,
|
&Interner,
|
||||||
solution.binders.iter(&Interner).map(|k| match k.kind {
|
solution.binders.iter(&Interner).map(|k| match k.kind {
|
||||||
VariableKind::Ty(TyVariableKind::General) => ctx.table.new_type_var(),
|
VariableKind::Ty(TyVariableKind::General) => {
|
||||||
VariableKind::Ty(TyVariableKind::Integer) => ctx.table.new_integer_var(),
|
ctx.table.new_type_var().cast(&Interner)
|
||||||
VariableKind::Ty(TyVariableKind::Float) => ctx.table.new_float_var(),
|
}
|
||||||
// HACK: Chalk can sometimes return new lifetime variables. We
|
VariableKind::Ty(TyVariableKind::Integer) => {
|
||||||
// want to just skip them, but to not mess up the indices of
|
ctx.table.new_integer_var().cast(&Interner)
|
||||||
// other variables, we'll just create a new type variable in
|
}
|
||||||
// their place instead. This should not matter (we never see the
|
VariableKind::Ty(TyVariableKind::Float) => {
|
||||||
// actual *uses* of the lifetime variable).
|
ctx.table.new_float_var().cast(&Interner)
|
||||||
VariableKind::Lifetime => ctx.table.new_type_var(),
|
}
|
||||||
|
// Chalk can sometimes return new lifetime variables. We just use the static lifetime everywhere
|
||||||
|
VariableKind::Lifetime => static_lifetime().cast(&Interner),
|
||||||
_ => panic!("const variable in solution"),
|
_ => panic!("const variable in solution"),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue