Just FYI, I’m planning to remove the Hair trait from MIR construction (PR coming soon). The reason is that the way I had it currently implemented, the
Hair trait serves two roles: it hosted a bunch of associated types that are used by the
Ty) and it also hosted some associated types and methods that were used solely by MIR construction (e.g.,
can_drop). The latter required access to an inference context, but that in turn requires that the type which implements the
Hair trait contains a
InferCtxt<'a, 'tcx>. THIS in turn means that you have a
Mir type that looks like
Mir<Cx<'a,'tcx>>. This is the type we would have to store in some table in the tcx. The problem is that the lifetime
'a is local to the MIR construction pass.
The only solution I see (besides removing the trait) is to split the
Hair trait into two traits, one that hosts the associated type, and one that is the “builder”. I experimented with this but it’s kind of annoying and verbose. Frankly, while the Hair trait was a fun experiment, it’s unclear that it carries its weight anyhow. The idea was to allow us to gin up artificial inputs beyond full .rs files – this seems maybe useful but also maybe like something we will implement and then rarely if ever use. So I am decided to just remove the trait instead.
PR coming soon.