@@ -400,17 +400,6 @@ impl CodeSuggestion {
400400 // Assumption: all spans are in the same file, and all spans
401401 // are disjoint. Sort in ascending order.
402402 substitution. parts . sort_by_key ( |part| part. span . lo ( ) ) ;
403- // Verify the assumption that all spans are disjoint
404- assert_eq ! (
405- substitution. parts. array_windows( ) . find( |[ a, b] | a. span. overlaps( b. span) ) ,
406- None ,
407- "all spans must be disjoint" ,
408- ) ;
409-
410- // Account for cases where we are suggesting the same code that's already
411- // there. This shouldn't happen often, but in some cases for multipart
412- // suggestions it's much easier to handle it here than in the origin.
413- substitution. parts . retain ( |p| is_different ( sm, & p. snippet , p. span ) ) ;
414403
415404 // Find the bounding span.
416405 let lo = substitution. parts . iter ( ) . map ( |part| part. span . lo ( ) ) . min ( ) ?;
@@ -505,12 +494,16 @@ impl CodeSuggestion {
505494 _ => 1 ,
506495 } )
507496 . sum ( ) ;
508-
509- line_highlight. push ( SubstitutionHighlight {
510- start : ( cur_lo. col . 0 as isize + acc) as usize ,
511- end : ( cur_lo. col . 0 as isize + acc + len) as usize ,
512- } ) ;
513-
497+ if !is_different ( sm, & part. snippet , part. span ) {
498+ // Account for cases where we are suggesting the same code that's already
499+ // there. This shouldn't happen often, but in some cases for multipart
500+ // suggestions it's much easier to handle it here than in the origin.
501+ } else {
502+ line_highlight. push ( SubstitutionHighlight {
503+ start : ( cur_lo. col . 0 as isize + acc) as usize ,
504+ end : ( cur_lo. col . 0 as isize + acc + len) as usize ,
505+ } ) ;
506+ }
514507 buf. push_str ( & part. snippet ) ;
515508 let cur_hi = sm. lookup_char_pos ( part. span . hi ( ) ) ;
516509 // Account for the difference between the width of the current code and the
0 commit comments