I'm working on a rustc plugin. My current understanding is that MIR does not instantiate generics. But the compiler has to it at some point. The question is when does this happen and if it is possible to instrument the process at this stage so that my plugin access some sort of intermediate representation where generics have already been instantiated?
It happens on the fly during codegen. A plugin cant intercept the monomorphized mir for a function, as every time a part of the mir is codegened, it monomorphized that part only.
What are you trying to achieve? Maybe there is another way to do it than intercepting the monomorphized mir.
I'm trying to annotate some types and track all functions related to that type, including generic functions instantiated with it.
Depending on what you are trying to track, you might be able to accomplish the same by having a trait. The types you want to track could implement the trait as the only way to create a new value of that type... It's possibly much less expressive than what you want, though...
I noticed this. But it seems the feature will still be around for a while. And there is no substitution as far as I know.
You can use a custom rustc driver.
That would be perpetually unstable, though it seems above that that is ok with the OP
I use a plug-in to add a custom attribute. It seems a custom rustc driver is not for that purpose?
For most cases, custom attributes can be handed via procedural macro attributes now.