diff --git a/clippy_lints/src/assigning_clones.rs b/clippy_lints/src/assigning_clones.rs index 1e636720cc0..40c72a299c1 100644 --- a/clippy_lints/src/assigning_clones.rs +++ b/clippy_lints/src/assigning_clones.rs @@ -61,16 +61,14 @@ impl<'tcx> LateLintPass<'tcx> for AssigningClones { }; if is_ok_to_suggest(cx, lhs, &call) { - suggest(cx, assign_expr, lhs, call); + suggest(cx, assign_expr, lhs, &call); } } } // Try to resolve the call to `Clone::clone` or `ToOwned::to_owned`. fn extract_call<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Option> { - let Some(fn_def_id) = clippy_utils::fn_def_id(cx, expr) else { - return None; - }; + let fn_def_id = clippy_utils::fn_def_id(cx, expr)?; // Fast paths to only check method calls without arguments or function calls with a single argument let (target, kind, resolved_method) = match expr.kind { @@ -182,7 +180,7 @@ fn suggest<'tcx>( cx: &LateContext<'tcx>, assign_expr: &hir::Expr<'tcx>, lhs: &hir::Expr<'tcx>, - call: CallCandidate<'tcx>, + call: &CallCandidate<'tcx>, ) { span_lint_and_then(cx, ASSIGNING_CLONES, assign_expr.span, call.message(), |diag| { let mut applicability = Applicability::MachineApplicable; diff --git a/clippy_utils/src/sugg.rs b/clippy_utils/src/sugg.rs index b355e66b7b1..0dc389993dd 100644 --- a/clippy_utils/src/sugg.rs +++ b/clippy_utils/src/sugg.rs @@ -994,7 +994,7 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> { // no adjustment needed here, as field projections are handled by the compiler ProjectionKind::Field(..) => match cmt.place.ty_before_projection(i).kind() { ty::Adt(..) | ty::Tuple(_) => { - replacement_str = ident_str_with_proj.clone(); + replacement_str.clone_from(&ident_str_with_proj); projections_handled = true; }, _ => (), diff --git a/tests/missing-test-files.rs b/tests/missing-test-files.rs index 0d35a22cd9a..141c11ddb47 100644 --- a/tests/missing-test-files.rs +++ b/tests/missing-test-files.rs @@ -54,7 +54,7 @@ fn explore_directory(dir: &Path) -> Vec { let file_prefix = path.file_prefix().unwrap().to_str().unwrap().to_string(); if let Some(ext) = path.extension() { match ext.to_str().unwrap() { - "rs" | "toml" => current_file = file_prefix.clone(), + "rs" | "toml" => current_file.clone_from(&file_prefix), "stderr" | "stdout" => { if file_prefix != current_file { missing_files.push(path.to_str().unwrap().to_string());