Skip to content

Commit

Permalink
Auto merge of #106916 - lukas-code:overlapping-substs, r=estebank
Browse files Browse the repository at this point in the history
Remove overlapping parts of multipart suggestions

This PR adds a debug assertion that the parts of a single substitution cannot overlap, fixes a overlapping substitution from the testsuite, and fixes rust-lang/rust#106870.

Note that a single suggestion can still have multiple overlapping substitutions / possible edits, we just don't suggest overlapping replacements in a single edit anymore.

I've also included a fix for an unrelated bug where rustfix for `explicit_outlives_requirements` would produce multiple trailing commas for a where clause.
  • Loading branch information
bors committed Jan 28, 2023
2 parents 06e7855 + 10c8686 commit 3a68217
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clippy_lints/src/format_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ fn check_uninlined_args(
// in those cases, make the code suggestion hidden
let multiline_fix = fixes.iter().any(|(span, _)| cx.sess().source_map().is_multiline(*span));

// Suggest removing each argument only once, for example in `format!("{0} {0}", arg)`.
fixes.sort_unstable_by_key(|(span, _)| *span);
fixes.dedup_by_key(|(span, _)| *span);

span_lint_and_then(
cx,
UNINLINED_FORMAT_ARGS,
Expand Down

0 comments on commit 3a68217

Please sign in to comment.