Stream: wg-traits

Topic: specialization first step chalk#219


nikomatsakis (May 03 2019 at 19:01, on Zulip):

So I created an issue chalk#219 to describe some simple first steps on specialization. @Sunjay Varma, you've previously expressed interest -- and this is indeed quite similar to the work you did on coherence earlier. Take a look.

Sunjay Varma (May 03 2019 at 19:02, on Zulip):

Perfect. I was just about to start this today. I'll take a look :)

nikomatsakis (May 03 2019 at 19:02, on Zulip):

I realize that I left some bits out -- like how do we determine if impl A specializes impl B

Sunjay Varma (May 03 2019 at 19:03, on Zulip):

(That's actually true I have a task for it :joy:) pasted image

Sunjay Varma (May 03 2019 at 19:04, on Zulip):

I realize that I left some bits out -- like how do we determine if impl A specializes impl B

Are you going to add this to the issue or should we meet at some point (not today) to discuss everything?

nikomatsakis (May 03 2019 at 19:10, on Zulip):

I can add some notes; the TL;dr is that we have some Code for this, and i'd mostly like to 'ignore it' to start

nikomatsakis (May 03 2019 at 19:10, on Zulip):

i.e., add some hacky sol'n if needed

nikomatsakis (May 03 2019 at 19:10, on Zulip):

then circle back to it

nikomatsakis (May 03 2019 at 19:10, on Zulip):

(like you could imagine that we just hard-code it for now in some way, in the limit)

Sunjay Varma (May 03 2019 at 19:14, on Zulip):

Are you talking about the code we discussed in that meeting we had a few months ago?

Sunjay Varma (May 03 2019 at 19:14, on Zulip):

Here's the doc for that: https://paper.dropbox.com/doc/Chalk-and-Specialization--AcYohtaLoeyk9kvGWaqEYnoOAg-urrCptcGmI7PA4pYaF5yn

Sunjay Varma (May 03 2019 at 19:22, on Zulip):

So it looks like chalk doesn't support the default keyword yet

Sunjay Varma (May 03 2019 at 19:22, on Zulip):

Would a good step (in addition to the design) be to add support for that?

Sunjay Varma (May 03 2019 at 19:25, on Zulip):

Oh actually it looks like we don't even support trait methods?

Sunjay Varma (May 03 2019 at 19:25, on Zulip):

Maybe I'm reading the code wrong...

Sunjay Varma (May 03 2019 at 19:25, on Zulip):
Impl: Impl = {
    <external:UpstreamKeyword?> "impl" <p:Angle<ParameterKind>> <mark:"!"?> <t:Id> <a:Angle<Parameter>> "for" <s:Ty>
        <w:QuantifiedWhereClauses> "{" <assoc:AssocTyValue*> "}" =>
Sunjay Varma (May 03 2019 at 19:26, on Zulip):

It looks like we only parse associated types within the curly braces of an impl

Sunjay Varma (May 03 2019 at 19:26, on Zulip):

@nikomatsakis do you think it's necessary for chalk to have support for all of this in order to add specialization? Or maybe you want to mark impls as default instead?

Sunjay Varma (May 03 2019 at 19:27, on Zulip):

That might mess up the semantics

Sunjay Varma (May 03 2019 at 19:27, on Zulip):

/me needs to read the RFC and blog posts again :joy:

Sunjay Varma (May 03 2019 at 19:28, on Zulip):

Yeah I definitely think we need to add default type and default fn to chalk

Sunjay Varma (May 03 2019 at 19:28, on Zulip):

Looking at the documents we need that in order for any of this to be tested within chalk

Sunjay Varma (May 03 2019 at 19:30, on Zulip):

From https://github.com/rust-lang/chalk/issues/219 :

Specialization does not effect whether or not a trait is implemented. Therefore, the "lowering" for an impl ought to be unaffected -- overlapping impls simply mean more than one way to prove the same set of types, and the solver ought to be able to handle that.

Maybe I'm misunderstanding, but I disagree. Isn't the default keyword required for specialization to even be considered? This should affect things or else we risk every impl being specialized even when that isn't intended.

nikomatsakis (May 03 2019 at 19:43, on Zulip):

I don't believe that it needs to effect whether or not the Implemented predicate is satisfied

nikomatsakis (May 03 2019 at 19:43, on Zulip):

It will certainly effect the coherence rules that get enforced

nikomatsakis (May 03 2019 at 19:43, on Zulip):

Given that two impls overlap, you have to determine if they are allowed to overlap, and that question is affected by whether default is supplied

nikomatsakis (May 03 2019 at 19:44, on Zulip):

Oh actually it looks like we don't even support trait methods?

trait methods aren't particularly relevant

nikomatsakis (May 03 2019 at 19:44, on Zulip):

So it looks like chalk doesn't support the default keyword yet

yes, good point, we should probably add that first, yes. it would be applied to associated types, at least to start

nikomatsakis (May 03 2019 at 19:45, on Zulip):

I didn't get as far, in that issue, as specifying concrete steps...let's see...

nikomatsakis (May 03 2019 at 19:54, on Zulip):

/me needs to read the RFC and blog posts again :joy:

BTW, @Sunjay Varma, I think that -- for the purposes of this first step -- the blog posts are mostly not relevant. They will become relevant later on. They basically define rules that we can enforce that specify when specialization is legal -- but this first step is more focused on what to do if you have specialization (and we assume it's legal for now).

nikomatsakis (May 03 2019 at 19:55, on Zulip):

But re-reading the RFC seems good

Sunjay Varma (May 03 2019 at 20:22, on Zulip):

But re-reading the RFC seems good

Doing that now :)

Sunjay Varma (May 03 2019 at 20:30, on Zulip):

@nikomatsakis Do you want the default flag in AssociatedTyValue? I've added it to the parser/AST but maybe I should wait to add it to other things

Sunjay Varma (May 03 2019 at 20:36, on Zulip):

@nikomatsakis This should be very easy to review: https://github.com/rust-lang/chalk/pull/221

nikomatsakis (May 04 2019 at 10:25, on Zulip):

Do you want the default flag in AssociatedTyValue? I've added it to the parser/AST but maybe I should wait to add it to other things

This is the first place; I'm not worrying about modeling default impls yet (they are kind of a different thing...) but eventually we'll probably want to do that, too

Last update: Nov 12 2019 at 15:35UTC