Implement associated existential types#52650
Conversation
|
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 |
src/librustc/infer/anon_types/mod.rs
Outdated
There was a problem hiding this comment.
I guess one of the wacky -- but perhaps .. fine -- consequences of this is that one could do something like
impl Foo for Bar {
existential type Item;
fn method() {
fn helper() -> <Bar as Foo>::Item { .. }
}and that helper fn might count as a defining use?
I feel like we should only allow other members of the impl to be a defining use.
There was a problem hiding this comment.
Not allowing this kind of defining use would be inconsistent with how normal existential types work.
There was a problem hiding this comment.
I don't see it as particularly inconsistent — depends on your POV, I suppose. It seems to me that the various "sugared forms" (e.g., impl Trait) don't desugar directly to an existential type "sibling item", because they have different sets of defining uses... in the case of a function, only the fn return type in question. In the case of an impl, we get to decide?
For that matter, I do wonder if we would rather have the syntax here be type Item = impl Foo.
(cc @cramertj on this particular question)
There was a problem hiding this comment.
I'm ok landing either way, but I would want to open an unresolved question on this point
There was a problem hiding this comment.
yea the syntax is horrible on purpose. It's the only one everyone could agree on that we do not want.
There was a problem hiding this comment.
I added two unresolved questions to the tracking issue. Dear god I hope they won't get lost. =)
There was a problem hiding this comment.
IMO it's fine for helper to be a defining use of Item because it's "in the scope" of Item's definition (in this case, the trait impl).
There was a problem hiding this comment.
Was there another discussion on syntax? Two points:
- sometimes there are no constraints: but
type Item;is of course ambiguous - "existential" is not really the correct term (mathematically it means "there exists at least one such ..."); really we just mean "indirectly specified"
So possibly indirect type Item; or unspec type Item; ?
There was a problem hiding this comment.
This implemented the placeholder syntax from the RFC. Please check out the discussion on the tracking issue and follow up RFCs. The syntax has been heavily discussed there and is currently being RFCed as type Item = impl Trait;. So if you disagree with the proposed syntax or otherwise have opinions on this topic, bring it up on that RFC.
src/librustc/traits/project.rs
Outdated
There was a problem hiding this comment.
huh, something looks fishy here -- you are using substs as part of ty in this case...
There was a problem hiding this comment.
yea, I'm gonna add some generics tests and do this properly
src/librustc/traits/project.rs
Outdated
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
I'd prefer to see this spelled out:
e.g., (Const, _) | (Method, _) | (Type, _) etc
this way when new kinds are added, we won't overlook them
65e016b to
01eacd8
Compare
|
@bors r+ |
|
📌 Commit 33712a8 has been approved by |
|
⌛ Testing commit 33712a8 with merge f1ecabf25ee6d7fc4a607e2e820013b8bf8619a1... |
|
💔 Test failed - status-travis |
|
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 |
|
@bors retry |
|
⌛ Testing commit 33712a8 with merge c82d35770ac9d4b53bb93247456206c003c5e4e8... |
|
💔 Test failed - status-travis |
|
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 |
…tsakis Implement associated existential types r? @nikomatsakis no idea if these work with generic traits. I'm going home for the day 🤣
|
☀️ Test successful - status-appveyor, status-travis |
r? @nikomatsakis
no idea if these work with generic traits. I'm going home for the day 🤣