Stream: t-compiler

Topic: Early return from a MIR `Visitor`?

ecstatic-morse (Oct 16 2019 at 19:27, on Zulip):

There's multiple places in const qualification and validation where Visitor is basically reimplemented only so it can eagerly return a result.

I wonder if we could add an associated return type to Visitor that must be either something implementing Try or an empty tuple so that code like this can take advantage of the existing structural recursion in Visitor? Existing visitors would not have to change except maybe to specify type BreakVal = () (I'm not sure if associated type defaults are usable).

oli (Oct 17 2019 at 12:22, on Zulip):

associated type defaults are not usable, because every implementor that changes it will have to reimplement all methods (even those with default bodies)

nikomatsakis (Oct 17 2019 at 14:15, on Zulip):

It could just be a plain generic

nikomatsakis (Oct 17 2019 at 14:16, on Zulip):

I'd like to review the MIR visitor somewhat, in light of the changes that @Santiago Pastorino was making; I'm wondering if there's a less general structure that might work better

ecstatic-morse (Oct 18 2019 at 21:03, on Zulip):

I did a proof-of-concept in #65572

ecstatic-morse (Oct 18 2019 at 21:37, on Zulip):

One of the reasons I'm interested in this is that it would be useful in #63812 (@eddyb )

ecstatic-morse (Oct 18 2019 at 21:45, on Zulip):

Also, I haven't looked at the perf implications of this. If the queue is ever empty I'll trigger a perf run (seems unlikely). I think I'd need to add #[inline] to the Try impl for () first.

Last update: May 26 2020 at 11:10UTC