Remove the need to manually call set_using_internal_features
This commit is contained in:
parent
b2728d5426
commit
4f9b9a43c1
10 changed files with 36 additions and 93 deletions
|
@ -28,8 +28,8 @@ use std::io::{self, IsTerminal, Read, Write};
|
||||||
use std::panic::{self, PanicHookInfo, catch_unwind};
|
use std::panic::{self, PanicHookInfo, catch_unwind};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::{self, Command, Stdio};
|
use std::process::{self, Command, Stdio};
|
||||||
|
use std::sync::OnceLock;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::sync::{Arc, OnceLock};
|
|
||||||
use std::time::{Instant, SystemTime};
|
use std::time::{Instant, SystemTime};
|
||||||
use std::{env, str};
|
use std::{env, str};
|
||||||
|
|
||||||
|
@ -214,18 +214,11 @@ pub struct RunCompiler<'a> {
|
||||||
file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
|
file_loader: Option<Box<dyn FileLoader + Send + Sync>>,
|
||||||
make_codegen_backend:
|
make_codegen_backend:
|
||||||
Option<Box<dyn FnOnce(&config::Options) -> Box<dyn CodegenBackend> + Send>>,
|
Option<Box<dyn FnOnce(&config::Options) -> Box<dyn CodegenBackend> + Send>>,
|
||||||
using_internal_features: Arc<std::sync::atomic::AtomicBool>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> RunCompiler<'a> {
|
impl<'a> RunCompiler<'a> {
|
||||||
pub fn new(at_args: &'a [String], callbacks: &'a mut (dyn Callbacks + Send)) -> Self {
|
pub fn new(at_args: &'a [String], callbacks: &'a mut (dyn Callbacks + Send)) -> Self {
|
||||||
Self {
|
Self { at_args, callbacks, file_loader: None, make_codegen_backend: None }
|
||||||
at_args,
|
|
||||||
callbacks,
|
|
||||||
file_loader: None,
|
|
||||||
make_codegen_backend: None,
|
|
||||||
using_internal_features: Arc::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set a custom codegen backend.
|
/// Set a custom codegen backend.
|
||||||
|
@ -257,23 +250,9 @@ impl<'a> RunCompiler<'a> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the session-global flag that checks whether internal features have been used,
|
|
||||||
/// suppressing the message about submitting an issue in ICEs when enabled.
|
|
||||||
#[must_use]
|
|
||||||
pub fn set_using_internal_features(mut self, using_internal_features: Arc<AtomicBool>) -> Self {
|
|
||||||
self.using_internal_features = using_internal_features;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Parse args and run the compiler.
|
/// Parse args and run the compiler.
|
||||||
pub fn run(self) {
|
pub fn run(self) {
|
||||||
run_compiler(
|
run_compiler(self.at_args, self.callbacks, self.file_loader, self.make_codegen_backend);
|
||||||
self.at_args,
|
|
||||||
self.callbacks,
|
|
||||||
self.file_loader,
|
|
||||||
self.make_codegen_backend,
|
|
||||||
self.using_internal_features,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +263,6 @@ fn run_compiler(
|
||||||
make_codegen_backend: Option<
|
make_codegen_backend: Option<
|
||||||
Box<dyn FnOnce(&config::Options) -> Box<dyn CodegenBackend> + Send>,
|
Box<dyn FnOnce(&config::Options) -> Box<dyn CodegenBackend> + Send>,
|
||||||
>,
|
>,
|
||||||
using_internal_features: Arc<std::sync::atomic::AtomicBool>,
|
|
||||||
) {
|
) {
|
||||||
let mut default_early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
|
let mut default_early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
|
||||||
|
|
||||||
|
@ -331,7 +309,7 @@ fn run_compiler(
|
||||||
override_queries: None,
|
override_queries: None,
|
||||||
make_codegen_backend,
|
make_codegen_backend,
|
||||||
registry: diagnostics_registry(),
|
registry: diagnostics_registry(),
|
||||||
using_internal_features,
|
using_internal_features: &USING_INTERNAL_FEATURES,
|
||||||
expanded_args: args,
|
expanded_args: args,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1350,6 +1328,8 @@ fn ice_path_with_config(config: Option<&UnstableOptions>) -> &'static Option<Pat
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub static USING_INTERNAL_FEATURES: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
/// Installs a panic hook that will print the ICE message on unexpected panics.
|
/// Installs a panic hook that will print the ICE message on unexpected panics.
|
||||||
///
|
///
|
||||||
/// The hook is intended to be useable even by external tools. You can pass a custom
|
/// The hook is intended to be useable even by external tools. You can pass a custom
|
||||||
|
@ -1360,15 +1340,8 @@ fn ice_path_with_config(config: Option<&UnstableOptions>) -> &'static Option<Pat
|
||||||
/// If you have no extra info to report, pass the empty closure `|_| ()` as the argument to
|
/// If you have no extra info to report, pass the empty closure `|_| ()` as the argument to
|
||||||
/// extra_info.
|
/// extra_info.
|
||||||
///
|
///
|
||||||
/// Returns a flag that can be set to disable the note for submitting a bug. This can be passed to
|
|
||||||
/// [`RunCompiler::set_using_internal_features`] to let macro expansion set it when encountering
|
|
||||||
/// internal features.
|
|
||||||
///
|
|
||||||
/// A custom rustc driver can skip calling this to set up a custom ICE hook.
|
/// A custom rustc driver can skip calling this to set up a custom ICE hook.
|
||||||
pub fn install_ice_hook(
|
pub fn install_ice_hook(bug_report_url: &'static str, extra_info: fn(&DiagCtxt)) {
|
||||||
bug_report_url: &'static str,
|
|
||||||
extra_info: fn(&DiagCtxt),
|
|
||||||
) -> Arc<AtomicBool> {
|
|
||||||
// If the user has not explicitly overridden "RUST_BACKTRACE", then produce
|
// If the user has not explicitly overridden "RUST_BACKTRACE", then produce
|
||||||
// full backtraces. When a compiler ICE happens, we want to gather
|
// full backtraces. When a compiler ICE happens, we want to gather
|
||||||
// as much information as possible to present in the issue opened
|
// as much information as possible to present in the issue opened
|
||||||
|
@ -1385,8 +1358,6 @@ pub fn install_ice_hook(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let using_internal_features = Arc::new(std::sync::atomic::AtomicBool::default());
|
|
||||||
let using_internal_features_hook = Arc::clone(&using_internal_features);
|
|
||||||
panic::update_hook(Box::new(
|
panic::update_hook(Box::new(
|
||||||
move |default_hook: &(dyn Fn(&PanicHookInfo<'_>) + Send + Sync + 'static),
|
move |default_hook: &(dyn Fn(&PanicHookInfo<'_>) + Send + Sync + 'static),
|
||||||
info: &PanicHookInfo<'_>| {
|
info: &PanicHookInfo<'_>| {
|
||||||
|
@ -1438,11 +1409,9 @@ pub fn install_ice_hook(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the ICE message
|
// Print the ICE message
|
||||||
report_ice(info, bug_report_url, extra_info, &using_internal_features_hook);
|
report_ice(info, bug_report_url, extra_info, &USING_INTERNAL_FEATURES);
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
|
||||||
using_internal_features
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prints the ICE message, including query stack, but without backtrace.
|
/// Prints the ICE message, including query stack, but without backtrace.
|
||||||
|
@ -1583,13 +1552,11 @@ pub fn main() -> ! {
|
||||||
init_rustc_env_logger(&early_dcx);
|
init_rustc_env_logger(&early_dcx);
|
||||||
signal_handler::install();
|
signal_handler::install();
|
||||||
let mut callbacks = TimePassesCallbacks::default();
|
let mut callbacks = TimePassesCallbacks::default();
|
||||||
let using_internal_features = install_ice_hook(DEFAULT_BUG_REPORT_URL, |_| ());
|
install_ice_hook(DEFAULT_BUG_REPORT_URL, |_| ());
|
||||||
install_ctrlc_handler();
|
install_ctrlc_handler();
|
||||||
|
|
||||||
let exit_code = catch_with_exit_code(|| {
|
let exit_code = catch_with_exit_code(|| {
|
||||||
RunCompiler::new(&args::raw_args(&early_dcx)?, &mut callbacks)
|
RunCompiler::new(&args::raw_args(&early_dcx)?, &mut callbacks).run();
|
||||||
.set_using_internal_features(using_internal_features)
|
|
||||||
.run();
|
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::result;
|
use std::result;
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use rustc_ast::{LitKind, MetaItemKind, token};
|
use rustc_ast::{LitKind, MetaItemKind, token};
|
||||||
use rustc_codegen_ssa::traits::CodegenBackend;
|
use rustc_codegen_ssa::traits::CodegenBackend;
|
||||||
|
@ -347,7 +346,7 @@ pub struct Config {
|
||||||
/// enabled. Makes it so that "please report a bug" is hidden, as ICEs with
|
/// enabled. Makes it so that "please report a bug" is hidden, as ICEs with
|
||||||
/// internal features are wontfix, and they are usually the cause of the ICEs.
|
/// internal features are wontfix, and they are usually the cause of the ICEs.
|
||||||
/// None signifies that this is not tracked.
|
/// None signifies that this is not tracked.
|
||||||
pub using_internal_features: Arc<std::sync::atomic::AtomicBool>,
|
pub using_internal_features: &'static std::sync::atomic::AtomicBool,
|
||||||
|
|
||||||
/// All commandline args used to invoke the compiler, with @file args fully expanded.
|
/// All commandline args used to invoke the compiler, with @file args fully expanded.
|
||||||
/// This will only be used within debug info, e.g. in the pdb file on windows
|
/// This will only be used within debug info, e.g. in the pdb file on windows
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
use std::collections::{BTreeMap, BTreeSet};
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
use std::num::NonZero;
|
use std::num::NonZero;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::Arc;
|
use std::sync::atomic::AtomicBool;
|
||||||
|
|
||||||
use rustc_data_structures::profiling::TimePassesFormat;
|
use rustc_data_structures::profiling::TimePassesFormat;
|
||||||
use rustc_errors::emitter::HumanReadableErrorType;
|
use rustc_errors::emitter::HumanReadableErrorType;
|
||||||
|
@ -62,6 +62,8 @@ where
|
||||||
temps_dir,
|
temps_dir,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static USING_INTERNAL_FEATURES: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
let sess = build_session(
|
let sess = build_session(
|
||||||
early_dcx,
|
early_dcx,
|
||||||
sessopts,
|
sessopts,
|
||||||
|
@ -74,7 +76,7 @@ where
|
||||||
sysroot,
|
sysroot,
|
||||||
"",
|
"",
|
||||||
None,
|
None,
|
||||||
Arc::default(),
|
&USING_INTERNAL_FEATURES,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
);
|
);
|
||||||
let cfg = parse_cfg(sess.dcx(), matches.opt_strs("cfg"));
|
let cfg = parse_cfg(sess.dcx(), matches.opt_strs("cfg"));
|
||||||
|
|
|
@ -189,7 +189,7 @@ pub struct Session {
|
||||||
/// enabled. Makes it so that "please report a bug" is hidden, as ICEs with
|
/// enabled. Makes it so that "please report a bug" is hidden, as ICEs with
|
||||||
/// internal features are wontfix, and they are usually the cause of the ICEs.
|
/// internal features are wontfix, and they are usually the cause of the ICEs.
|
||||||
/// None signifies that this is not tracked.
|
/// None signifies that this is not tracked.
|
||||||
pub using_internal_features: Arc<AtomicBool>,
|
pub using_internal_features: &'static AtomicBool,
|
||||||
|
|
||||||
/// All commandline args used to invoke the compiler, with @file args fully expanded.
|
/// All commandline args used to invoke the compiler, with @file args fully expanded.
|
||||||
/// This will only be used within debug info, e.g. in the pdb file on windows
|
/// This will only be used within debug info, e.g. in the pdb file on windows
|
||||||
|
@ -966,7 +966,7 @@ pub fn build_session(
|
||||||
sysroot: PathBuf,
|
sysroot: PathBuf,
|
||||||
cfg_version: &'static str,
|
cfg_version: &'static str,
|
||||||
ice_file: Option<PathBuf>,
|
ice_file: Option<PathBuf>,
|
||||||
using_internal_features: Arc<AtomicBool>,
|
using_internal_features: &'static AtomicBool,
|
||||||
expanded_args: Vec<String>,
|
expanded_args: Vec<String>,
|
||||||
) -> Session {
|
) -> Session {
|
||||||
// FIXME: This is not general enough to make the warning lint completely override
|
// FIXME: This is not general enough to make the warning lint completely override
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::LazyLock;
|
||||||
use std::sync::{Arc, LazyLock};
|
|
||||||
use std::{io, mem};
|
use std::{io, mem};
|
||||||
|
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_data_structures::unord::UnordSet;
|
use rustc_data_structures::unord::UnordSet;
|
||||||
|
use rustc_driver::USING_INTERNAL_FEATURES;
|
||||||
use rustc_errors::TerminalUrl;
|
use rustc_errors::TerminalUrl;
|
||||||
use rustc_errors::codes::*;
|
use rustc_errors::codes::*;
|
||||||
use rustc_errors::emitter::{
|
use rustc_errors::emitter::{
|
||||||
|
@ -221,7 +221,6 @@ pub(crate) fn create_config(
|
||||||
..
|
..
|
||||||
}: RustdocOptions,
|
}: RustdocOptions,
|
||||||
RenderOptions { document_private, .. }: &RenderOptions,
|
RenderOptions { document_private, .. }: &RenderOptions,
|
||||||
using_internal_features: Arc<AtomicBool>,
|
|
||||||
) -> rustc_interface::Config {
|
) -> rustc_interface::Config {
|
||||||
// Add the doc cfg into the doc build.
|
// Add the doc cfg into the doc build.
|
||||||
cfgs.push("doc".to_string());
|
cfgs.push("doc".to_string());
|
||||||
|
@ -316,7 +315,7 @@ pub(crate) fn create_config(
|
||||||
make_codegen_backend: None,
|
make_codegen_backend: None,
|
||||||
registry: rustc_driver::diagnostics_registry(),
|
registry: rustc_driver::diagnostics_registry(),
|
||||||
ice_file: None,
|
ice_file: None,
|
||||||
using_internal_features,
|
using_internal_features: &USING_INTERNAL_FEATURES,
|
||||||
expanded_args,
|
expanded_args,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,7 +193,7 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions
|
||||||
make_codegen_backend: None,
|
make_codegen_backend: None,
|
||||||
registry: rustc_driver::diagnostics_registry(),
|
registry: rustc_driver::diagnostics_registry(),
|
||||||
ice_file: None,
|
ice_file: None,
|
||||||
using_internal_features: Arc::default(),
|
using_internal_features: &rustc_driver::USING_INTERNAL_FEATURES,
|
||||||
expanded_args: options.expanded_args.clone(),
|
expanded_args: options.expanded_args.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,6 @@ extern crate tikv_jemalloc_sys as jemalloc_sys;
|
||||||
use std::env::{self, VarError};
|
use std::env::{self, VarError};
|
||||||
use std::io::{self, IsTerminal};
|
use std::io::{self, IsTerminal};
|
||||||
use std::process;
|
use std::process;
|
||||||
use std::sync::Arc;
|
|
||||||
use std::sync::atomic::AtomicBool;
|
|
||||||
|
|
||||||
use rustc_errors::DiagCtxtHandle;
|
use rustc_errors::DiagCtxtHandle;
|
||||||
use rustc_interface::interface;
|
use rustc_interface::interface;
|
||||||
|
@ -158,7 +156,7 @@ pub fn main() {
|
||||||
|
|
||||||
let mut early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
|
let mut early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
|
||||||
|
|
||||||
let using_internal_features = rustc_driver::install_ice_hook(
|
rustc_driver::install_ice_hook(
|
||||||
"https://github.com/rust-lang/rust/issues/new\
|
"https://github.com/rust-lang/rust/issues/new\
|
||||||
?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md",
|
?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md",
|
||||||
|_| (),
|
|_| (),
|
||||||
|
@ -179,7 +177,7 @@ pub fn main() {
|
||||||
|
|
||||||
let exit_code = rustc_driver::catch_with_exit_code(|| {
|
let exit_code = rustc_driver::catch_with_exit_code(|| {
|
||||||
let at_args = rustc_driver::args::raw_args(&early_dcx)?;
|
let at_args = rustc_driver::args::raw_args(&early_dcx)?;
|
||||||
main_args(&mut early_dcx, &at_args, using_internal_features);
|
main_args(&mut early_dcx, &at_args);
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
process::exit(exit_code);
|
process::exit(exit_code);
|
||||||
|
@ -768,11 +766,7 @@ fn run_merge_finalize(opt: config::RenderOptions) -> Result<(), error::Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main_args(
|
fn main_args(early_dcx: &mut EarlyDiagCtxt, at_args: &[String]) {
|
||||||
early_dcx: &mut EarlyDiagCtxt,
|
|
||||||
at_args: &[String],
|
|
||||||
using_internal_features: Arc<AtomicBool>,
|
|
||||||
) {
|
|
||||||
// Throw away the first argument, the name of the binary.
|
// Throw away the first argument, the name of the binary.
|
||||||
// In case of at_args being empty, as might be the case by
|
// In case of at_args being empty, as might be the case by
|
||||||
// passing empty argument array to execve under some platforms,
|
// passing empty argument array to execve under some platforms,
|
||||||
|
@ -825,8 +819,7 @@ fn main_args(
|
||||||
(false, Some(md_input)) => {
|
(false, Some(md_input)) => {
|
||||||
let md_input = md_input.to_owned();
|
let md_input = md_input.to_owned();
|
||||||
let edition = options.edition;
|
let edition = options.edition;
|
||||||
let config =
|
let config = core::create_config(input, options, &render_options);
|
||||||
core::create_config(input, options, &render_options, using_internal_features);
|
|
||||||
|
|
||||||
// `markdown::render` can invoke `doctest::make_test`, which
|
// `markdown::render` can invoke `doctest::make_test`, which
|
||||||
// requires session globals and a thread pool, so we use
|
// requires session globals and a thread pool, so we use
|
||||||
|
@ -859,7 +852,7 @@ fn main_args(
|
||||||
let scrape_examples_options = options.scrape_examples_options.clone();
|
let scrape_examples_options = options.scrape_examples_options.clone();
|
||||||
let bin_crate = options.bin_crate;
|
let bin_crate = options.bin_crate;
|
||||||
|
|
||||||
let config = core::create_config(input, options, &render_options, using_internal_features);
|
let config = core::create_config(input, options, &render_options);
|
||||||
|
|
||||||
let registered_lints = config.register_lints.is_some();
|
let registered_lints = config.register_lints.is_some();
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ pub fn main() {
|
||||||
|
|
||||||
rustc_driver::init_rustc_env_logger(&early_dcx);
|
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
|
// 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
|
// as simple as moving the call from the hook to main, because `install_ice_hook` doesn't
|
||||||
// accept a generic closure.
|
// accept a generic closure.
|
||||||
|
@ -295,13 +295,9 @@ pub fn main() {
|
||||||
let clippy_enabled = !cap_lints_allow && relevant_package && !info_query;
|
let clippy_enabled = !cap_lints_allow && relevant_package && !info_query;
|
||||||
if clippy_enabled {
|
if clippy_enabled {
|
||||||
args.extend(clippy_args);
|
args.extend(clippy_args);
|
||||||
rustc_driver::RunCompiler::new(&args, &mut ClippyCallbacks { clippy_args_var })
|
rustc_driver::RunCompiler::new(&args, &mut ClippyCallbacks { clippy_args_var }).run();
|
||||||
.set_using_internal_features(using_internal_features)
|
|
||||||
.run();
|
|
||||||
} else {
|
} else {
|
||||||
rustc_driver::RunCompiler::new(&args, &mut RustcCallbacks { clippy_args_var })
|
rustc_driver::RunCompiler::new(&args, &mut RustcCallbacks { clippy_args_var }).run();
|
||||||
.set_using_internal_features(using_internal_features)
|
|
||||||
.run();
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -30,7 +30,7 @@ use std::ops::Range;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::atomic::{AtomicI32, Ordering};
|
use std::sync::atomic::{AtomicI32, Ordering};
|
||||||
use std::sync::{Arc, Once};
|
use std::sync::Once;
|
||||||
|
|
||||||
use miri::{
|
use miri::{
|
||||||
BacktraceStyle, BorrowTrackerMethod, MiriConfig, MiriEntryFnType,ProvenanceMode, RetagFields, ValidationMode,
|
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(
|
fn run_compiler_and_exit(
|
||||||
args: &[String],
|
args: &[String],
|
||||||
callbacks: &mut (dyn rustc_driver::Callbacks + Send),
|
callbacks: &mut (dyn rustc_driver::Callbacks + Send),
|
||||||
using_internal_features: Arc<std::sync::atomic::AtomicBool>,
|
|
||||||
) -> ! {
|
) -> ! {
|
||||||
// Invoke compiler, and handle return code.
|
// Invoke compiler, and handle return code.
|
||||||
let exit_code = rustc_driver::catch_with_exit_code(move || {
|
let exit_code = rustc_driver::catch_with_exit_code(move || {
|
||||||
rustc_driver::RunCompiler::new(args, callbacks)
|
rustc_driver::RunCompiler::new(args, callbacks).run();
|
||||||
.set_using_internal_features(using_internal_features)
|
|
||||||
.run();
|
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
std::process::exit(exit_code)
|
std::process::exit(exit_code)
|
||||||
|
@ -467,8 +464,7 @@ fn main() {
|
||||||
// If the environment asks us to actually be rustc, then do that.
|
// If the environment asks us to actually be rustc, then do that.
|
||||||
if let Some(crate_kind) = env::var_os("MIRI_BE_RUSTC") {
|
if let Some(crate_kind) = env::var_os("MIRI_BE_RUSTC") {
|
||||||
// Earliest rustc setup.
|
// 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);
|
rustc_driver::init_rustc_env_logger(&early_dcx);
|
||||||
|
|
||||||
let target_crate = if crate_kind == "target" {
|
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.
|
// We cannot use `rustc_driver::main` as we want it to use `args` as the CLI arguments.
|
||||||
run_compiler_and_exit(
|
run_compiler_and_exit(&args, &mut MiriBeRustCompilerCalls { target_crate })
|
||||||
&args,
|
|
||||||
&mut MiriBeRustCompilerCalls { target_crate },
|
|
||||||
using_internal_features,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add an ICE bug report hook.
|
// 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 loggers the Miri way.
|
||||||
init_early_loggers(&early_dcx);
|
init_early_loggers(&early_dcx);
|
||||||
|
@ -735,9 +726,5 @@ fn main() {
|
||||||
|
|
||||||
debug!("rustc arguments: {:?}", rustc_args);
|
debug!("rustc arguments: {:?}", rustc_args);
|
||||||
debug!("crate arguments: {:?}", miri_config.args);
|
debug!("crate arguments: {:?}", miri_config.args);
|
||||||
run_compiler_and_exit(
|
run_compiler_and_exit(&rustc_args, &mut MiriCompilerCalls::new(miri_config, many_seeds))
|
||||||
&rustc_args,
|
|
||||||
&mut MiriCompilerCalls::new(miri_config, many_seeds),
|
|
||||||
using_internal_features,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf, linker: Option<&Path
|
||||||
override_queries: None,
|
override_queries: None,
|
||||||
make_codegen_backend: None,
|
make_codegen_backend: None,
|
||||||
registry: rustc_driver::diagnostics_registry(),
|
registry: rustc_driver::diagnostics_registry(),
|
||||||
using_internal_features: std::sync::Arc::default(),
|
using_internal_features: &rustc_driver::USING_INTERNAL_FEATURES,
|
||||||
expanded_args: Default::default(),
|
expanded_args: Default::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue