@@ -381,17 +381,6 @@ impl CodeSuggestion {
381381 // Assumption: all spans are in the same file, and all spans
382382 // are disjoint. Sort in ascending order.
383383 substitution. parts . sort_by_key ( |part| part. span . lo ( ) ) ;
384- // Verify the assumption that all spans are disjoint
385- assert_eq ! (
386- substitution. parts. array_windows( ) . find( |[ a, b] | a. span. overlaps( b. span) ) ,
387- None ,
388- "all spans must be disjoint" ,
389- ) ;
390-
391- // Account for cases where we are suggesting the same code that's already
392- // there. This shouldn't happen often, but in some cases for multipart
393- // suggestions it's much easier to handle it here than in the origin.
394- substitution. parts . retain ( |p| is_different ( sm, & p. snippet , p. span ) ) ;
395384
396385 // Find the bounding span.
397386 let lo = substitution. parts . iter ( ) . map ( |part| part. span . lo ( ) ) . min ( ) ?;
@@ -481,12 +470,16 @@ impl CodeSuggestion {
481470 _ => 1 ,
482471 } )
483472 . sum ( ) ;
484-
485- line_highlight. push ( SubstitutionHighlight {
486- start : ( cur_lo. col . 0 as isize + acc) as usize ,
487- end : ( cur_lo. col . 0 as isize + acc + len) as usize ,
488- } ) ;
489-
473+ if !is_different ( sm, & part. snippet , part. span ) {
474+ // Account for cases where we are suggesting the same code that's already
475+ // there. This shouldn't happen often, but in some cases for multipart
476+ // suggestions it's much easier to handle it here than in the origin.
477+ } else {
478+ line_highlight. push ( SubstitutionHighlight {
479+ start : ( cur_lo. col . 0 as isize + acc) as usize ,
480+ end : ( cur_lo. col . 0 as isize + acc + len) as usize ,
481+ } ) ;
482+ }
490483 buf. push_str ( & part. snippet ) ;
491484 let cur_hi = sm. lookup_char_pos ( part. span . hi ( ) ) ;
492485 // Account for the difference between the width of the current code and the
0 commit comments