Nest the impl Trait existential item inside the return type#54741
Nest the impl Trait existential item inside the return type#54741bors merged 2 commits intorust-lang:masterfrom
impl Trait existential item inside the return type#54741Conversation
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
Nice! @bors r+ |
|
📌 Commit c3151c6 has been approved by |
|
☀️ Test successful - status-appveyor, status-travis |
| /// | ||
| /// The generic arg list are the lifetimes (and in the future possibly parameters) that are | ||
| /// actually bound on the `impl Trait`. | ||
| Def(ItemId, HirVec<GenericArg>), |
There was a problem hiding this comment.
I want something like this in general, maybe {...} block syntax for types?
Then -> impl Trait would be -> { existential type X: Trait; X }.
cc @Centril @nikomatsakis
There was a problem hiding this comment.
In other words this would be legal?
type Foo = { u8 };Not sure why it is useful tho...
There was a problem hiding this comment.
isn't that essentially generic modules? (but unnamed)
There was a problem hiding this comment.
I guess only if you can depend on parameters in scope.
which impl trait always does
There was a problem hiding this comment.
@eddyb in exprs it exists for some sort of encapsulation purposes... I suppose you could do some sort of encapsulation of type aliases... but we should tread carefully here, there might be ambiguity in store.
PS: we should move this conversation elsewhere into a fresh issue / internals instead of comments on a merged PR (totally not discoverable...).
There was a problem hiding this comment.
I suppose you could do some sort of encapsulation of type aliases
Module-based encapsulation is how existential type X: Trait; works today.
There was a problem hiding this comment.
@cramertj I meant something like this:
type Foo = {
type ComplexType = Bar<Baz<u8>>;
Vec<ComplexType>
};
fixes #54045
r? @cramertj