Closed
Description
This is a sub-issue of #44524, tracking the desire to stabilize '_
(and the lints around its usage).
Covered areas
The '_
can be used anywhere that a region can be elided. It (typically) carries the same meaning as having no region at all. This section summarizes its usage, giving pointers to tests, and also listing known blocking issues.
fn foo(x: Ref<'_>)
-- fresh namefn foo(&self) -> Ref<'_>
-- links toself
fn foo(&self) -> Box<dyn Debug + '_>
-- links toself
, not quite the same asBox<dyn Debug>
fn foo(&self) -> Box<impl Debug + '_>
-- links toself
, not quite the same asBox<impl Debug>
Some areas where elision ought to be supported are not yet:
impl Foo for Ref<'_>
-- not yet implemented, this is Tracking issue for lifetime elision for impl headers (feature impl_header_lifetime_elision) #15872where T: Trait<'_>
-- not yet implemented, this is enable elision in where-clauses on functions #45667- also, what semantics are desired here? Where is the binder?
There are also several linted scenarios to nudge the user in the right direction:
- Eliding parameters of a lifetime-parameterized struct (e.g.,
Ref
) is deprecated, preferRef<'_>
#[warn(elided_lifetimes_in_paths)]
- blocked on
elided_lifetime_in_path
triggers for theformat!
macro #48385 -- triggers forformat!
- Lifetime names used only once are deprecated:
#[warn(single_use_lifetime)]
- blocked on In-band lifetimes: Lint against single-use lifetime names #44752 -- only partially impemented
Changes or clarifications to the RFC
The behavior around dyn Trait
is probably worth highlighting, since it is one case where '_
differs from writing nothing at all.
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
nikomatsakis commentedon Mar 8, 2018
@rfcbot fcp merge
I want to propose that we stabilize
'_
, with the semantics as given in the header of this post. Note however that there are some blocking issues that must be resolved (cited in the header) before stabilization can actually occur. But those don't need to block us making the decision to stabilize.rfcbot commentedon Mar 8, 2018
Team member @nikomatsakis has proposed to merge this. The next step is review by the rest of the tagged teams:
No concerns currently listed.
Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
See this document for info about what commands tagged team members can give me.
rfcbot commentedon Mar 14, 2018
🔔 This is now entering its final comment period, as per the review above. 🔔
rfcbot commentedon Mar 24, 2018
The final comment period is now complete.
steveklabnik commentedon Apr 4, 2018
was this closed by #49458 ?
nikomatsakis commentedon Apr 5, 2018
Seems like...yes.