rustc internal: a shiny future for HIR typeck

This is not a blogpost for public consumption, it’s a note so that I don’t forgot about this myself. This stems from a 5 minute conversation with Boxy.

HIR typeck does not care about free regions. It cares about bound regions, i.e. whether a type is for<'a> fn(&'a u32) or fn(&'static u32) matters, but whether a type is &'a u32 vs &'b u32 does not.

We could mostly just use our internal 'erased everywhere in HIR typeck and don’t bother with any region information at all there.

Separately, we’re currently removing higher-ranked subtyping. The fact that subtyping can impact trait selection is a nightmare and unfortunately that’s just currently the case. I’ve been looking into this with Santiago Pastorino, see #160461.

Once we’ve replaced higher-ranked subtyping with coercions we don’t need to differentiate between subtyping and equality in HIR typeck anymore and can just have a single way to relate things there.

This would have a significant positive perf impact. We can remove Subtype obligations and instead just unify all related inference variables.

More importantly, we can remove the sub_unification_table. Handling that one correctly has a pretty big impact on the complexity and performance of canonicalization for the trait solver. It forces us to check a separate unification table whenever we test whether some obligation is currently stalled.

if you find any typos or errors in this post, please pm me on zulip or discord

back

impressum rss