diff options
| author | Brian Anderson <banderson@mozilla.com> | 2014-07-19 21:54:37 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-07-21 09:54:26 -0700 |
| commit | c88bf10c37d32f18774cfa3ef480eb77df294565 (patch) | |
| tree | bddfcf7c6d583d0c491a30ef501d79664369954c /src/librustc/plugin | |
| parent | 1c3655bed192e31bdf649ed5f4e728201ede17b2 (diff) | |
| download | rust-c88bf10c37d32f18774cfa3ef480eb77df294565.tar.gz rust-c88bf10c37d32f18774cfa3ef480eb77df294565.zip | |
rustc: Pass optional additional plugins to compile_input
This provides a way for clients of the rustc library to add their own features to the pipeline.
Diffstat (limited to 'src/librustc/plugin')
| -rw-r--r-- | src/librustc/plugin/load.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/librustc/plugin/load.rs b/src/librustc/plugin/load.rs index 499cffa42aa..4f38c74893e 100644 --- a/src/librustc/plugin/load.rs +++ b/src/librustc/plugin/load.rs @@ -66,10 +66,24 @@ impl<'a> PluginLoader<'a> { } /// Read plugin metadata and dynamically load registrar functions. -pub fn load_plugins(sess: &Session, krate: &ast::Crate) -> Plugins { +pub fn load_plugins(sess: &Session, krate: &ast::Crate, + addl_plugins: Option<Plugins>) -> Plugins { let mut loader = PluginLoader::new(sess); visit::walk_crate(&mut loader, krate, ()); - loader.plugins + + let mut plugins = loader.plugins; + + match addl_plugins { + Some(addl_plugins) => { + // Add in the additional plugins requested by the frontend + let Plugins { macros: addl_macros, registrars: addl_registrars } = addl_plugins; + plugins.macros.push_all_move(addl_macros); + plugins.registrars.push_all_move(addl_registrars); + } + None => () + } + + return plugins; } // note that macros aren't expanded yet, and therefore macros can't add plugins. |
