Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 0250c51

Browse files
committed
refactor
1 parent 6ea7cd8 commit 0250c51

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

clippy_lints/src/trait_bounds.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ impl TraitBounds {
260260
SpanlessTy { ty: p.bounded_ty, cx },
261261
p.bounds.iter().collect::<Vec<_>>()
262262
);
263+
let bounded_ty = snippet(cx, p.bounded_ty.span, "_");
263264
if let TyKind::Path(qpath) = p.bounded_ty.kind;
264-
if format!("{}:", rustc_hir_pretty::qpath_to_string(&qpath))
265-
== format!("{}:", snippet(cx, p.bounded_ty.span, "_"));
265+
if format!("{}:", rustc_hir_pretty::qpath_to_string(&qpath)) == format!("{}:", bounded_ty);
266266

267267
then {
268268
let trait_bounds = v
@@ -272,10 +272,7 @@ impl TraitBounds {
272272
.filter_map(get_trait_info_from_bound)
273273
.map(|(_, _, span)| snippet_with_applicability(cx, span, "..", &mut applicability))
274274
.join(" + ");
275-
let hint_string = format!(
276-
"consider combining the bounds: `{}: {trait_bounds}`",
277-
snippet(cx, p.bounded_ty.span, "_"),
278-
);
275+
let hint_string = format!("consider combining the bounds: `{}: {trait_bounds}`", bounded_ty);
279276
span_lint_and_help(
280277
cx,
281278
TYPE_REPETITION_IN_BOUNDS,
@@ -345,7 +342,7 @@ fn check_trait_bound_duplication(cx: &LateContext<'_>, gen: &'_ Generics<'_>) {
345342
"this trait bound is already specified in the where clause",
346343
None,
347344
"consider removing this trait bound",
348-
);
345+
);
349346
}
350347
}
351348
}

0 commit comments

Comments
 (0)