Skip to content

RS-LIFE0001 · elidable_lifetime_annotation

Count lifetime annotations the compiler would have inferred on its own.

This is a deterministic rule for rust. Read its implementation.

Read every signature that names a lifetime and report one whose elided form means exactly the same thing. Elision gives each input lifetime position its own fresh lifetime and gives every elided output the receiver’s lifetime, so an annotation restating that tells the reader nothing the compiler did not already know and charges them the reading anyway.

The cost is not the character count. A signature carrying <'a> reads as a signature with a borrowing constraint worth understanding, so the reader stops and works out which one. Doing that and finding nothing is worse than never having stopped.

Two arrangements are claimed and both are settled by the signature alone. A lifetime written in exactly one input position and read nowhere else is one elision produces identically. A lifetime the receiver carries and the return states is another, since elision hands every elided output the receiver’s lifetime whatever else is in scope.

Continue with evidence and references, or open the examples.