Skip to content

Commit 6ddd840

Browse files
committed
Minor refactoring in try_index_step
Merges `if-let` and `if x.is_some() { ... }` blocks
1 parent 2caeeb0 commit 6ddd840

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Diff for: compiler/rustc_typeck/src/check/place_op.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
103103
let method =
104104
self.try_overloaded_place_op(expr.span, self_ty, &[input_ty], PlaceOp::Index);
105105

106-
let result = method.map(|ok| {
106+
if let Some(result) = method {
107107
debug!("try_index_step: success, using overloaded indexing");
108-
let method = self.register_infer_ok_obligations(ok);
108+
let method = self.register_infer_ok_obligations(result);
109109

110110
let mut adjustments = self.adjust_steps(autoderef);
111111
if let ty::Ref(region, _, hir::Mutability::Not) = method.sig.inputs()[0].kind() {
@@ -128,10 +128,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
128128
self.apply_adjustments(base_expr, adjustments);
129129

130130
self.write_method_call(expr.hir_id, method);
131-
(input_ty, self.make_overloaded_place_return_type(method).ty)
132-
});
133-
if result.is_some() {
134-
return result;
131+
132+
return Some((input_ty, self.make_overloaded_place_return_type(method).ty));
135133
}
136134
}
137135

0 commit comments

Comments
 (0)