Skip to content

Commit b3497a2

Browse files
author
Ype Kingma
committed
Use Span.to() to replace spans_merge()
1 parent 18bab34 commit b3497a2

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

clippy_lints/src/lifetimes_bound_nested_ref.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ fn get_declared_bounds_spans(generics: &Generics) -> BTreeMap<BoundLftSymbolPair
240240
gp.bounds.iter().for_each(|bound| {
241241
if let GenericBound::Outlives(outlived_lft) = bound {
242242
let decl_span = if let Some(colon_span) = gp.colon_span {
243-
spans_merge(colon_span, outlived_lft.ident.span)
243+
colon_span.to(outlived_lft.ident.span)
244244
} else {
245245
outlived_lft.ident.span
246246
};
@@ -475,7 +475,7 @@ impl ImpliedBoundsLinter {
475475
let impl_bound_decl = implied_bound.to_declaration();
476476
let msg_missing = format!("missing lifetimes bound declaration: {impl_bound_decl}");
477477
if let Some(long_lft_decl_span) = self.declared_lifetimes_spans.get(&implied_bound.long_lft) {
478-
let nested_ref_span = spans_merge(*outlived_lft_span, *long_lft_span);
478+
let nested_ref_span = outlived_lft_span.to(*long_lft_span);
479479
span_lint_and_fix_sugg_and_note_cause(
480480
cx,
481481
EXPLICIT_LIFETIMES_BOUND,
@@ -492,7 +492,7 @@ impl ImpliedBoundsLinter {
492492

493493
for (declared_bound, decl_span) in self.declared_bounds_spans {
494494
if let Some((outlived_lft_span, long_lft_span)) = self.implied_bounds_span_pairs.get(&declared_bound) {
495-
let nested_ref_span = spans_merge(*outlived_lft_span, *long_lft_span);
495+
let nested_ref_span = outlived_lft_span.to(*long_lft_span);
496496
span_lint_and_note(
497497
cx,
498498
IMPLICIT_LIFETIMES_BOUND,
@@ -510,15 +510,6 @@ impl ImpliedBoundsLinter {
510510
}
511511
}
512512

513-
fn spans_merge(span1: Span, span2: Span) -> Span {
514-
Span::new(
515-
span1.lo().min(span2.lo()),
516-
span1.hi().max(span2.hi()),
517-
span1.ctxt(),
518-
span1.parent(),
519-
)
520-
}
521-
522513
/// Combine `span_lint_and_sugg` and `span_lint_and_help`:
523514
/// give a lint error, a suggestion to fix, and a note on the cause of the lint in the code.
524515
#[allow(clippy::too_many_arguments)]

0 commit comments

Comments
 (0)