@@ -863,20 +863,28 @@ fn elision_suggestions(
863863 // ^^^^
864864 vec ! [ ( generics. span, String :: new( ) ) ]
865865 } else {
866+ let mut end: Option < LocalDefId > = None ;
866867 elidable_lts
867868 . iter ( )
869+ . rev ( )
868870 . map ( |& id| {
869- let pos = explicit_params. iter ( ) . position ( |param| param. def_id == id) ?;
870- let param = explicit_params. get ( pos) ?;
871+ let ( idx, param) = explicit_params. iter ( ) . find_position ( |param| param. def_id == id) ?;
871872
872- let span = if let Some ( next) = explicit_params. get ( pos + 1 ) {
873+ let span = if let Some ( next) = explicit_params. get ( idx + 1 )
874+ && end != Some ( next. def_id )
875+ {
876+ // Extend the current span forward, up until the next param in the list.
873877 // fn x<'prev, 'a, 'next>() {}
874878 // ^^^^
875879 param. span . until ( next. span )
876880 } else {
877- // `pos` should be at least 1 here, because the param in position 0 would either have a `next`
878- // param or would have taken the `elidable_lts.len() == explicit_params.len()` branch.
879- let prev = explicit_params. get ( pos - 1 ) ?;
881+ // Extend the current span back to include the comma following the previous
882+ // param. If the span of the next param in the list has already been
883+ // extended, we continue the chain. This is why we're iterating in reverse.
884+ end = Some ( param. def_id ) ;
885+
886+ // `idx` will never be 0, else we'd be removing the entire list of generics
887+ let prev = explicit_params. get ( idx - 1 ) ?;
880888
881889 // fn x<'prev, 'a>() {}
882890 // ^^^^
0 commit comments