Skip to content

Commit 827cb1b

Browse files
committed
use try_fold instead of fold
1 parent e77a8f4 commit 827cb1b

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

Diff for: compiler/stable_mir/src/mir/body.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1057,8 +1057,7 @@ impl Place {
10571057
/// In order to retrieve the correct type, the `locals` argument must match the list of all
10581058
/// locals from the function body where this place originates from.
10591059
pub fn ty(&self, locals: &[LocalDecl]) -> Result<Ty, Error> {
1060-
let start_ty = locals[self.local].ty;
1061-
self.projection.iter().fold(Ok(start_ty), |place_ty, elem| elem.ty(place_ty?))
1060+
self.projection.iter().try_fold(locals[self.local].ty, |place_ty, elem| elem.ty(place_ty))
10621061
}
10631062
}
10641063

Diff for: compiler/stable_mir/src/mir/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ pub struct PlaceRef<'a> {
563563
impl PlaceRef<'_> {
564564
/// Get the type of this place.
565565
pub fn ty(&self, locals: &[LocalDecl]) -> Result<Ty, Error> {
566-
self.projection.iter().fold(Ok(locals[self.local].ty), |place_ty, elem| elem.ty(place_ty?))
566+
self.projection.iter().try_fold(locals[self.local].ty, |place_ty, elem| elem.ty(place_ty))
567567
}
568568
}
569569

0 commit comments

Comments
 (0)