diff options
| author | Yotam Ofek <yotam.ofek@gmail.com> | 2025-03-28 12:14:09 +0000 |
|---|---|---|
| committer | Yotam Ofek <yotam.ofek@gmail.com> | 2025-03-28 12:14:09 +0000 |
| commit | 827cb1b2a7b4334b38b20c291a95de62894c335c (patch) | |
| tree | 4a7a6c6e4bf3936b297ab599b0f69a0b2cff75f1 | |
| parent | e77a8f439cc87c5d67b007e9811578533de1de91 (diff) | |
| download | rust-827cb1b2a7b4334b38b20c291a95de62894c335c.tar.gz rust-827cb1b2a7b4334b38b20c291a95de62894c335c.zip | |
use `try_fold` instead of `fold`
| -rw-r--r-- | compiler/stable_mir/src/mir/body.rs | 3 | ||||
| -rw-r--r-- | compiler/stable_mir/src/mir/visit.rs | 2 |
2 files changed, 2 insertions, 3 deletions
diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs index b1bf7bce828..2a1c163de3c 100644 --- a/compiler/stable_mir/src/mir/body.rs +++ b/compiler/stable_mir/src/mir/body.rs @@ -1057,8 +1057,7 @@ impl Place { /// In order to retrieve the correct type, the `locals` argument must match the list of all /// locals from the function body where this place originates from. pub fn ty(&self, locals: &[LocalDecl]) -> Result<Ty, Error> { - let start_ty = locals[self.local].ty; - self.projection.iter().fold(Ok(start_ty), |place_ty, elem| elem.ty(place_ty?)) + self.projection.iter().try_fold(locals[self.local].ty, |place_ty, elem| elem.ty(place_ty)) } } diff --git a/compiler/stable_mir/src/mir/visit.rs b/compiler/stable_mir/src/mir/visit.rs index 09447e70dfb..9d2368ba332 100644 --- a/compiler/stable_mir/src/mir/visit.rs +++ b/compiler/stable_mir/src/mir/visit.rs @@ -563,7 +563,7 @@ pub struct PlaceRef<'a> { impl PlaceRef<'_> { /// Get the type of this place. pub fn ty(&self, locals: &[LocalDecl]) -> Result<Ty, Error> { - self.projection.iter().fold(Ok(locals[self.local].ty), |place_ty, elem| elem.ty(place_ty?)) + self.projection.iter().try_fold(locals[self.local].ty, |place_ty, elem| elem.ty(place_ty)) } } |
