WIP partial apply fix
This commit is contained in:
parent
c63f1fe92b
commit
a9f1e1c440
2 changed files with 192 additions and 103 deletions
|
@ -61,6 +61,7 @@ impl<'cx, 'tcx> AtExt<'tcx> for At<'cx, 'tcx> {
|
|||
error: false,
|
||||
cache: SsoHashMap::new(),
|
||||
anon_depth: 0,
|
||||
universes: vec![],
|
||||
};
|
||||
|
||||
let result = value.fold_with(&mut normalizer);
|
||||
|
@ -91,6 +92,7 @@ struct QueryNormalizer<'cx, 'tcx> {
|
|||
cache: SsoHashMap<Ty<'tcx>, Ty<'tcx>>,
|
||||
error: bool,
|
||||
anon_depth: usize,
|
||||
universes: Vec<Option<ty::UniverseIndex>>,
|
||||
}
|
||||
|
||||
impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
|
||||
|
@ -98,6 +100,16 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
|
|||
self.infcx.tcx
|
||||
}
|
||||
|
||||
fn fold_binder<T: TypeFoldable<'tcx>>(
|
||||
&mut self,
|
||||
t: ty::Binder<'tcx, T>,
|
||||
) -> ty::Binder<'tcx, T> {
|
||||
self.universes.push(None);
|
||||
let t = t.super_fold_with(self);
|
||||
self.universes.pop();
|
||||
t
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
if !ty.has_projections() {
|
||||
|
@ -216,8 +228,19 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
|
|||
|
||||
let tcx = self.infcx.tcx;
|
||||
let infcx = self.infcx;
|
||||
let (data, mapped_regions, mapped_types, mapped_consts, universe_map) =
|
||||
crate::traits::project::BoundVarReplacer::replace_bound_vars(infcx, data);
|
||||
let replaced = crate::traits::project::BoundVarReplacer::replace_bound_vars(
|
||||
infcx,
|
||||
&mut self.universes,
|
||||
data,
|
||||
);
|
||||
let (data, mapped_regions, mapped_types, mapped_consts) = match replaced {
|
||||
Some(r) => r,
|
||||
None => {
|
||||
bug!("{:?} {:?}", data, self.universes);
|
||||
//self.error = true;
|
||||
//return ty.super_fold_with(self);
|
||||
}
|
||||
};
|
||||
let data = data.super_fold_with(self);
|
||||
|
||||
let mut orig_values = OriginalQueryValues::default();
|
||||
|
@ -263,7 +286,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
|
|||
mapped_regions,
|
||||
mapped_types,
|
||||
mapped_consts,
|
||||
universe_map,
|
||||
&self.universes,
|
||||
normalized_ty,
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue