Examples of macros/compiler plugins with access to type information?


#1

Are there any examples of macros or compiler plugins that have access to type information?


#2

Some of clippy’s lints run after type checking passes: https://github.com/Manishearth/rust-clippy

Plugins that modify the AST will always run before type checking, though.


#3

Hm, wasn’t there some talk about having plugins modify AST and have access to type information?


#4

Rust does not do type checking on the AST I believe. I think type checking is done on HIR, and borrow checking is/will soon be done even later (on MIR).


#5

Yeh, I think this is a bit of a gap in what compiler plugins can do.

The best I’ve been able to do is build plugins in such a way that the emitted code can call out to methods that infer the type and do something based on that.