mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Fix TyBuilder methods
This commit is contained in:
parent
b24e6f6030
commit
1332e72d09
1 changed files with 5 additions and 5 deletions
|
@ -4,6 +4,7 @@ use std::iter;
|
||||||
|
|
||||||
use chalk_ir::{
|
use chalk_ir::{
|
||||||
cast::{Cast, CastTo, Caster},
|
cast::{Cast, CastTo, Caster},
|
||||||
|
fold::Fold,
|
||||||
interner::HasInterner,
|
interner::HasInterner,
|
||||||
AdtId, BoundVar, DebruijnIndex, Safety, Scalar,
|
AdtId, BoundVar, DebruijnIndex, Safety, Scalar,
|
||||||
};
|
};
|
||||||
|
@ -32,8 +33,7 @@ impl<D> TyBuilder<D> {
|
||||||
|
|
||||||
fn build_internal(self) -> (D, Substitution) {
|
fn build_internal(self) -> (D, Substitution) {
|
||||||
assert_eq!(self.vec.len(), self.param_count);
|
assert_eq!(self.vec.len(), self.param_count);
|
||||||
// FIXME: would be good to have a way to construct a chalk_ir::Substitution from the interned form
|
let subst = Substitution::from_iter(&Interner, self.vec);
|
||||||
let subst = Substitution::intern(self.vec);
|
|
||||||
(self.data, subst)
|
(self.data, subst)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ impl TyBuilder<hir_def::AdtId> {
|
||||||
self.vec.push(fallback().cast(&Interner));
|
self.vec.push(fallback().cast(&Interner));
|
||||||
} else {
|
} else {
|
||||||
// each default can depend on the previous parameters
|
// each default can depend on the previous parameters
|
||||||
let subst_so_far = Substitution::intern(self.vec.clone());
|
let subst_so_far = Substitution::from_iter(&Interner, self.vec.clone());
|
||||||
self.vec
|
self.vec
|
||||||
.push(default_ty.clone().substitute(&Interner, &subst_so_far).cast(&Interner));
|
.push(default_ty.clone().substitute(&Interner, &subst_so_far).cast(&Interner));
|
||||||
}
|
}
|
||||||
|
@ -196,13 +196,13 @@ impl TyBuilder<TypeAliasId> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: TypeWalk + HasInterner<Interner = Interner>> TyBuilder<Binders<T>> {
|
impl<T: HasInterner<Interner = Interner> + Fold<Interner>> TyBuilder<Binders<T>> {
|
||||||
fn subst_binders(b: Binders<T>) -> Self {
|
fn subst_binders(b: Binders<T>) -> Self {
|
||||||
let param_count = b.binders.len(&Interner);
|
let param_count = b.binders.len(&Interner);
|
||||||
TyBuilder::new(b, param_count)
|
TyBuilder::new(b, param_count)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build(self) -> T {
|
pub fn build(self) -> <T as Fold<Interner>>::Result {
|
||||||
let (b, subst) = self.build_internal();
|
let (b, subst) = self.build_internal();
|
||||||
b.substitute(&Interner, &subst)
|
b.substitute(&Interner, &subst)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue