To compile the previous example with Cargo, we'll just need to include the crate containing the compiler plugin in Cargo.toml and define it as a plugin. Cargo will handle the rest. Modifying the preceding example into a Cargo project, we get this directory structure:
We'll still need to tell Cargo about the plugin. The lib section of Cargo.toml would look as follows:
// compiler-plugin/Cargo.toml [lib] name="simplest_compiler_plugin" plugin=true
After this change, building with Cargo works and we can see the plugin in glorious action:
Now that we are able to build a simple compiler plugin, let's try ...