Closed
Description
I think a lint for code of the following form would be useful:
fn foo<'a>(x: &'a str) -> &'a str {
x
}
This function signature contains explicit lifetimes which can be inferred by the compiler. I imagine that the lint would emit something like the following:
warning: unnecesary lifetime annotations
fn foo<'a>(x: &'a str) -> &'a str {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: signature can be written as follows:
fn foo(x: &str) -> &str {
Perhaps the suggested signature bit would be tricky. I also have no opinion regarding whether or not this lint would be on or off by default.