Compiler plugins
To finish with this list, we will talk about the compiler plugins. These plugins can be used by adding #![feature(plugin)] to the top of the main.rs or lib.rs files, as with the rest of the nightly features. If you want to actually create a plugin, you will need to use the plugin_registrar and rustc_private features.
The unstable feature list has an interesting guide to create plugins, which will be extended in Chapter 9, Creating Your Own Macros. You will need to use the libsyntax crate, along with the internals of the compiler syntax, and the compiler internals themselves, so that you can parse the advanced source tree (AST) tokens, and perform the operations required by your plugin.
Plugins enable big syntax extensions ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access