1
1
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg};
2
2
use clippy_utils::source::{snippet, snippet_opt, snippet_with_applicability};
3
- use clippy_utils::{SpanlessEq, SpanlessHash};
3
+ use clippy_utils::{is_from_proc_macro, SpanlessEq, SpanlessHash};
4
4
use core::hash::{Hash, Hasher};
5
5
use if_chain::if_chain;
6
6
use itertools::Itertools;
@@ -260,10 +260,7 @@ impl TraitBounds {
260
260
SpanlessTy { ty: p.bounded_ty, cx },
261
261
p.bounds.iter().collect::<Vec<_>>()
262
262
);
263
- let bounded_ty = snippet(cx, p.bounded_ty.span, "_");
264
- if let TyKind::Path(qpath) = p.bounded_ty.kind;
265
- if format!("{}:", rustc_hir_pretty::qpath_to_string(&qpath)) == format!("{bounded_ty}:");
266
-
263
+ if !is_from_proc_macro(cx, p.bounded_ty);
267
264
then {
268
265
let trait_bounds = v
269
266
.iter()
@@ -272,7 +269,10 @@ impl TraitBounds {
272
269
.filter_map(get_trait_info_from_bound)
273
270
.map(|(_, _, span)| snippet_with_applicability(cx, span, "..", &mut applicability))
274
271
.join(" + ");
275
- let hint_string = format!("consider combining the bounds: `{bounded_ty}: {trait_bounds}`");
272
+ let hint_string = format!(
273
+ "consider combining the bounds: `{}: {trait_bounds}`",
274
+ snippet(cx, p.bounded_ty.span, "_"),
275
+ );
276
276
span_lint_and_help(
277
277
cx,
278
278
TYPE_REPETITION_IN_BOUNDS,
0 commit comments