lifetime elision for return type can refer to an explicitly named region #121152
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lifetimes
Area: Lifetimes / regions
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
D-newcomer-roadblock
Diagnostics: Confusing error or lint; hard to understand for new users.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
Originally posted by @danielhenrymantilla in #117967 (comment)
I would nonetheless like to take this opportunity to talk a bit about:
Aside: edge cases of lifetime elision rules which are confusing
There are two slightly related aspects which can make lifetime elision rules (w.r.t. the output elided lifetime) be rather confusing, or poorly readable.
'_
can "connect"/match an input explicitly named lifetime "parameter".'static
hard-coded / fixed value)!To illustrate, consider:
I personally find the capability of type aliases or
Self
aliases to affect semantics (here, those of lifetime elision rules) to be appaling.It would thus be nice if certain efforts were made to try and go in the other directions, e.g., by linting whenever an output-elided lifetime (
'_
-explicitly, or implicitly) happens to match an explicitly named input lifetime param, and even more so when this input lifetime "param" is'static
or stems from an outer scope.The text was updated successfully, but these errors were encountered: