Adapt TypeFolder implementors to return a Result

Co-authored-by: Alan Egerton <eggyal@gmail.com>
This commit is contained in:
LeSeulArtichaut 2021-05-19 15:01:30 +02:00 committed by Alan Egerton
parent 6e3fa20b00
commit 6dc3dae46f
No known key found for this signature in database
GPG key ID: 07CAC3CCA7E0643F
24 changed files with 387 additions and 305 deletions

View file

@ -860,11 +860,11 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx> {
self.tcx
}
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
(match r {
fn fold_region(&mut self, r: ty::Region<'tcx>) -> Result<ty::Region<'tcx>, Self::Error> {
Ok((match r {
ty::ReVar(vid) => self.vid_to_region.get(vid).cloned(),
_ => None,
})
.unwrap_or_else(|| r.super_fold_with(self))
.unwrap_or_else(|| r.super_fold_with(self).into_ok()))
}
}