mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Get rid of subst_bound_vars uses
This commit is contained in:
parent
e28f0c98ba
commit
fbab69cbff
@ -152,7 +152,7 @@ impl<T> Canonicalized<T> {
|
||||
// eagerly replace projections in the type; we may be getting types
|
||||
// e.g. from where clauses where this hasn't happened yet
|
||||
let ty = ctx.normalize_associated_types_in(
|
||||
ty.assert_ty_ref(&Interner).clone().subst_bound_vars(&new_vars),
|
||||
new_vars.apply(ty.assert_ty_ref(&Interner).clone(), &Interner),
|
||||
);
|
||||
ctx.table.unify(&TyKind::InferenceVar(v, k).intern(&Interner), &ty);
|
||||
}
|
||||
@ -173,8 +173,8 @@ pub(crate) fn unify(tys: &Canonical<(Ty, Ty)>) -> Option<Substitution> {
|
||||
// fallback to Unknown in the end (kind of hacky, as below)
|
||||
.map(|_| table.new_type_var()),
|
||||
);
|
||||
let ty1_with_vars = tys.value.0.clone().subst_bound_vars(&vars);
|
||||
let ty2_with_vars = tys.value.1.clone().subst_bound_vars(&vars);
|
||||
let ty1_with_vars = vars.apply(tys.value.0.clone(), &Interner);
|
||||
let ty2_with_vars = vars.apply(tys.value.1.clone(), &Interner);
|
||||
if !table.unify(&ty1_with_vars, &ty2_with_vars) {
|
||||
return None;
|
||||
}
|
||||
|
@ -477,7 +477,7 @@ impl<'a> TyLoweringContext<'a> {
|
||||
),
|
||||
);
|
||||
let s = generics.type_params_subst(self.db);
|
||||
t.substitution.clone().subst_bound_vars(&s)
|
||||
s.apply(t.substitution.clone(), &Interner)
|
||||
}
|
||||
TypeParamLoweringMode::Variable => t.substitution.clone(),
|
||||
};
|
||||
|
@ -12,7 +12,7 @@ use smallvec::SmallVec;
|
||||
|
||||
use crate::{
|
||||
AssocTypeId, CanonicalVarKinds, ChalkTraitId, ClosureId, FnDefId, FnSig, ForeignDefId,
|
||||
InferenceVar, Interner, OpaqueTyId, PlaceholderIndex, VariableKinds,
|
||||
InferenceVar, Interner, OpaqueTyId, PlaceholderIndex, TypeWalk, VariableKinds,
|
||||
};
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
||||
@ -286,6 +286,10 @@ impl Substitution {
|
||||
Substitution(elements.into_iter().casted(interner).collect())
|
||||
}
|
||||
|
||||
pub fn apply<T: TypeWalk>(&self, value: T, _interner: &Interner) -> T {
|
||||
value.subst_bound_vars(self)
|
||||
}
|
||||
|
||||
// Temporary helper functions, to be removed
|
||||
pub fn intern(interned: SmallVec<[GenericArg; 2]>) -> Substitution {
|
||||
Substitution(interned)
|
||||
|
Loading…
Reference in New Issue
Block a user