Stream: wg-traits

Topic: chalk#176


nikomatsakis (Oct 09 2018 at 13:45, on Zulip):

I was wondering @scalexm if you wanted to discuss chalk#176

scalexm (Oct 09 2018 at 13:47, on Zulip):

yes

nikomatsakis (Oct 09 2018 at 13:50, on Zulip):

https://appear.in/i-heart-rust

scalexm (Oct 17 2018 at 13:06, on Zulip):

@nikomatsakis I've been pondering for a while, but I fear the way I changed the rule regarding implied bounds on assoc types is too restrictive

scalexm (Oct 17 2018 at 13:06, on Zulip):

here is an example where it is not expressive enough: https://gist.github.com/rust-play/f5710ea680dabc7ec2b15888a70b83d0

scalexm (Oct 17 2018 at 13:10, on Zulip):

(for having things back in cache)

trait Foo {
    type Item<...>: Bound where WC;
}

// old rule: `FromEnv(<Self as Foo>::Item<...>: Bounds) :- FromEnv(Self: Foo)`
// new rule after #176: `FromEnv(<Self as Foo>::Item<...>: Bounds) :- FromEnv(Self: Foo), FromEnv(WC)`
nikomatsakis (Oct 17 2018 at 13:11, on Zulip):

@scalexm it looks like your "new rule" is cutoff

nikomatsakis (Oct 17 2018 at 13:12, on Zulip):

oh, I see, when I copy-and-patse I see it all :)

nikomatsakis (Oct 17 2018 at 13:12, on Zulip):
// new rule after #176:

FromEnv(<Self as Foo>::Item<...>: Bounds) :-
    FromEnv(Self: Foo),
    FromEnv(WC)
nikomatsakis (Oct 17 2018 at 13:13, on Zulip):

it feels like the problem is that we have FromEnv(WC)

nikomatsakis (Oct 17 2018 at 13:13, on Zulip):

and not just WC

scalexm (Oct 17 2018 at 13:13, on Zulip):

@nikomatsakis right

nikomatsakis (Oct 17 2018 at 13:13, on Zulip):

it also feels like it would be ok to just have Implemented(WC) there

nikomatsakis (Oct 17 2018 at 13:13, on Zulip):

but I've not thought deeply about it

nikomatsakis (Oct 17 2018 at 13:13, on Zulip):

the main thing is that

scalexm (Oct 17 2018 at 13:13, on Zulip):

it looks like it'd be ok yes, however I would find the rule a bit "weird", like we don't have any rules FromEnv(...) :-Implemented(...)

nikomatsakis (Oct 17 2018 at 13:14, on Zulip):

the impl does not "provide" those facts

nikomatsakis (Oct 17 2018 at 13:14, on Zulip):

so we don't need to be sure that they come from the environment

scalexm (Oct 17 2018 at 13:14, on Zulip):

yes I think this is right

scalexm (Oct 17 2018 at 13:14, on Zulip):

I just hope it would not lead to weird cycles

nikomatsakis (Oct 17 2018 at 13:14, on Zulip):

it is asymmetric, but i'm arguing why it is different than the other cases :)

nikomatsakis (Oct 17 2018 at 13:14, on Zulip):

these where clauses are not 'like' the others

scalexm (Oct 17 2018 at 13:14, on Zulip):

yes I agree

nikomatsakis (Oct 17 2018 at 13:14, on Zulip):

rather, they are more like where clauses on methods

nikomatsakis (Oct 17 2018 at 13:15, on Zulip):

(but methods don't have implied bounds...)

nikomatsakis (Oct 17 2018 at 13:15, on Zulip):

(yet...)

scalexm (Oct 17 2018 at 13:16, on Zulip):

well they might have, the analogy I was drawing in my head was:

trait Foo {
    fn item<T: WC>() -> impl Bound;
}
nikomatsakis (Oct 17 2018 at 13:17, on Zulip):

if we permitted you to "name" this return type...

nikomatsakis (Oct 17 2018 at 13:17, on Zulip):

...that would be quite analogous indeed

nikomatsakis (Oct 17 2018 at 13:17, on Zulip):

well I guess you can't name it

nikomatsakis (Oct 17 2018 at 13:17, on Zulip):

but the point is

nikomatsakis (Oct 17 2018 at 13:17, on Zulip):

after you call the method

nikomatsakis (Oct 17 2018 at 13:17, on Zulip):

the value you get back has a type that we "assume" to implement bound

nikomatsakis (Oct 17 2018 at 13:18, on Zulip):

in effect this is desugaring, of course, to an associated type

nikomatsakis (Oct 17 2018 at 13:18, on Zulip):

(and I'd hope that eventually we are literally desugaring to that)

scalexm (Oct 17 2018 at 13:19, on Zulip):

yeah, I think it's ok indeed to just have :- Implemented(Bar)

scalexm (Oct 17 2018 at 13:19, on Zulip):

because as you said this does not come from the Bar trait declaration

scalexm (Oct 17 2018 at 13:19, on Zulip):

so it seems ok

scalexm (Oct 17 2018 at 13:21, on Zulip):

ok cool

scalexm (Oct 17 2018 at 13:22, on Zulip):

I'd like to also ask @Ariel Ben-Yehuda what they think, just in case

nikomatsakis (Oct 17 2018 at 13:34, on Zulip):

yep, maybe they'll weigh in

Last update: Nov 12 2019 at 16:35UTC