# rustc-tools
Some internal rustc tools made accessible (by wrapping the setup part away).
## Why would I need this crate?
If you need to write a Rust compiler plugin (`clippy` and `rustdoc` are good examples of what a rustc plugin can achieve), a lot of setup is required to be able to use its APIs. This crate aims at removing this pain point so you can spend more time working on the plugin instead.
## How to use it?
Since it provides and uses `rustc` API, it only works on a very specific nightly version of the Rust compiler. Take a look at the `rust-toolchain` file.
Another thing required: you need to add `# and to take a look at the [compiler documentation](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/index.html) (and in particular the [`TyCtxt`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html) and [`Map`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/map/struct.Map.html) types, both of which are at the center of the `HIR` level).
## Running examples
There are a few examples available in the `examples` folder. To run them:
```
$ cargo run --example ast -- asset/example_file.rs
$ cargo run --example hir -- asset/example_file.rs
$ cargo run --example lint -- asset/example_file.rs
```