Skip to content

Commit 0e722cc

Browse files
authored
Rollup merge of rust-lang#139056 - yotamofek:pr/smir/try_fold, r=scottmcm
use `try_fold` instead of `fold` Small cleanup, applies the [`manual_try_fold`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold) clippy lint.
2 parents 111351f + 827cb1b commit 0e722cc

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)