llogiq / metacollect

A lint to collect some crate metadata
Mozilla Public License 2.0
115 stars 2 forks source link

Look at the output of -Z save-analysis-json #4

Open llogiq opened 8 years ago

llogiq commented 8 years ago

The rust compiler currently implements something similar to this project, so in the name of reducing duplication, it would be good to find out and document what it does and where we can augment it with our own analysis.

nrc commented 8 years ago

You should look at the save-analysis crate you can implement data dumpers to dump data in any format you like (currently we format JSON and CSV) and I'm very open to dumping more data if there is some missing. I would strongly recommend you use that. We intend to support the API long term (it will be used to power IDEs, etc.) and will be relatively stable. We can also customise to your needs. Any approach that uses the compiler internals or crate metadata is likely to break very often.

eddyb commented 7 years ago

For the intended purposes of metacollect, MIR seems way more relevant than save-analysis.

Since https://github.com/rust-lang/rust/pull/37400, all you need to do is tcx.item_mir(def_id) to get it, even from a lint. NB: cross-crate MIR exists only for constants, const fn or #[inline]/generic functions.