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 }).into_ok()
+ ty.super_fold_with(&mut RegionEraserVisitor { tcx })
}
impl<'tcx> TyCtxt<'tcx> {
return value;
}
debug!("erase_regions({:?})", value);
- let value1 = value.fold_with(&mut RegionEraserVisitor { tcx: self }).into_ok();
+ let value1 = value.fold_with(&mut RegionEraserVisitor { tcx: self });
debug!("erase_regions = {:?}", value1);
value1
}
tcx: TyCtxt<'tcx>,
}
-impl TypeFolder<'tcx> for RegionEraserVisitor<'tcx> {
+impl<'tcx> TypeFolder<'tcx> for RegionEraserVisitor<'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
self.tcx
}
- fn fold_ty(&mut self, ty: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
- if ty.needs_infer() { ty.super_fold_with(self) } else { Ok(self.tcx.erase_regions_ty(ty)) }
+ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
+ if ty.needs_infer() { ty.super_fold_with(self) } else { self.tcx.erase_regions_ty(ty) }
}
- fn fold_binder<T>(&mut self, t: ty::Binder<'tcx, T>) -> Result<ty::Binder<'tcx, T>, Self::Error>
+ fn fold_binder<T>(&mut self, t: ty::Binder<'tcx, T>) -> ty::Binder<'tcx, T>
where
T: TypeFoldable<'tcx>,
{
u.super_fold_with(self)
}
- fn fold_region(&mut self, r: ty::Region<'tcx>) -> Result<ty::Region<'tcx>, Self::Error> {
+ fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
// because late-bound regions affect subtyping, we can't
// erase the bound/free distinction, but we can replace
// all free regions with 'erased.
// away. In codegen, they will always be erased to 'erased
// whenever a substitution occurs.
match *r {
- ty::ReLateBound(..) => Ok(r),
- _ => Ok(self.tcx.lifetimes.re_erased),
+ ty::ReLateBound(..) => r,
+ _ => self.tcx.lifetimes.re_erased,
}
}
- fn fold_mir_const(
- &mut self,
- c: mir::ConstantKind<'tcx>,
- ) -> Result<mir::ConstantKind<'tcx>, Self::Error> {
+ fn fold_mir_const(&mut self, c: mir::ConstantKind<'tcx>) -> mir::ConstantKind<'tcx> {
c.super_fold_with(self)
}
}