about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCentri3 <114838443+Centri3@users.noreply.github.com>2023-06-06 22:16:02 -0500
committerCentri3 <114838443+Centri3@users.noreply.github.com>2023-06-06 22:16:02 -0500
commita434a7715d205959c3a07c9a7fe43e56a128e0c4 (patch)
tree895a866106040fc76e4f6608d3f82b9b969e5a67
parente97f190a9dab40aa1fe2e5ec72af5d52f5fcf1fd (diff)
downloadrust-a434a7715d205959c3a07c9a7fe43e56a128e0c4.tar.gz
rust-a434a7715d205959c3a07c9a7fe43e56a128e0c4.zip
`impl WithSearchPat for Ty`
-rw-r--r--clippy_lints/src/trait_bounds.rs12
-rw-r--r--clippy_utils/src/check_proc_macro.rs3
2 files changed, 8 insertions, 7 deletions
diff --git a/clippy_lints/src/trait_bounds.rs b/clippy_lints/src/trait_bounds.rs
index 2e6108d6b24..f4554fbcf9b 100644
--- a/clippy_lints/src/trait_bounds.rs
+++ b/clippy_lints/src/trait_bounds.rs
@@ -1,6 +1,6 @@
 use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg};
 use clippy_utils::source::{snippet, snippet_opt, snippet_with_applicability};
-use clippy_utils::{SpanlessEq, SpanlessHash};
+use clippy_utils::{is_from_proc_macro, SpanlessEq, SpanlessHash};
 use core::hash::{Hash, Hasher};
 use if_chain::if_chain;
 use itertools::Itertools;
@@ -260,10 +260,7 @@ impl TraitBounds {
                     SpanlessTy { ty: p.bounded_ty, cx },
                     p.bounds.iter().collect::<Vec<_>>()
                 );
-                let bounded_ty = snippet(cx, p.bounded_ty.span, "_");
-                if let TyKind::Path(qpath) = p.bounded_ty.kind;
-                if format!("{}:", rustc_hir_pretty::qpath_to_string(&qpath)) == format!("{bounded_ty}:");
-
+                if !is_from_proc_macro(cx, p.bounded_ty);
                 then {
                     let trait_bounds = v
                         .iter()
@@ -272,7 +269,10 @@ impl TraitBounds {
                         .filter_map(get_trait_info_from_bound)
                         .map(|(_, _, span)| snippet_with_applicability(cx, span, "..", &mut applicability))
                         .join(" + ");
-                    let hint_string = format!("consider combining the bounds: `{bounded_ty}: {trait_bounds}`");
+                    let hint_string = format!(
+                        "consider combining the bounds: `{}: {trait_bounds}`",
+                        snippet(cx, p.bounded_ty.span, "_"),
+                    );
                     span_lint_and_help(
                         cx,
                         TYPE_REPETITION_IN_BOUNDS,
diff --git a/clippy_utils/src/check_proc_macro.rs b/clippy_utils/src/check_proc_macro.rs
index 7f79b8f87dd..05b34986274 100644
--- a/clippy_utils/src/check_proc_macro.rs
+++ b/clippy_utils/src/check_proc_macro.rs
@@ -351,7 +351,8 @@ fn ty_search_pat(ty: &Ty<'_>) -> (Pat, Pat) {
         TyKind::Never => (Pat::Str("!"), Pat::Str("")),
         TyKind::Tup(..) => (Pat::Str("("), Pat::Str(")")),
         TyKind::OpaqueDef(..) => (Pat::Str("impl"), Pat::Str("")),
-        // NOTE: This is missing `TraitObject` and `Path` here. It always return true then.
+        TyKind::Path(qpath) => qpath_search_pat(&qpath),
+        // NOTE: This is missing `TraitObject`. It always return true then.
         _ => (Pat::Str(""), Pat::Str("")),
     }
 }