Unwrap the results of type folders
Co-authored-by: Alan Egerton <eggyal@gmail.com>
This commit is contained in:
parent
6dc3dae46f
commit
30bf20a692
34 changed files with 191 additions and 167 deletions
|
@ -56,6 +56,7 @@
|
|||
#![feature(try_blocks)]
|
||||
#![feature(try_reserve_kind)]
|
||||
#![feature(nonzero_ops)]
|
||||
#![feature(unwrap_infallible)]
|
||||
#![recursion_limit = "512"]
|
||||
|
||||
#[macro_use]
|
||||
|
|
|
@ -9,7 +9,7 @@ pub(super) fn provide(providers: &mut ty::query::Providers) {
|
|||
fn erase_regions_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
// N.B., use `super_fold_with` here. If we used `fold_with`, it
|
||||
// could invoke the `erase_regions_ty` query recursively.
|
||||
ty.super_fold_with(&mut RegionEraserVisitor { tcx })
|
||||
ty.super_fold_with(&mut RegionEraserVisitor { tcx }).into_ok()
|
||||
}
|
||||
|
||||
impl<'tcx> TyCtxt<'tcx> {
|
||||
|
@ -27,7 +27,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
return value;
|
||||
}
|
||||
debug!("erase_regions({:?})", value);
|
||||
let value1 = value.fold_with(&mut RegionEraserVisitor { tcx: self });
|
||||
let value1 = value.fold_with(&mut RegionEraserVisitor { tcx: self }).into_ok();
|
||||
debug!("erase_regions = {:?}", value1);
|
||||
value1
|
||||
}
|
||||
|
|
|
@ -336,7 +336,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
where
|
||||
T: TypeFoldable<'tcx>,
|
||||
{
|
||||
value.fold_with(&mut RegionFolder::new(self, skipped_regions, &mut f))
|
||||
value.fold_with(&mut RegionFolder::new(self, skipped_regions, &mut f)).into_ok()
|
||||
}
|
||||
|
||||
/// Invoke `callback` on every region appearing free in `value`.
|
||||
|
@ -638,7 +638,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
value
|
||||
} else {
|
||||
let mut replacer = BoundVarReplacer::new(self, Some(&mut real_fld_r), None, None);
|
||||
value.fold_with(&mut replacer)
|
||||
value.fold_with(&mut replacer).into_ok()
|
||||
};
|
||||
(value, region_map)
|
||||
}
|
||||
|
@ -664,7 +664,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
} else {
|
||||
let mut replacer =
|
||||
BoundVarReplacer::new(self, Some(&mut fld_r), Some(&mut fld_t), Some(&mut fld_c));
|
||||
value.fold_with(&mut replacer)
|
||||
value.fold_with(&mut replacer).into_ok()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1030,7 +1030,7 @@ where
|
|||
{
|
||||
debug!("shift_vars(value={:?}, amount={})", value, amount);
|
||||
|
||||
value.fold_with(&mut Shifter::new(tcx, amount))
|
||||
value.fold_with(&mut Shifter::new(tcx, amount)).into_ok()
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||
|
@ -1293,7 +1293,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
///
|
||||
/// FIXME(@lcnr): explain this function a bit more
|
||||
pub fn expose_default_const_substs<T: TypeFoldable<'tcx>>(self, v: T) -> T {
|
||||
v.fold_with(&mut ExposeDefaultConstSubstsFolder { tcx: self })
|
||||
v.fold_with(&mut ExposeDefaultConstSubstsFolder { tcx: self }).into_ok()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -669,7 +669,7 @@ fn polymorphize<'tcx>(
|
|||
// ..and polymorphize any closures/generators captured as upvars.
|
||||
let upvars_ty = upvars_ty.unwrap();
|
||||
let polymorphized_upvars_ty = upvars_ty.fold_with(
|
||||
&mut PolymorphizationFolder { tcx });
|
||||
&mut PolymorphizationFolder { tcx }).into_ok();
|
||||
debug!("polymorphize: polymorphized_upvars_ty={:?}", polymorphized_upvars_ty);
|
||||
ty::GenericArg::from(polymorphized_upvars_ty)
|
||||
},
|
||||
|
|
|
@ -35,7 +35,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
if !value.has_projections() {
|
||||
value
|
||||
} else {
|
||||
value.fold_with(&mut NormalizeAfterErasingRegionsFolder { tcx: self, param_env })
|
||||
value
|
||||
.fold_with(&mut NormalizeAfterErasingRegionsFolder { tcx: self, param_env })
|
||||
.into_ok()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2193,7 +2193,7 @@ impl<F: fmt::Write> FmtPrinter<'_, 'tcx, F> {
|
|||
name: &mut name,
|
||||
region_map: BTreeMap::new(),
|
||||
};
|
||||
let new_value = value.clone().skip_binder().fold_with(&mut folder);
|
||||
let new_value = value.clone().skip_binder().fold_with(&mut folder).into_ok();
|
||||
let region_map = folder.region_map;
|
||||
start_or_continue(&mut self, "", "> ");
|
||||
(new_value, region_map)
|
||||
|
|
|
@ -439,7 +439,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> Subst<'tcx> for T {
|
|||
span: Option<Span>,
|
||||
) -> T {
|
||||
let mut folder = SubstFolder { tcx, substs, span, binders_passed: 0 };
|
||||
self.fold_with(&mut folder)
|
||||
self.fold_with(&mut folder).into_ok()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -574,14 +574,14 @@ impl<'tcx> OpaqueTypeExpander<'tcx> {
|
|||
if self.found_any_recursion {
|
||||
return None;
|
||||
}
|
||||
let substs = substs.fold_with(self);
|
||||
let substs = substs.fold_with(self).into_ok();
|
||||
if !self.check_recursion || self.seen_opaque_tys.insert(def_id) {
|
||||
let expanded_ty = match self.expanded_cache.get(&(def_id, substs)) {
|
||||
Some(expanded_ty) => expanded_ty,
|
||||
None => {
|
||||
let generic_ty = self.tcx.type_of(def_id);
|
||||
let concrete_ty = generic_ty.subst(self.tcx, substs);
|
||||
let expanded_ty = self.fold_ty(concrete_ty);
|
||||
let expanded_ty = self.fold_ty(concrete_ty).into_ok();
|
||||
self.expanded_cache.insert((def_id, substs), expanded_ty);
|
||||
expanded_ty
|
||||
}
|
||||
|
@ -1092,7 +1092,7 @@ pub fn normalize_opaque_types(
|
|||
check_recursion: false,
|
||||
tcx,
|
||||
};
|
||||
val.fold_with(&mut visitor)
|
||||
val.fold_with(&mut visitor).into_ok()
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut ty::query::Providers) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue