From 0250c518449f535a4d38bf17f5b0ba5ecda3f3c9 Mon Sep 17 00:00:00 2001 From: Centri3 <114838443+Centri3@users.noreply.github.com> Date: Mon, 5 Jun 2023 14:46:47 -0500 Subject: [PATCH] refactor --- clippy_lints/src/trait_bounds.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/clippy_lints/src/trait_bounds.rs b/clippy_lints/src/trait_bounds.rs index 913ef7644aae..90c6429ff380 100644 --- a/clippy_lints/src/trait_bounds.rs +++ b/clippy_lints/src/trait_bounds.rs @@ -260,9 +260,9 @@ impl TraitBounds { SpanlessTy { ty: p.bounded_ty, cx }, p.bounds.iter().collect::>() ); + 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!("{}:", snippet(cx, p.bounded_ty.span, "_")); + if format!("{}:", rustc_hir_pretty::qpath_to_string(&qpath)) == format!("{}:", bounded_ty); then { let trait_bounds = v @@ -272,10 +272,7 @@ 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: `{}: {trait_bounds}`", - snippet(cx, p.bounded_ty.span, "_"), - ); + let hint_string = format!("consider combining the bounds: `{}: {trait_bounds}`", bounded_ty); span_lint_and_help( cx, TYPE_REPETITION_IN_BOUNDS, @@ -345,7 +342,7 @@ fn check_trait_bound_duplication(cx: &LateContext<'_>, gen: &'_ Generics<'_>) { "this trait bound is already specified in the where clause", None, "consider removing this trait bound", - ); + ); } } }