It is recommended to increase the default lifetimes

TBH, I do think that the elision rules could do with some tweaks. For example, it's unclear to me whether the ones for trait objects are a net win (Consider re-tuning the lifetime elision rules for trait objects · Issue #91302 · rust-lang/rust · GitHub), and cramertj has previously brought up another weirdness (Elision in method can take `'static` from `self`, perhaps surprising · Issue #48686 · rust-lang/rust · GitHub). Another thing that comes to mind is that perhaps we should tweak elision for -> Ref<'_, &Foo> functions because with two lifetimes it's not obvious that things like the "just take it from self" rule make sense.

Elision rules are exactly the kind of thing we can tweak in an edition -- the migration lint can always just write them out in full, if necessary -- so I'd love to see an RFC show up with an analysis of a bunch of cases where they're more confusing than helpful, and a corresponding set of more restricted elision rules to apply in the 2024 edition.

10 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.