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
We had added an RPITIT desugaring that was rather complicated. This
complication was due to trying to explain what it would mean to not
capture generic parameters that are part of the trait header.
However, it's likely that there's no good way to express that semantic
in the surface syntax. Let's instead simplify the desugaring and make
a note of its limitations.
@@ -207,7 +207,7 @@ The [syntax for `impl Trait`][] is revised and extended as follows:
207
207
208
208
## Reference desugarings
209
209
210
-
The desugarings that follow can be used to answer questions about how `use<..>` is expected to work with respect to the capturing of generic parameters in opaque types.
210
+
The desugarings that follow can be used to answer questions about how `use<..>` is expected to work with respect to the capturing of generic parameters.
211
211
212
212
### Reference desugaring for `use<..>` in RPIT
213
213
@@ -275,126 +275,31 @@ mod _0 {
275
275
276
276
### Reference desugaring for `use<..>` in RPITIT
277
277
278
-
Similarly, we can describe the semantics of `use<..>` in return position `impl Trait` in trait (RPITIT) using anonymous associated types and ATPIT. If we consider the following code:
278
+
Similarly, we can describe the semantics of `use<..>` in return position `impl Trait` in trait (RPITIT) using anonymous associated types. If we consider the following code:
Then we can desugar this as follows, without the use of `use<..>`specifiers, while preserving equivalent semantics with respect to the capturing of generic parameters:
289
+
Then we can desugar this as follows, without the use of a `use<..>`specifier, while preserving equivalent semantics with respect to the capturing of generic parameters:
// These are the arguments given to the `use<..>` specifier.
395
298
}
396
299
```
397
300
301
+
Note that this desugaring does not allow for removing from the `use<..>` specifier `Self` or any generics that are input parameters to the trait. This is, in fact, an implementation restriction that is likely to be part of initial rounds of stabilization.
302
+
398
303
## Avoiding capture of higher ranked lifetimes in nested opaques
399
304
400
305
According to the Lifetime Capture Rules 2024, a nested `impl Trait` opaque type *must* capture all generic parameters in scope, including higher ranked ones. However, for implementation reasons, Rust does not yet support higher ranked lifetime bounds on nested opaque types (see [#104288][]). Therefore, in Rust 2024, this code, which is valid in Rust 2021, fails to compile:
0 commit comments