Fix lint errors

This commit is contained in:
Jakub Beránek 2024-01-23 15:18:03 +01:00
parent 41f5ee1189
commit f7356f2a8f
No known key found for this signature in database
GPG Key ID: 909CD0D26483516B
3 changed files with 5 additions and 7 deletions

View File

@ -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;

View File

@ -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;
},
_ => (),

View File

@ -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());