MCPcopy Index your code
hub / github.com/cognitive-engineering-lab/rustc_plugin

github.com/cognitive-engineering-lab/rustc_plugin @nightly-2023-04-12-v0.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release nightly-2023-04-12-v0.1.0 ↗ · + Follow
33 symbols 57 edges 13 files 5 documented · 15% updated 32d ago★ 1716 open issues

Browse by type

Functions 27 Types & classes 6
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

rustc-plugin

Tests docs

rustc-plugin is a framework for writing plugins that integrate with the Rust compiler. We wrote rustc-plugin to support our research on experimental Rust tools like Flowistry and Aquascope. rustc-plugin is a kind of generalized version of the infrastructure in Clippy.

Installation

The Rust compiler's interface is not stable, so the only sensible way to develop a Rust compiler plugin is by pinning to a specific nightly. Each version of rustc-plugin is pinned to one nightly, and you have to use the same nightly version that we do. Therefore each release of rustc-plugin will be tagged with its nightly (e.g. nightly-2023-04-12) and its semantic version (e.g. v0.1.0). The extra nightly metadata breaks Cargo's semver rules, so we won't be publishing to crates.io. Instead, you should add a git dependency like this:

[dependencies.rustc-plugin]
git = "https://github.com/cognitive-engineering-lab/rustc-plugin"
tag = "nightly-2023-04-12-v0.1.0"

Usage

See the print-all-items crate for an example of how to use rustc-plugin. See the docs for an explanation of each API component. In short, a Rustc plugin is structured like this:

The rustc-plugin framework is responsible for marshalling arguments from the top-level CLI into the individual invocations of the driver. It handles issues like setting the sysroot (so the compiler can locate the Rust standard libraries) and finding the crate that contains a given file (if you only want to run on a specific file). Everything else is up to you!

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Function 22
Class 5
Method 5
Interface 1

Languages

Rust100%

Modules by API surface

examples/print-all-items/src/lib.rs9 symbols
src/driver.rs5 symbols
tests/test_example.rs4 symbols
tests/workspaces/multi/b/src/lib.rs2 symbols
tests/workspaces/multi/a/src/lib.rs2 symbols
tests/workspaces/basic/src/lib.rs2 symbols
src/plugin.rs2 symbols
src/cli.rs2 symbols
examples/print-all-items/test-crate/src/lib.rs2 symbols
examples/print-all-items/src/bin/print-all-items-driver.rs1 symbols
examples/print-all-items/src/bin/cargo-print-all-items.rs1 symbols
build.rs1 symbols

For agents

$ claude mcp add rustc_plugin \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page