Stream: t-compiler

Topic: moving method matching to a canonical query


Ariel Ben-Yehuda (Jan 25 2019 at 21:40, on Zulip):

hi @nikomatsakis

Ariel Ben-Yehuda (Jan 25 2019 at 21:40, on Zulip):

so about moving method matching to a canonical query

Ariel Ben-Yehuda (Jan 25 2019 at 21:41, on Zulip):

I think the main problem with doing it "directly" is that method matching has a lot of inputs

Ariel Ben-Yehuda (Jan 25 2019 at 21:41, on Zulip):

things like the privacy of methods

Ariel Ben-Yehuda (Jan 25 2019 at 21:41, on Zulip):

but it might be possible to do it "indirectly"

Ariel Ben-Yehuda (Jan 25 2019 at 21:41, on Zulip):

where there's a query that returns the set of matching methods

Ariel Ben-Yehuda (Jan 25 2019 at 21:41, on Zulip):

and their priorities

nikomatsakis (Jan 25 2019 at 21:42, on Zulip):

I think the main problem with doing it "directly" is that method matching has a lot of inputs

(Do you just mean there'd be a lot of data in the query key?)

Ariel Ben-Yehuda (Jan 25 2019 at 21:42, on Zulip):

the problem is that privacy is based on a NodeId

Ariel Ben-Yehuda (Jan 25 2019 at 21:42, on Zulip):

so if we do it directly, we really won't be having any deduplication

nikomatsakis (Jan 25 2019 at 21:42, on Zulip):

well, only within a module

Ariel Ben-Yehuda (Jan 25 2019 at 21:43, on Zulip):

consider hygiene

nikomatsakis (Jan 25 2019 at 21:43, on Zulip):

(i.e., there is presumably some "canonicalization" we can do to the node-id)

Ariel Ben-Yehuda (Jan 25 2019 at 21:43, on Zulip):

it makes this sort of thing so much more fun

nikomatsakis (Jan 25 2019 at 21:43, on Zulip):

I'm not really convinced anymore that "type-related" lookups should work via hygiene

nikomatsakis (Jan 25 2019 at 21:43, on Zulip):

but that's a separate matter

Ariel Ben-Yehuda (Jan 25 2019 at 21:43, on Zulip):

sure me too

Ariel Ben-Yehuda (Jan 25 2019 at 21:43, on Zulip):

but that's what @jseyfried implemented back in the day

nikomatsakis (Jan 25 2019 at 21:43, on Zulip):

regardless I agree that your idea is good

nikomatsakis (Jan 25 2019 at 21:43, on Zulip):

if we can make it work

Ariel Ben-Yehuda (Jan 25 2019 at 21:43, on Zulip):

which one, the PR

nikomatsakis (Jan 25 2019 at 21:43, on Zulip):

no, I haven't read the PR yet

Ariel Ben-Yehuda (Jan 25 2019 at 21:43, on Zulip):

or having a "table ignoring privacy"

nikomatsakis (Jan 25 2019 at 21:44, on Zulip):

I mean that if we could do method lookups that can ignore privacy and return enough results to "customize" to each site

nikomatsakis (Jan 25 2019 at 21:44, on Zulip):

that seems like it could result in a lot more re-use

nikomatsakis (Jan 25 2019 at 21:44, on Zulip):

anyway I should read your PR

Ariel Ben-Yehuda (Jan 25 2019 at 21:44, on Zulip):

actually, it's [WIP] because I might be rewriting it

Ariel Ben-Yehuda (Jan 25 2019 at 21:47, on Zulip):

but I wanted to see whether my approach to composing canonicalization is OK

Ariel Ben-Yehuda (Jan 25 2019 at 21:47, on Zulip):

i.e. https://github.com/rust-lang/rust/pull/57885/files#diff-dd3531c645441fc4588d997838e391f5R813

Ariel Ben-Yehuda (Jan 25 2019 at 21:57, on Zulip):

and I think I'm saved by ObjectCandidate being weird

nikomatsakis (Jan 25 2019 at 21:58, on Zulip):

I'm not sure I quite get what is being composed

nikomatsakis (Jan 25 2019 at 21:59, on Zulip):

you instantiate the canonical self-ty with variables

nikomatsakis (Jan 25 2019 at 21:59, on Zulip):

then invoke canonicalize_response on the new struct which seems to be largely built from the result of that, right?

nikomatsakis (Jan 25 2019 at 22:00, on Zulip):

I guess I don't see anything that stands out as wrong to me

nikomatsakis (Jan 25 2019 at 22:00, on Zulip):

but I feel like maybe I'm missing something because I'm not quite sure what you are concerned about

Ariel Ben-Yehuda (Jan 25 2019 at 22:01, on Zulip):

yea

Ariel Ben-Yehuda (Jan 25 2019 at 22:01, on Zulip):

So I start with a Canonical<QueryResult<T>>

Ariel Ben-Yehuda (Jan 25 2019 at 22:01, on Zulip):

and I first open the canonical

Ariel Ben-Yehuda (Jan 25 2019 at 22:01, on Zulip):

then I "map" the QueryResult

Ariel Ben-Yehuda (Jan 25 2019 at 22:01, on Zulip):

then I canonicalize it again

Ariel Ben-Yehuda (Jan 25 2019 at 22:02, on Zulip):

the "weird" thing here is that I'm splitting the Canonical & the QueryResult

Ariel Ben-Yehuda (Jan 25 2019 at 22:02, on Zulip):

where most methods treat Canonical<QueryResult<->> as a single unit

Ariel Ben-Yehuda (Jan 25 2019 at 22:02, on Zulip):

but I suppose that's just the thing that is OK

Ariel Ben-Yehuda (Jan 25 2019 at 22:03, on Zulip):

and now I'm trying to investigate whether it's possible to have an ObjectCandidate be sensitive to just the def-id of the trait object

Ariel Ben-Yehuda (Jan 25 2019 at 22:03, on Zulip):

while ignoring its substs

Ariel Ben-Yehuda (Jan 25 2019 at 22:03, on Zulip):

and then I'll have to do none of this canonicalization business

Ariel Ben-Yehuda (Jan 25 2019 at 22:04, on Zulip):

but this seems subtle

Ariel Ben-Yehuda (Jan 25 2019 at 22:04, on Zulip):

and I'm trying to work it out

nikomatsakis (Jan 25 2019 at 22:07, on Zulip):

ok. I don't see an obvious problem but I will try to give it a bit more concentrated time

nikomatsakis (Jan 25 2019 at 22:07, on Zulip):

let me add something to my calendar :)

