pub trait RustcPlugin: Sized {
    type Args: Serialize + DeserializeOwned;

    // Required methods
    fn version(&self) -> Cow<'static, str>;
    fn driver_name(&self) -> Cow<'static, str>;
    fn args(&self, target_dir: &Utf8Path) -> RustcPluginArgs<Self::Args>;
    fn run(
        self,
        compiler_args: Vec<String>,
        plugin_args: Self::Args
    ) -> Result<()>;

    // Provided method
    fn modify_cargo(&self, _cargo: &mut Command, _args: &Self::Args) { ... }
}
Expand description

Interface between your plugin and the rustc_plugin framework.

Required Associated Types§

source

type Args: Serialize + DeserializeOwned

Command-line arguments passed by the user.

Required Methods§

source

fn version(&self) -> Cow<'static, str>

Returns the version of your plugin.

A sensible default is your plugin’s Cargo version:

env!("CARGO_PKG_VERSION").into()
source

fn driver_name(&self) -> Cow<'static, str>

Returns the name of your driver binary as it’s installed in the filesystem.

Should be just the filename, not the full path.

source

fn args(&self, target_dir: &Utf8Path) -> RustcPluginArgs<Self::Args>

Parses and returns the CLI arguments for the plugin.

source

fn run(self, compiler_args: Vec<String>, plugin_args: Self::Args) -> Result<()>

Executes the plugin with a set of compiler and plugin args.

Provided Methods§

source

fn modify_cargo(&self, _cargo: &mut Command, _args: &Self::Args)

Optionally modify the cargo command that launches rustc. For example, you could pass a --feature flag here.

Object Safety§

This trait is not object safe.

Implementors§