Add lint for unused lifetimes

A step towards  #12805.
The ` $ty` in this macro caused problems for the lint. Is there any better way of dealing with this other than just ignoring it?