Skip to content

Commit 44ddbf7

Browse files
committed
simplified the structure of this proposal
1 parent 1bcf57c commit 44ddbf7

File tree

1 file changed

+22
-38
lines changed

1 file changed

+22
-38
lines changed

src/2025h2/autoreborrow-traits.md

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,26 @@ An improvement is needed.
6161
- Gather feedback from users, especially `reborrow` crate users.
6262
- Implement nightly support for recursive reborrowing.
6363

64+
65+
The basic idea of autoreborrowing is simple enough: when a reborrowable type is encountered at a coercion
66+
site, attempt a reborrow operation. The `Pin<&mut T>` special-case in the
67+
compiler already exists and could probably be reimagined to rely on a `Reborrow` trait.
68+
69+
Complications arise when reborrowing becomes recursive: if a `struct X { a: A, b: B }` contains two
70+
reborrowable types `A` and `B`, then we'd want the reborrow of `X` to be performed "piecewise". As an
71+
example, the following type should, upon reborrow, only invalidate any values that depend on the `'a` lifetime while any values dependent on the `'b` lifetime should still be usable as normal.
72+
73+
```rust
74+
struct X<'a, 'b> {
75+
a: &'a mut A,
76+
b: &'b B,
77+
}
78+
```
79+
80+
To enable this, reborrowing needs to be defined as a recursive operation but what the "bottom-case" is, that
81+
is the question. One option would be to use `!Copy + Reborrow` fields, another would use core marker types
82+
like `PhantomExclusive<'a>` and `PhantomShared<'b>` to discern the difference.
83+
6484
### The "shiny future" we are working towards
6585

6686
`Pin` ergonomics group should be able to get rid of special-casing of `Pin` reborrowing in rustc.
@@ -90,48 +110,12 @@ Users of `reborrow` crate and similar should be enabled to move to core solution
90110

91111
## Ownership and team asks
92112

113+
93114
| Task | Owner(s) or team(s) | Notes |
94115
| ---------------------------- | -------------------- | ------------------------------------------------------------------ |
95116
| Discussion and moral support | ![Team][] [lang] | Normal RFC process |
96117
| Standard reviews | ![Team][] [compiler] | Trait-impl querying in rustc to replace `Pin<&mut T>` special case |
118+
| Lang-team experiment | ![Team][] [lang] | allows coding pre-RFC; only for trusted contributors |
97119
| Do the work | @aapoalas | |
98120

99-
### Experiment with Reborrow trait design
100-
101-
The basic idea of autoreborrowing is simple enough: when a reborrowable type is encountered at a coercion
102-
site, attempt a reborrow operation.
103-
104-
Complications arise when reborrowing becomes recursive: if a `struct X { a: A, b: B }` contains two
105-
reborrowable types `A` and `B`, then we'd want the reborrow of `X` to be performed "piecewise". As an
106-
example, the following type should, upon reborrow, only invalidate any values that depend on the `'a` lifetime while any values dependent on the `'b` lifetime should still be usable as normal.
107-
108-
```rust
109-
struct X<'a, 'b> {
110-
a: &'a mut A,
111-
b: &'b B,
112-
}
113-
```
114-
115-
To enable this, reborrowing needs to be defined as a recursive operation but what the "bottom-case" is, that
116-
is the question. One option would be to use `!Copy + Reborrow` fields, another would use core marker types
117-
like `PhantomExclusive<'a>` and `PhantomShared<'b>` to discern the difference.
118-
| Task | Owner(s) or team(s) | Notes |
119-
| -------------------- | ---------------------------------- | ------------------------------------------------------------------- |
120-
| Lang-team experiment | ![Team][] [lang] | allows coding pre-RFC; only for trusted contributors |
121-
| Author RFC | *Goal point of contact, typically* | |
122-
| RFC decision | ![Team][] [lang] | |
123-
| RFC secondary review | ![Team][] [types] | request bandwidth from a second team, most features don't need this |
124-
125-
### Seek feedback for an RFC based on experiment
126-
127-
A basic autoreborrowing feature should not be too complicated: the `Pin<&mut T>` special-case in the
128-
compiler already exists and could probably be reimagined to rely on a `Reborrow` trait.
129-
130-
| Task | Owner(s) or team(s) | Notes |
131-
| --------------------------------- | ---------------------------------- | ----- |
132-
| Implementation | *Goal point of contact, typically* | |
133-
| Standard reviews | ![Team][] [compiler] | |
134-
| Design meeting | ![Team][] [lang] | |
135-
| Author call for testing blog post | *Goal point of contact, typically* | |
136-
137121
## Frequently asked questions

0 commit comments

Comments
 (0)