]> git.lizzy.rs Git - rust.git/blobdiff - crates/hir_ty/src/infer/expr.rs
Merge #9007
[rust.git] / crates / hir_ty / src / infer / expr.rs
index 79a7321060011276daf83919653ab62abdc66f71..97507305c23ca86fed187c1330d5ea6956592f21 100644 (file)
@@ -44,7 +44,7 @@ pub(super) fn infer_expr(&mut self, tgt_expr: ExprId, expected: &Expectation) ->
             if !could_unify {
                 self.result.type_mismatches.insert(
                     tgt_expr.into(),
-                    TypeMismatch { expected: expected_ty.clone(), actual: ty.clone() },
+                    TypeMismatch { expected: expected_ty, actual: ty.clone() },
                 );
             }
         }
@@ -57,15 +57,14 @@ pub(super) fn infer_expr_coerce(&mut self, expr: ExprId, expected: &Expectation)
         let ty = self.infer_expr_inner(expr, &expected);
         let ty = if let Some(target) = expected.only_has_type(&mut self.table) {
             if !self.coerce(&ty, &target) {
-                self.result.type_mismatches.insert(
-                    expr.into(),
-                    TypeMismatch { expected: target.clone(), actual: ty.clone() },
-                );
+                self.result
+                    .type_mismatches
+                    .insert(expr.into(), TypeMismatch { expected: target, actual: ty.clone() });
                 // Return actual type when type mismatch.
                 // This is needed for diagnostic when return type mismatch.
                 ty
             } else {
-                target.clone()
+                target
             }
         } else {
             ty