I have this proto-RFC to disallow lifetime shadowing. But now it occurs to me this might be better done with a lint. I am curious to get people’s opinions on the matter.
I’m okay with it being an error, and if a use case for shadowed parameters is found then it could be relaxed.
(especially if it’s easier to implement it this way.)
+1 to this RFC, it feels consistent to make it an error, since we already forbid shadowing types/traits at the module level. And with associated items, traits and impls will look more like modules.
Slightly on topic, should we also forbid/lint name clashes between generic input parameters (types/lifetimes) and associated output types/lifetimes? We don’t yet know how troublesome this may be in practice, since AI is still WIP, but it’s something to think about.
I’m okay with either, but I would prefer having an error since it’s better for backwards compatibility – we can change it back if we want, but not if we lint it.
I really like this, and would be very fine with it being an error as well. Lifetime parameters idiomatically have one-letter names, and the have a wide-scope, so this would certainly be a win in my book.
On a related note, I’ve seen many people trip up with non-lifetime type parameter shadowing as well (the often seen “Found T but expected T” error).