diff options
| author | Jakub Beránek <berykubik@gmail.com> | 2024-01-23 15:18:03 +0100 |
|---|---|---|
| committer | Jakub Beránek <berykubik@gmail.com> | 2024-03-01 16:36:05 +0100 |
| commit | f7356f2a8f1c47f8358c62dceacc2386d7ae7d8e (patch) | |
| tree | 5b849396344111dbccf1a354fcf76923b6e81635 | |
| parent | 41f5ee11894180700e82aaf9d4d271ddb8d22600 (diff) | |
| download | rust-f7356f2a8f1c47f8358c62dceacc2386d7ae7d8e.tar.gz rust-f7356f2a8f1c47f8358c62dceacc2386d7ae7d8e.zip | |
Fix lint errors
| -rw-r--r-- | clippy_lints/src/assigning_clones.rs | 8 | ||||
| -rw-r--r-- | clippy_utils/src/sugg.rs | 2 | ||||
| -rw-r--r-- | tests/missing-test-files.rs | 2 |
3 files changed, 5 insertions, 7 deletions
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<CallCandidate<'tcx>> { - 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<String> { 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()); |
