mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-01 09:33:26 +00:00
Assert index relationship between type_variable_table and var_unification_table
This commit is contained in:
parent
11a1f13cd1
commit
4b7fc69315
@ -225,36 +225,27 @@ impl InferenceTable {
|
||||
}
|
||||
}
|
||||
|
||||
fn new_var(&mut self, kind: TyVariableKind, diverging: bool) -> Ty {
|
||||
self.type_variable_table.push(TypeVariableData { diverging });
|
||||
let key = self.var_unification_table.new_key(TypeVarValue::Unknown);
|
||||
assert_eq!(key.0 as usize, self.type_variable_table.inner.len() - 1);
|
||||
Ty::InferenceVar(InferenceVar::from_inner(key), kind)
|
||||
}
|
||||
|
||||
pub(crate) fn new_type_var(&mut self) -> Ty {
|
||||
self.type_variable_table.push(TypeVariableData { diverging: false });
|
||||
Ty::InferenceVar(
|
||||
InferenceVar::from_inner(self.var_unification_table.new_key(TypeVarValue::Unknown)),
|
||||
TyVariableKind::General,
|
||||
)
|
||||
self.new_var(TyVariableKind::General, false)
|
||||
}
|
||||
|
||||
pub(crate) fn new_integer_var(&mut self) -> Ty {
|
||||
self.type_variable_table.push(TypeVariableData { diverging: false });
|
||||
Ty::InferenceVar(
|
||||
InferenceVar::from_inner(self.var_unification_table.new_key(TypeVarValue::Unknown)),
|
||||
TyVariableKind::Integer,
|
||||
)
|
||||
self.new_var(TyVariableKind::Integer, false)
|
||||
}
|
||||
|
||||
pub(crate) fn new_float_var(&mut self) -> Ty {
|
||||
self.type_variable_table.push(TypeVariableData { diverging: false });
|
||||
Ty::InferenceVar(
|
||||
InferenceVar::from_inner(self.var_unification_table.new_key(TypeVarValue::Unknown)),
|
||||
TyVariableKind::Float,
|
||||
)
|
||||
self.new_var(TyVariableKind::Float, false)
|
||||
}
|
||||
|
||||
pub(crate) fn new_maybe_never_var(&mut self) -> Ty {
|
||||
self.type_variable_table.push(TypeVariableData { diverging: true });
|
||||
Ty::InferenceVar(
|
||||
InferenceVar::from_inner(self.var_unification_table.new_key(TypeVarValue::Unknown)),
|
||||
TyVariableKind::General,
|
||||
)
|
||||
self.new_var(TyVariableKind::General, true)
|
||||
}
|
||||
|
||||
pub(crate) fn resolve_ty_completely(&mut self, ty: Ty) -> Ty {
|
||||
|
@ -527,11 +527,11 @@ impl TypeWalk for GenericPredicate {
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Canonical<T> {
|
||||
pub value: T,
|
||||
pub kinds: Arc<[chalk_ir::TyVariableKind]>,
|
||||
pub kinds: Arc<[TyVariableKind]>,
|
||||
}
|
||||
|
||||
impl<T> Canonical<T> {
|
||||
pub fn new(value: T, kinds: impl IntoIterator<Item = chalk_ir::TyVariableKind>) -> Self {
|
||||
pub fn new(value: T, kinds: impl IntoIterator<Item = TyVariableKind>) -> Self {
|
||||
Self { value, kinds: kinds.into_iter().collect() }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user