Trait rustc_plugin::RustcPlugin
source · 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§
sourcetype Args: Serialize + DeserializeOwned
type Args: Serialize + DeserializeOwned
Command-line arguments passed by the user.
Required Methods§
sourcefn version(&self) -> Cow<'static, str>
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()
sourcefn driver_name(&self) -> Cow<'static, str>
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.
sourcefn args(&self, target_dir: &Utf8Path) -> RustcPluginArgs<Self::Args>
fn args(&self, target_dir: &Utf8Path) -> RustcPluginArgs<Self::Args>
Parses and returns the CLI arguments for the plugin.
Provided Methods§
sourcefn modify_cargo(&self, _cargo: &mut Command, _args: &Self::Args)
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.