driver_hax_frontend_exporter/
callbacks_wrapper.rsuse hax_types::cli_options::{Command, Options, ENV_VAR_OPTIONS_FRONTEND};
use rustc_driver::{Callbacks, Compilation};
use rustc_interface::{interface, Queries};
use rustc_span::symbol::Symbol;
pub struct CallbacksWrapper<'a> {
pub sub: &'a mut (dyn Callbacks + Send + 'a),
pub options: Options,
}
impl<'a> Callbacks for CallbacksWrapper<'a> {
fn config(&mut self, config: &mut interface::Config) {
let options = self.options.clone();
config.psess_created = Some(Box::new(move |parse_sess| {
let depinfo = parse_sess.env_depinfo.get_mut();
depinfo.insert((
Symbol::intern(ENV_VAR_OPTIONS_FRONTEND),
Some(Symbol::intern(&serde_json::to_string(&options).unwrap())),
));
depinfo.insert((
Symbol::intern("HAX_CARGO_CACHE_KEY"),
std::env::var("HAX_CARGO_CACHE_KEY")
.ok()
.as_deref()
.map(Symbol::intern),
));
}));
self.sub.config(config)
}
fn after_crate_root_parsing<'tcx>(
&mut self,
compiler: &interface::Compiler,
queries: &'tcx Queries<'tcx>,
) -> Compilation {
self.sub.after_crate_root_parsing(compiler, queries)
}
fn after_expansion<'tcx>(
&mut self,
compiler: &interface::Compiler,
queries: &'tcx Queries<'tcx>,
) -> Compilation {
self.sub.after_expansion(compiler, queries)
}
fn after_analysis<'tcx>(
&mut self,
compiler: &interface::Compiler,
queries: &'tcx Queries<'tcx>,
) -> Compilation {
self.sub.after_analysis(compiler, queries)
}
}