-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Description
This is a tracking issue for the lang experiment into a Reborrow trait and its dual CoerceShared trait.
The feature gate for the issue is #![feature(reborrow)]
.
For more information, see the 2025H2 project goal and the draft RFC.
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.
Steps
- Land a feature gate, and possibly an empty trait.
- Land an empty Reborrow trait.
- Land an empty CoerceShared trait.
- Land a test battery for Reborrow trait.
- Land a test battery for CoerceShared trait.
- Implement the Reborrow trait internals (probably a rustc builtin macro)
- Implement the CoerceShared trait internals (ditto)
- Start the RFC process based on the learnings
Unresolved Questions
The implementation of the Reborrow trait is likely something like this:
struct Example<'a, 'b> {
a: A<'a>,
b: B<'b>
}
fn reborrow(e: Example) {
let Example { a, b } = e;
reborrow(Example { a, b });
}
This allows the compiler to see the individual field usages and, eventually, enables the correct lifetimes to be "used as exclusive". But the question is; where does this bottom out? Is any field that implements Reborrow
(but not Copy
, if Reborrow
is blanket-implemented for Copy
types) a point where the recursion into structs stops? That stops composing of reborrowable types to a depth of 2. Is a PhantomReborrowable<'a>
marker type needed? If so, then what is the variance of the lifetime there?
Implementation history
Metadata
Metadata
Assignees
Labels
Type
Projects
Status