Open
Description
Tracking issue for rust-lang/rfcs#66: better temporary lifetimes.
Some unresolved questions to be settled when implementing:
- This implies that the lifetimes of temporaries is not known until after typeck. I think this is ok but it is a phase change which can sometimes be tricky (currently temporary lifetimes are known before typeck).
- We have to specify the precise rules over when a temporary is extended. There are various subtle cases to be considered:
- Clearly we must consider whether the parameter type is a reference with a lifetime that also appears in the return type. Does the variance in the return type matter? (I think: no, too subtle and not worth it.)
- When do we decide what the type of the parameter is? Do we consider the declared type, the type after inference, or a hybrid?
Some examples where this matters:
fn identity<T>(x: T) -> T { x }
// Are these the same or different?
foo(&3);
foo::<&int>(&3);
My take: Probably we should just consider the fully inferred type.
Unresolved questions
- Resolve the concern about semantic changes described in comment.
Metadata
Metadata
Assignees
Labels
Area: Lifetimes / regionsBlocker: Approved by a merged RFC but not yet implemented.Category: An issue tracking the progress of sth. like the implementation of an RFCStatus: There are blocking design concerns.Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.