diff options
| author | John Kelly <johnharrykelly@gmail.com> | 2023-04-30 14:10:26 +0100 |
|---|---|---|
| committer | John Kelly <johnharrykelly@gmail.com> | 2023-04-30 14:10:26 +0100 |
| commit | 0fb3f3b25667c2e9c56a7fd83019cafec7ada1cf (patch) | |
| tree | d3411ae7b59b751811ad52287217d84c0b976aff | |
| parent | 1eff408ca44ae15ffd6592714487f168a5549bcc (diff) | |
| download | rust-0fb3f3b25667c2e9c56a7fd83019cafec7ada1cf.tar.gz rust-0fb3f3b25667c2e9c56a7fd83019cafec7ada1cf.zip | |
WIP
| -rw-r--r-- | clippy_lints/src/trait_bounds.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/clippy_lints/src/trait_bounds.rs b/clippy_lints/src/trait_bounds.rs index 1af2c594243..4c70bae7529 100644 --- a/clippy_lints/src/trait_bounds.rs +++ b/clippy_lints/src/trait_bounds.rs @@ -177,6 +177,7 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds { bounds, .. ), + span, .. }, .. @@ -189,6 +190,12 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds { let mut seen_def_ids = FxHashSet::default(); + let traits = bounds + .iter() + .filter_map(|b| snippet_opt(cx, b.span)) + .collect::<Vec<_>>(); + let traits = traits.join(" + "); + for bound in bounds.iter() { let Some(def_id) = bound.trait_ref.trait_def_id() else { continue; }; @@ -198,10 +205,10 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds { span_lint_and_sugg( cx, TRAIT_DUPLICATION_IN_BOUNDS, - bound.span, + *span, "this trait bound is already specified in trait declaration", "consider removing this trait bound", - "".to_string(), + traits.clone(), Applicability::MaybeIncorrect, ); } |
