1
Fork 0

Reduce boilerplate around infallible folders

This commit is contained in:
Alan Egerton 2021-12-01 00:55:57 +00:00
parent db7295fa96
commit bfc434b6d0
No known key found for this signature in database
GPG key ID: 07CAC3CCA7E0643F
41 changed files with 898 additions and 727 deletions

View file

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