Skip to content

Commit 9c0bbe0

Browse files
committed
Use fold
1 parent 87420cd commit 9c0bbe0

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/librustc/mir/tcx.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,10 @@ impl<'tcx> Place<'tcx> {
127127
) -> PlaceTy<'tcx>
128128
where D: HasLocalDecls<'tcx>
129129
{
130-
let mut place_ty = base.ty(local_decls);
131-
132-
for elem in projection.iter() {
133-
place_ty = place_ty.projection_ty(tcx, elem);
134-
}
135-
136-
place_ty
130+
projection.iter().fold(
131+
base.ty(local_decls),
132+
|place_ty, elem| place_ty.projection_ty(tcx, elem)
133+
)
137134
}
138135

139136
pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>

0 commit comments

Comments
 (0)