Skip to content

Commit e7e26ea

Browse files
committed
Clarify multiple impl Trait semantics
1 parent b02be50 commit e7e26ea

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

text/0000-impl-trait-type-aliases.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,18 @@ The other alternatives commonly given are:
398398
[unresolved-questions]: #unresolved-questions
399399

400400
- The restriction of type alias `impl Trait` to the forms that are currently possible with `existential trait` is potentially unnecessary. Although this was proposed to simplify the RFC by only changing syntax, it could be a better choice to allow `impl Trait` anywhere in a type alias (by desugaring each occurrence into a separate inferred type).
401+
402+
In this case, each occurrence of `impl Trait` would be desugared to a new existential type. For example,
403+
the following alias:
404+
405+
```rust
406+
type Foo = Arc<impl Iterator<Item = impl Debug>>;
407+
```
408+
409+
would be desugared to the equivalent of:
410+
411+
```rust
412+
existential type _0: Debug;
413+
existential type _1: Iterator<Item = _0>;
414+
type Foo = Arc<_1>;
415+
```

0 commit comments

Comments
 (0)