Tracking Issue for Reborrow trait lang experiment
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
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 https://github.com/rust-lang/rust-project-goals/issues/399.
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 basic Reborrow trait usage.
- Land a test battery for basic CoerceShared trait usage
- Land a test battery for complex Reborrow trait usage.
- Land a test battery for complex CoerceShared trait usage.
- 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with rust-lang/rust-project-goals#399 and the #![feature(reborrow)] tracking issue; review the completed implementation and test-battery checklist alongside the unresolved recursion and variance questions. Done means starting the RFC process based on the feature's learnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100