Stream: t-compiler/wg-mir-opt

Topic: matching again projection List


Santiago Pastorino (Oct 11 2019 at 20:41, on Zulip):

we were talking about matching Place now that after interning instead of having Box<[T]> we will have &List<T>

Santiago Pastorino (Oct 11 2019 at 20:41, on Zulip):

/cc @nikomatsakis @oli

Santiago Pastorino (Oct 11 2019 at 20:42, on Zulip):

what I'm mainly doing is calling Place::as_ref() to get a PlaceRef which holds &[T] instead of &List<T>

Santiago Pastorino (Oct 11 2019 at 20:42, on Zulip):

so trivial cases are not thaaat bad

Santiago Pastorino (Oct 11 2019 at 20:42, on Zulip):

the problem is once the pattern is more complex, like having Place inside other things

Santiago Pastorino (Oct 11 2019 at 20:42, on Zulip):

patterns like Operand(Place { ... }) are now not directly possible

nikomatsakis (Oct 11 2019 at 20:42, on Zulip):

yeah I mean at the end of the day I think you just need nested matches sometimes

nikomatsakis (Oct 11 2019 at 20:43, on Zulip):

maybe point to some particularl examples?

Santiago Pastorino (Oct 11 2019 at 20:43, on Zulip):

need to translate to Operand(place) and then match over place.as_ref() or things like that

nikomatsakis (Oct 11 2019 at 20:43, on Zulip):

tbqh I sort of prefer helper functions describing patterns where possible anyway

nikomatsakis (Oct 11 2019 at 20:43, on Zulip):

but I might just have stockholm syndrome

nikomatsakis (Oct 11 2019 at 20:43, on Zulip):

I feel like there's some syndrome where compiler authors avoid complex features because they know what a pain they are to implement

nikomatsakis (Oct 11 2019 at 20:43, on Zulip):

that's how I presently feel about slice patterns :P

Santiago Pastorino (Oct 11 2019 at 20:45, on Zulip):

https://github.com/rust-lang/rust/blob/db704a69ffbb22adca23ba21dc0cc8d1f24d8646/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L497

Santiago Pastorino (Oct 11 2019 at 20:46, on Zulip):

but I might just have stockholm syndrome

LOL

nikomatsakis (Oct 11 2019 at 20:49, on Zulip):

link doesn't work for me

Santiago Pastorino (Oct 11 2019 at 20:50, on Zulip):

fixed

Santiago Pastorino (Oct 11 2019 at 20:50, on Zulip):

sorry, in a particular branch

nikomatsakis (Oct 11 2019 at 20:53, on Zulip):

yeah so that's a case where I would sort of prefer the as_local function

nikomatsakis (Oct 11 2019 at 20:53, on Zulip):

that said

nikomatsakis (Oct 11 2019 at 20:53, on Zulip):

how often is the pattern the "empty list"?

nikomatsakis (Oct 11 2019 at 20:53, on Zulip):

i.e., box []

ecstatic-morse (Oct 11 2019 at 20:54, on Zulip):

A Place::local combinator that returns Some(local) when the place has no projections would remove many places where you need to match on the projections directly, at least in the code I've been working on.

nikomatsakis (Oct 11 2019 at 20:54, on Zulip):

that might be something we could do with a constant

nikomatsakis (Oct 11 2019 at 20:54, on Zulip):

A Place::local combinator that returns Some(local) when the place has no projections and would remove many places where you need to match on the projections directly, at least in the code I've been working on.

there is one

nikomatsakis (Oct 11 2019 at 20:54, on Zulip):

I landed it -- I think? -- as part of some PR

nikomatsakis (Oct 11 2019 at 20:54, on Zulip):

place.as_local() I think?

ecstatic-morse (Oct 11 2019 at 20:54, on Zulip):

I'll check. I've seen local_or_deref_local.

Santiago Pastorino (Oct 11 2019 at 20:54, on Zulip):

maybe I can look for better examples :)

ecstatic-morse (Oct 11 2019 at 20:55, on Zulip):

Place::as_local

ecstatic-morse (Oct 11 2019 at 20:55, on Zulip):

time to rewrite some stuff :)

Last update: Nov 17 2019 at 07:30UTC