Rollup merge of #135880 - bjorn3:misc_driver_refactors, r=oli-obk
Get rid of RunCompiler The various `set_*` methods that have been removed can be replaced by setting the respective fields in the `Callbacks::config` implementation. `set_using_internal_features` was often forgotten and it's equivalent is now done automatically.
This commit is contained in:
commit
7d31ae7f35
16 changed files with 68 additions and 174 deletions
|
|
@ -186,7 +186,7 @@ pub fn main() {
|
|||
|
||||
rustc_driver::init_rustc_env_logger(&early_dcx);
|
||||
|
||||
let using_internal_features = rustc_driver::install_ice_hook(BUG_REPORT_URL, |dcx| {
|
||||
rustc_driver::install_ice_hook(BUG_REPORT_URL, |dcx| {
|
||||
// FIXME: this macro calls unwrap internally but is called in a panicking context! It's not
|
||||
// as simple as moving the call from the hook to main, because `install_ice_hook` doesn't
|
||||
// accept a generic closure.
|
||||
|
|
@ -236,7 +236,7 @@ pub fn main() {
|
|||
let mut args: Vec<String> = orig_args.clone();
|
||||
pass_sysroot_env_if_given(&mut args, sys_root_env);
|
||||
|
||||
rustc_driver::RunCompiler::new(&args, &mut DefaultCallbacks).run();
|
||||
rustc_driver::run_compiler(&args, &mut DefaultCallbacks);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
|
@ -295,13 +295,9 @@ pub fn main() {
|
|||
let clippy_enabled = !cap_lints_allow && relevant_package && !info_query;
|
||||
if clippy_enabled {
|
||||
args.extend(clippy_args);
|
||||
rustc_driver::RunCompiler::new(&args, &mut ClippyCallbacks { clippy_args_var })
|
||||
.set_using_internal_features(using_internal_features)
|
||||
.run();
|
||||
rustc_driver::run_compiler(&args, &mut ClippyCallbacks { clippy_args_var });
|
||||
} else {
|
||||
rustc_driver::RunCompiler::new(&args, &mut RustcCallbacks { clippy_args_var })
|
||||
.set_using_internal_features(using_internal_features)
|
||||
.run();
|
||||
rustc_driver::run_compiler(&args, &mut RustcCallbacks { clippy_args_var });
|
||||
}
|
||||
Ok(())
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use std::ops::Range;
|
|||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use std::sync::atomic::{AtomicI32, Ordering};
|
||||
use std::sync::{Arc, Once};
|
||||
use std::sync::Once;
|
||||
|
||||
use miri::{
|
||||
BacktraceStyle, BorrowTrackerMethod, MiriConfig, MiriEntryFnType,ProvenanceMode, RetagFields, ValidationMode,
|
||||
|
|
@ -370,13 +370,10 @@ fn init_late_loggers(early_dcx: &EarlyDiagCtxt, tcx: TyCtxt<'_>) {
|
|||
fn run_compiler_and_exit(
|
||||
args: &[String],
|
||||
callbacks: &mut (dyn rustc_driver::Callbacks + Send),
|
||||
using_internal_features: Arc<std::sync::atomic::AtomicBool>,
|
||||
) -> ! {
|
||||
// Invoke compiler, and handle return code.
|
||||
let exit_code = rustc_driver::catch_with_exit_code(move || {
|
||||
rustc_driver::RunCompiler::new(args, callbacks)
|
||||
.set_using_internal_features(using_internal_features)
|
||||
.run();
|
||||
rustc_driver::run_compiler(args, callbacks);
|
||||
Ok(())
|
||||
});
|
||||
std::process::exit(exit_code)
|
||||
|
|
@ -467,8 +464,7 @@ fn main() {
|
|||
// If the environment asks us to actually be rustc, then do that.
|
||||
if let Some(crate_kind) = env::var_os("MIRI_BE_RUSTC") {
|
||||
// Earliest rustc setup.
|
||||
let using_internal_features =
|
||||
rustc_driver::install_ice_hook(rustc_driver::DEFAULT_BUG_REPORT_URL, |_| ());
|
||||
rustc_driver::install_ice_hook(rustc_driver::DEFAULT_BUG_REPORT_URL, |_| ());
|
||||
rustc_driver::init_rustc_env_logger(&early_dcx);
|
||||
|
||||
let target_crate = if crate_kind == "target" {
|
||||
|
|
@ -492,16 +488,11 @@ fn main() {
|
|||
}
|
||||
|
||||
// We cannot use `rustc_driver::main` as we want it to use `args` as the CLI arguments.
|
||||
run_compiler_and_exit(
|
||||
&args,
|
||||
&mut MiriBeRustCompilerCalls { target_crate },
|
||||
using_internal_features,
|
||||
)
|
||||
run_compiler_and_exit(&args, &mut MiriBeRustCompilerCalls { target_crate })
|
||||
}
|
||||
|
||||
// Add an ICE bug report hook.
|
||||
let using_internal_features =
|
||||
rustc_driver::install_ice_hook("https://github.com/rust-lang/miri/issues/new", |_| ());
|
||||
rustc_driver::install_ice_hook("https://github.com/rust-lang/miri/issues/new", |_| ());
|
||||
|
||||
// Init loggers the Miri way.
|
||||
init_early_loggers(&early_dcx);
|
||||
|
|
@ -735,9 +726,5 @@ fn main() {
|
|||
|
||||
debug!("rustc arguments: {:?}", rustc_args);
|
||||
debug!("crate arguments: {:?}", miri_config.args);
|
||||
run_compiler_and_exit(
|
||||
&rustc_args,
|
||||
&mut MiriCompilerCalls::new(miri_config, many_seeds),
|
||||
using_internal_features,
|
||||
)
|
||||
run_compiler_and_exit(&rustc_args, &mut MiriCompilerCalls::new(miri_config, many_seeds))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue