Skip to content

Commit 1a0a613

Browse files
chenyukangestebank
andcommitted
Apply suggestions from code review
Co-authored-by: Esteban Kuber <[email protected]>
1 parent e7a7778 commit 1a0a613

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,25 +1021,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10211021
expr_ty: Ty<'tcx>,
10221022
expected_ty: Ty<'tcx>,
10231023
) -> bool {
1024-
if let ty::Ref(_, inner_ty, hir::Mutability::Not) = expr_ty.kind() &&
1025-
let Some(clone_trait_def) = self.tcx.lang_items().clone_trait() &&
1026-
expected_ty == *inner_ty &&
1027-
self
1024+
if let ty::Ref(_, inner_ty, hir::Mutability::Not) = expr_ty.kind()
1025+
&& let Some(clone_trait_def) = self.tcx.lang_items().clone_trait()
1026+
&& expected_ty == *inner_ty
1027+
&& self
10281028
.infcx
10291029
.type_implements_trait(
10301030
clone_trait_def,
10311031
[self.tcx.erase_regions(expected_ty)],
10321032
self.param_env
10331033
)
1034-
.must_apply_modulo_regions() {
1035-
diag.span_suggestion_verbose(
1036-
expr.span.shrink_to_hi(),
1037-
"consider using clone here",
1038-
".clone()",
1039-
Applicability::MachineApplicable,
1040-
);
1041-
return true;
1042-
}
1034+
.must_apply_modulo_regions()
1035+
{
1036+
diag.span_suggestion_verbose(
1037+
expr.span.shrink_to_hi(),
1038+
"consider using clone here",
1039+
".clone()",
1040+
Applicability::MachineApplicable,
1041+
);
1042+
return true;
1043+
}
10431044
false
10441045
}
10451046

0 commit comments

Comments
 (0)