]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/clippy_lints/src/len_zero.rs
Rollup merge of #102888 - GuillaumeGomez:improve-search-color-check, r=notriddle
[rust.git] / src / tools / clippy / clippy_lints / src / len_zero.rs
index 7d15dd4cb216488caf619bd3c3afcf625459645e..3a563736fb077b7ae51d3016ff63c9c0c4434182 100644 (file)
@@ -210,7 +210,8 @@ fn fill_trait_set(traitt: DefId, set: &mut DefIdSet, cx: &LateContext<'_>) {
         }
     }
 
-    if cx.access_levels.is_exported(visited_trait.def_id.def_id) && trait_items.iter().any(|i| is_named_self(cx, i, sym::len))
+    if cx.access_levels.is_exported(visited_trait.def_id.def_id)
+        && trait_items.iter().any(|i| is_named_self(cx, i, sym::len))
     {
         let mut current_and_super_traits = DefIdSet::default();
         fill_trait_set(visited_trait.def_id.to_def_id(), &mut current_and_super_traits, cx);
@@ -278,15 +279,13 @@ fn expected_sig(self, self_kind: ImplicitSelfKind) -> String {
             _ => "",
         };
         match self {
-            Self::Integral => format!("expected signature: `({}self) -> bool`", self_ref),
-            Self::Option(_) => format!(
-                "expected signature: `({}self) -> bool` or `({}self) -> Option<bool>",
-                self_ref, self_ref
-            ),
-            Self::Result(..) => format!(
-                "expected signature: `({}self) -> bool` or `({}self) -> Result<bool>",
-                self_ref, self_ref
-            ),
+            Self::Integral => format!("expected signature: `({self_ref}self) -> bool`"),
+            Self::Option(_) => {
+                format!("expected signature: `({self_ref}self) -> bool` or `({self_ref}self) -> Option<bool>")
+            },
+            Self::Result(..) => {
+                format!("expected signature: `({self_ref}self) -> bool` or `({self_ref}self) -> Result<bool>")
+            },
         }
     }
 }
@@ -326,8 +325,7 @@ fn check_for_is_empty<'tcx>(
     let (msg, is_empty_span, self_kind) = match is_empty {
         None => (
             format!(
-                "{} `{}` has a public `len` method, but no `is_empty` method",
-                item_kind,
+                "{item_kind} `{}` has a public `len` method, but no `is_empty` method",
                 item_name.as_str(),
             ),
             None,
@@ -335,8 +333,7 @@ fn check_for_is_empty<'tcx>(
         ),
         Some(is_empty) if !cx.access_levels.is_exported(is_empty.def_id.expect_local()) => (
             format!(
-                "{} `{}` has a public `len` method, but a private `is_empty` method",
-                item_kind,
+                "{item_kind} `{}` has a public `len` method, but a private `is_empty` method",
                 item_name.as_str(),
             ),
             Some(cx.tcx.def_span(is_empty.def_id)),
@@ -348,8 +345,7 @@ fn check_for_is_empty<'tcx>(
         {
             (
                 format!(
-                    "{} `{}` has a public `len` method, but the `is_empty` method has an unexpected signature",
-                    item_kind,
+                    "{item_kind} `{}` has a public `len` method, but the `is_empty` method has an unexpected signature",
                     item_name.as_str(),
                 ),
                 Some(cx.tcx.def_span(is_empty.def_id)),
@@ -419,10 +415,9 @@ fn check_len(
                 LEN_ZERO,
                 span,
                 &format!("length comparison to {}", if compare_to == 0 { "zero" } else { "one" }),
-                &format!("using `{}is_empty` is clearer and more explicit", op),
+                &format!("using `{op}is_empty` is clearer and more explicit"),
                 format!(
-                    "{}{}.is_empty()",
-                    op,
+                    "{op}{}.is_empty()",
                     snippet_with_applicability(cx, receiver.span, "_", &mut applicability)
                 ),
                 applicability,
@@ -439,10 +434,9 @@ fn check_empty_expr(cx: &LateContext<'_>, span: Span, lit1: &Expr<'_>, lit2: &Ex
             COMPARISON_TO_EMPTY,
             span,
             "comparison to empty slice",
-            &format!("using `{}is_empty` is clearer and more explicit", op),
+            &format!("using `{op}is_empty` is clearer and more explicit"),
             format!(
-                "{}{}.is_empty()",
-                op,
+                "{op}{}.is_empty()",
                 snippet_with_applicability(cx, lit1.span, "_", &mut applicability)
             ),
             applicability,