nikomatsakis (Jan 25 2019 at 22:07, on Zulip):

I'd like to read it more closely anyway

Ariel Ben-Yehuda (Jan 25 2019 at 22:08, on Zulip):

you mean my PR?

nikomatsakis (Jan 25 2019 at 22:08, on Zulip):

Yes. I won't really have time to look closely until Monday anyway

Ariel Ben-Yehuda (Jan 25 2019 at 22:08, on Zulip):

I think there's some subtle problem with arbitrary_self_types that could cause the simpler approach to ICE

Ariel Ben-Yehuda (Jan 25 2019 at 22:08, on Zulip):

ok

Ariel Ben-Yehuda (Jan 25 2019 at 22:08, on Zulip):

which means we need to do this approach instead of the simpler one

Ariel Ben-Yehuda (Jan 28 2019 at 21:53, on Zulip):

wait, in the universes world, does dyn for<'a> Foo<'a, Output=&'a $0> unify with dyn Foo<'$0, Output=$1>?

Ariel Ben-Yehuda (Jan 28 2019 at 21:54, on Zulip):

I mean, in a probe context? @nikomatsakis

Ariel Ben-Yehuda (Jan 28 2019 at 22:14, on Zulip):

and now I found a stupid simple way of cutting away that gordian know

nikomatsakis (Jan 29 2019 at 17:21, on Zulip):

@Ariel Ben-Yehuda presently, they do unify but should generate an error later in region solving. I think that for trait solving at least we may have to get a bit smarter, though.

Ariel Ben-Yehuda (Jan 29 2019 at 20:26, on Zulip):

that's what I thought, but it turns out I don't need that

Last update: Nov 16 2019 at 02:30UTC