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 methods
fn reported_driver_version(&self) -> Cow<'static, str> { ... }
fn hash_config(&self, _args: &Self::Args, _hasher: &mut impl Hasher) { ... }
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§
fn reported_driver_version(&self) -> Cow<'static, str>
fn hash_config(&self, _args: &Self::Args, _hasher: &mut impl Hasher)
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.