You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/2025h2/autoreborrow-traits.md
+22-38Lines changed: 22 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,6 +61,26 @@ An improvement is needed.
61
61
- Gather feedback from users, especially `reborrow` crate users.
62
62
- Implement nightly support for recursive reborrowing.
63
63
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
+
structX<'a, 'b> {
75
+
a:&'amutA,
76
+
b:&'bB,
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
+
64
84
### The "shiny future" we are working towards
65
85
66
86
`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
| Discussion and moral support |![Team][][lang]| Normal RFC process |
96
117
| 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 |
97
119
| Do the work |@aapoalas||
98
120
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
-
structX<'a, 'b> {
110
-
a:&'amutA,
111
-
b:&'bB,
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.
0 commit comments