Minor refactoring in try_index_step

Merges `if-let` and `if x.is_some() { ... }` blocks
This commit is contained in:
Ömer Sinan Ağacan 2021-03-14 16:00:02 +03:00
parent 2caeeb0527
commit 6ddd840f36
1 changed files with 4 additions and 6 deletions

View File

@ -103,9 +103,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let method =
self.try_overloaded_place_op(expr.span, self_ty, &[input_ty], PlaceOp::Index);
let result = method.map(|ok| {
if let Some(result) = method {
debug!("try_index_step: success, using overloaded indexing");
let method = self.register_infer_ok_obligations(ok);
let method = self.register_infer_ok_obligations(result);
let mut adjustments = self.adjust_steps(autoderef);
if let ty::Ref(region, _, hir::Mutability::Not) = method.sig.inputs()[0].kind() {
@ -128,10 +128,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.apply_adjustments(base_expr, adjustments);
self.write_method_call(expr.hir_id, method);
(input_ty, self.make_overloaded_place_return_type(method).ty)
});
if result.is_some() {
return result;
return Some((input_ty, self.make_overloaded_place_return_type(method).ty));
}
}