Skip to content

Commit 3a68217

Browse files
committed
Auto merge of rust-lang#106916 - lukas-code:overlapping-substs, r=estebank
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#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.
2 parents 06e7855 + 10c8686 commit 3a68217

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

clippy_lints/src/format_args.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ fn check_uninlined_args(
311311
// in those cases, make the code suggestion hidden
312312
let multiline_fix = fixes.iter().any(|(span, _)| cx.sess().source_map().is_multiline(*span));
313313

314+
// Suggest removing each argument only once, for example in `format!("{0} {0}", arg)`.
315+
fixes.sort_unstable_by_key(|(span, _)| *span);
316+
fixes.dedup_by_key(|(span, _)| *span);
317+
314318
span_lint_and_then(
315319
cx,
316320
UNINLINED_FORMAT_ARGS,

0 commit comments

Comments
 (0)