From 0bc26c811c96c05b2e60c94d06e2904b0ce25fe7 Mon Sep 17 00:00:00 2001 From: "Samuel E. Moelius III" Date: Fri, 29 Jul 2022 17:46:09 -0400 Subject: [PATCH] `needed_ref` -> `needs_ref` --- clippy_lints/src/format_args.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/clippy_lints/src/format_args.rs b/clippy_lints/src/format_args.rs index 473c9a8675f1..9fb9fd99748b 100644 --- a/clippy_lints/src/format_args.rs +++ b/clippy_lints/src/format_args.rs @@ -137,12 +137,8 @@ fn check_to_string_in_format_args(cx: &LateContext<'_>, name: Symbol, value: &Ex if let Some(sized_trait_id) = cx.tcx.lang_items().sized_trait(); if let Some(receiver_snippet) = snippet_opt(cx, receiver.span); then { - let needed_ref = if implements_trait(cx, receiver_ty, sized_trait_id, &[]) { - "" - } else { - "&" - }; - if n_needed_derefs == 0 && needed_ref.is_empty() { + let needs_ref = !implements_trait(cx, receiver_ty, sized_trait_id, &[]); + if n_needed_derefs == 0 && !needs_ref { span_lint_and_sugg( cx, TO_STRING_IN_FORMAT_ARGS, @@ -167,7 +163,7 @@ fn check_to_string_in_format_args(cx: &LateContext<'_>, name: Symbol, value: &Ex "use this", format!( "{}{:*>width$}{}", - needed_ref, + if needs_ref { "&" } else { "" }, "", receiver_snippet, width = n_needed_derefs