+ );
+ if let Some(parent_def_id) = self.tcx.parent(def_id) {
+ if let Some(node_id) = self.tcx.hir.as_local_node_id(parent_def_id) {
+ if let Some(Node::Item(hir_item)) = self.tcx.hir.find(node_id) {
+ match hir_item.node {
+ hir::ItemKind::Fn(_, _, ref generics, _) |
+ hir::ItemKind::Impl(_, _, _, ref generics, _, _, _) => {
+ let unused_lt_span = if generics.params.len() == 1 {
+ // if sole lifetime, remove the `<>` brackets
+ Some(generics.span)
+ } else {
+ generics.params.iter().enumerate()
+ .find_map(|(i, param)| {
+ if param.name.ident() == name {
+ // We also want to delete a leading or
+ // trailing comma as appropriate
+ if i >= generics.params.len() - 1 {
+ Some(
+ generics.params[i-1]
+ .span.shrink_to_hi()
+ .to(param.span)
+ )
+ } else {
+ Some(
+ param.span.to(
+ generics.params[i+1]
+ .span.shrink_to_lo()
+ )
+ )
+ }
+ } else {
+ None
+ }
+ })
+ };
+ if let Some(span) = unused_lt_span {
+ err.span_suggestion_with_applicability(
+ span,
+ "remove it",
+ String::new(),
+ Applicability::MachineApplicable
+ );
+ }
+ },
+ _ => {}
+ }
+ }
+ }
+ }
+ err.emit();