mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-01 01:23:26 +00:00
Rename EarlyErrorHandler
as EarlyDiagCtxt
.
This commit is contained in:
parent
45f347681d
commit
cce1701c4c
@ -176,7 +176,7 @@ pub(crate) fn compile_fn(
|
||||
match module.define_function(codegened_func.func_id, context) {
|
||||
Ok(()) => {}
|
||||
Err(ModuleError::Compilation(CodegenError::ImplLimitExceeded)) => {
|
||||
let handler = rustc_session::EarlyErrorHandler::new(
|
||||
let handler = rustc_session::EarlyDiagCtxt::new(
|
||||
rustc_session::config::ErrorOutputType::default(),
|
||||
);
|
||||
handler.early_error(format!(
|
||||
|
@ -231,9 +231,8 @@ pub(crate) fn write_ir_file(
|
||||
let res = std::fs::File::create(clif_file_name).and_then(|mut file| write(&mut file));
|
||||
if let Err(err) = res {
|
||||
// Using early_warn as no Session is available here
|
||||
let handler = rustc_session::EarlyErrorHandler::new(
|
||||
rustc_session::config::ErrorOutputType::default(),
|
||||
);
|
||||
let handler =
|
||||
rustc_session::EarlyDiagCtxt::new(rustc_session::config::ErrorOutputType::default());
|
||||
handler.early_warn(format!("error writing ir file: {}", err));
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use std::fmt;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
|
||||
use rustc_session::EarlyErrorHandler;
|
||||
use rustc_session::EarlyDiagCtxt;
|
||||
|
||||
fn arg_expand(arg: String) -> Result<Vec<String>, Error> {
|
||||
if let Some(path) = arg.strip_prefix('@') {
|
||||
@ -23,7 +23,7 @@ fn arg_expand(arg: String) -> Result<Vec<String>, Error> {
|
||||
/// **Note:** This function doesn't interpret argument 0 in any special way.
|
||||
/// If this function is intended to be used with command line arguments,
|
||||
/// `argv[0]` must be removed prior to calling it manually.
|
||||
pub fn arg_expand_all(handler: &EarlyErrorHandler, at_args: &[String]) -> Vec<String> {
|
||||
pub fn arg_expand_all(handler: &EarlyDiagCtxt, at_args: &[String]) -> Vec<String> {
|
||||
let mut args = Vec::new();
|
||||
for arg in at_args {
|
||||
match arg_expand(arg.clone()) {
|
||||
|
@ -38,7 +38,7 @@ use rustc_session::config::{nightly_options, CG_OPTIONS, Z_OPTIONS};
|
||||
use rustc_session::config::{ErrorOutputType, Input, OutFileName, OutputType, TrimmedDefPaths};
|
||||
use rustc_session::getopts::{self, Matches};
|
||||
use rustc_session::lint::{Lint, LintId};
|
||||
use rustc_session::{config, EarlyErrorHandler, Session};
|
||||
use rustc_session::{config, EarlyDiagCtxt, Session};
|
||||
use rustc_span::def_id::LOCAL_CRATE;
|
||||
use rustc_span::source_map::FileLoader;
|
||||
use rustc_span::symbol::sym;
|
||||
@ -291,7 +291,7 @@ fn run_compiler(
|
||||
>,
|
||||
using_internal_features: Arc<std::sync::atomic::AtomicBool>,
|
||||
) -> interface::Result<()> {
|
||||
let mut default_handler = EarlyErrorHandler::new(ErrorOutputType::default());
|
||||
let mut default_handler = EarlyDiagCtxt::new(ErrorOutputType::default());
|
||||
|
||||
// Throw away the first argument, the name of the binary.
|
||||
// In case of at_args being empty, as might be the case by
|
||||
@ -369,7 +369,7 @@ fn run_compiler(
|
||||
return sess.compile_status();
|
||||
}
|
||||
|
||||
let handler = EarlyErrorHandler::new(sess.opts.error_format);
|
||||
let handler = EarlyDiagCtxt::new(sess.opts.error_format);
|
||||
|
||||
if print_crate_info(&handler, codegen_backend, sess, has_input) == Compilation::Stop {
|
||||
return sess.compile_status();
|
||||
@ -495,7 +495,7 @@ fn make_output(matches: &getopts::Matches) -> (Option<PathBuf>, Option<OutFileNa
|
||||
|
||||
// Extract input (string or file and optional path) from matches.
|
||||
fn make_input(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
free_matches: &[String],
|
||||
) -> Result<Option<Input>, ErrorGuaranteed> {
|
||||
if free_matches.len() == 1 {
|
||||
@ -537,7 +537,7 @@ pub enum Compilation {
|
||||
Continue,
|
||||
}
|
||||
|
||||
fn handle_explain(handler: &EarlyErrorHandler, registry: Registry, code: &str, color: ColorConfig) {
|
||||
fn handle_explain(handler: &EarlyDiagCtxt, registry: Registry, code: &str, color: ColorConfig) {
|
||||
let upper_cased_code = code.to_ascii_uppercase();
|
||||
let normalised =
|
||||
if upper_cased_code.starts_with('E') { upper_cased_code } else { format!("E{code:0>4}") };
|
||||
@ -669,11 +669,7 @@ fn process_rlink(sess: &Session, compiler: &interface::Compiler) {
|
||||
}
|
||||
}
|
||||
|
||||
fn list_metadata(
|
||||
handler: &EarlyErrorHandler,
|
||||
sess: &Session,
|
||||
metadata_loader: &dyn MetadataLoader,
|
||||
) {
|
||||
fn list_metadata(handler: &EarlyDiagCtxt, sess: &Session, metadata_loader: &dyn MetadataLoader) {
|
||||
match sess.io.input {
|
||||
Input::File(ref ifile) => {
|
||||
let path = &(*ifile);
|
||||
@ -695,7 +691,7 @@ fn list_metadata(
|
||||
}
|
||||
|
||||
fn print_crate_info(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
codegen_backend: &dyn CodegenBackend,
|
||||
sess: &Session,
|
||||
parse_attrs: bool,
|
||||
@ -873,7 +869,7 @@ pub macro version($handler: expr, $binary: literal, $matches: expr) {
|
||||
|
||||
#[doc(hidden)] // use the macro instead
|
||||
pub fn version_at_macro_invocation(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
binary: &str,
|
||||
matches: &getopts::Matches,
|
||||
version: &str,
|
||||
@ -1072,7 +1068,7 @@ Available lint options:
|
||||
/// Show help for flag categories shared between rustdoc and rustc.
|
||||
///
|
||||
/// Returns whether a help option was printed.
|
||||
pub fn describe_flag_categories(handler: &EarlyErrorHandler, matches: &Matches) -> bool {
|
||||
pub fn describe_flag_categories(handler: &EarlyDiagCtxt, matches: &Matches) -> bool {
|
||||
// Handle the special case of -Wall.
|
||||
let wall = matches.opt_strs("W");
|
||||
if wall.iter().any(|x| *x == "all") {
|
||||
@ -1160,7 +1156,7 @@ fn print_flag_list<T>(
|
||||
/// This does not need to be `pub` for rustc itself, but @chaosite needs it to
|
||||
/// be public when using rustc as a library, see
|
||||
/// <https://github.com/rust-lang/rust/commit/2b4c33817a5aaecabf4c6598d41e190080ec119e>
|
||||
pub fn handle_options(handler: &EarlyErrorHandler, args: &[String]) -> Option<getopts::Matches> {
|
||||
pub fn handle_options(handler: &EarlyDiagCtxt, args: &[String]) -> Option<getopts::Matches> {
|
||||
if args.is_empty() {
|
||||
// user did not write `-v` nor `-Z unstable-options`, so do not
|
||||
// include that extra information.
|
||||
@ -1336,7 +1332,7 @@ pub fn install_ice_hook(
|
||||
if msg.starts_with("failed printing to stdout: ") && msg.ends_with("(os error 232)")
|
||||
{
|
||||
// the error code is already going to be reported when the panic unwinds up the stack
|
||||
let handler = EarlyErrorHandler::new(ErrorOutputType::default());
|
||||
let handler = EarlyDiagCtxt::new(ErrorOutputType::default());
|
||||
let _ = handler.early_error_no_abort(msg.clone());
|
||||
return;
|
||||
}
|
||||
@ -1476,14 +1472,14 @@ fn report_ice(
|
||||
|
||||
/// This allows tools to enable rust logging without having to magically match rustc's
|
||||
/// tracing crate version.
|
||||
pub fn init_rustc_env_logger(handler: &EarlyErrorHandler) {
|
||||
pub fn init_rustc_env_logger(handler: &EarlyDiagCtxt) {
|
||||
init_logger(handler, rustc_log::LoggerConfig::from_env("RUSTC_LOG"));
|
||||
}
|
||||
|
||||
/// This allows tools to enable rust logging without having to magically match rustc's
|
||||
/// tracing crate version. In contrast to `init_rustc_env_logger` it allows you to choose
|
||||
/// the values directly rather than having to set an environment variable.
|
||||
pub fn init_logger(handler: &EarlyErrorHandler, cfg: rustc_log::LoggerConfig) {
|
||||
pub fn init_logger(handler: &EarlyDiagCtxt, cfg: rustc_log::LoggerConfig) {
|
||||
if let Err(error) = rustc_log::init_logger(cfg) {
|
||||
handler.early_error(error.to_string());
|
||||
}
|
||||
@ -1493,7 +1489,7 @@ pub fn main() -> ! {
|
||||
let start_time = Instant::now();
|
||||
let start_rss = get_resident_set_size();
|
||||
|
||||
let handler = EarlyErrorHandler::new(ErrorOutputType::default());
|
||||
let handler = EarlyDiagCtxt::new(ErrorOutputType::default());
|
||||
|
||||
init_rustc_env_logger(&handler);
|
||||
signal_handler::install();
|
||||
|
@ -18,7 +18,7 @@ use rustc_query_system::query::print_query_stack;
|
||||
use rustc_session::config::{self, Cfg, CheckCfg, ExpectedValues, Input, OutFileName};
|
||||
use rustc_session::filesearch::sysroot_candidates;
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_session::{lint, CompilerIO, EarlyErrorHandler, Session};
|
||||
use rustc_session::{lint, CompilerIO, EarlyDiagCtxt, Session};
|
||||
use rustc_span::source_map::FileLoader;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::FileName;
|
||||
@ -317,7 +317,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
|
||||
rustc_data_structures::sync::set_dyn_thread_safe_mode(config.opts.unstable_opts.threads > 1);
|
||||
|
||||
// Check jobserver before run_in_thread_pool_with_globals, which call jobserver::acquire_thread
|
||||
let early_handler = EarlyErrorHandler::new(config.opts.error_format);
|
||||
let early_handler = EarlyDiagCtxt::new(config.opts.error_format);
|
||||
early_handler.initialize_checked_jobserver();
|
||||
|
||||
util::run_in_thread_pool_with_globals(
|
||||
@ -326,7 +326,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
|
||||
|| {
|
||||
crate::callbacks::setup_callbacks();
|
||||
|
||||
let early_handler = EarlyErrorHandler::new(config.opts.error_format);
|
||||
let early_handler = EarlyDiagCtxt::new(config.opts.error_format);
|
||||
|
||||
let codegen_backend = if let Some(make_codegen_backend) = config.make_codegen_backend {
|
||||
make_codegen_backend(&config.opts)
|
||||
|
@ -13,7 +13,7 @@ use rustc_session::config::{
|
||||
use rustc_session::lint::Level;
|
||||
use rustc_session::search_paths::SearchPath;
|
||||
use rustc_session::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
|
||||
use rustc_session::{build_session, getopts, CompilerIO, EarlyErrorHandler, Session};
|
||||
use rustc_session::{build_session, getopts, CompilerIO, EarlyDiagCtxt, Session};
|
||||
use rustc_span::edition::{Edition, DEFAULT_EDITION};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::{FileName, SourceFileHashAlgorithm};
|
||||
@ -25,7 +25,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
|
||||
fn mk_session(matches: getopts::Matches) -> (Session, Cfg) {
|
||||
let mut early_handler = EarlyErrorHandler::new(ErrorOutputType::default());
|
||||
let mut early_handler = EarlyDiagCtxt::new(ErrorOutputType::default());
|
||||
early_handler.initialize_checked_jobserver();
|
||||
|
||||
let registry = registry::Registry::new(&[]);
|
||||
@ -301,7 +301,7 @@ fn test_search_paths_tracking_hash_different_order() {
|
||||
let mut v3 = Options::default();
|
||||
let mut v4 = Options::default();
|
||||
|
||||
let handler = EarlyErrorHandler::new(JSON);
|
||||
let handler = EarlyDiagCtxt::new(JSON);
|
||||
const JSON: ErrorOutputType = ErrorOutputType::Json {
|
||||
pretty: false,
|
||||
json_rendered: HumanReadableErrorType::Default(ColorConfig::Never),
|
||||
@ -854,7 +854,7 @@ fn test_edition_parsing() {
|
||||
let options = Options::default();
|
||||
assert!(options.edition == DEFAULT_EDITION);
|
||||
|
||||
let mut handler = EarlyErrorHandler::new(ErrorOutputType::default());
|
||||
let mut handler = EarlyDiagCtxt::new(ErrorOutputType::default());
|
||||
|
||||
let matches = optgroups().parse(&["--edition=2018".to_string()]).unwrap();
|
||||
let sessopts = build_session_options(&mut handler, &matches);
|
||||
|
@ -14,7 +14,7 @@ use rustc_session::{filesearch, output, Session};
|
||||
use rustc_span::edit_distance::find_best_match_for_name;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use session::EarlyErrorHandler;
|
||||
use session::EarlyDiagCtxt;
|
||||
use std::env;
|
||||
use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
|
||||
use std::mem;
|
||||
@ -161,7 +161,7 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
|
||||
})
|
||||
}
|
||||
|
||||
fn load_backend_from_dylib(handler: &EarlyErrorHandler, path: &Path) -> MakeBackendFn {
|
||||
fn load_backend_from_dylib(handler: &EarlyDiagCtxt, path: &Path) -> MakeBackendFn {
|
||||
let lib = unsafe { Library::new(path) }.unwrap_or_else(|err| {
|
||||
let err = format!("couldn't load codegen backend {path:?}: {err}");
|
||||
handler.early_error(err);
|
||||
@ -185,7 +185,7 @@ fn load_backend_from_dylib(handler: &EarlyErrorHandler, path: &Path) -> MakeBack
|
||||
///
|
||||
/// A name of `None` indicates that the default backend should be used.
|
||||
pub fn get_codegen_backend(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
maybe_sysroot: &Option<PathBuf>,
|
||||
backend_name: Option<&str>,
|
||||
) -> Box<dyn CodegenBackend> {
|
||||
@ -233,7 +233,7 @@ fn get_rustc_path_inner(bin_path: &str) -> Option<PathBuf> {
|
||||
}
|
||||
|
||||
fn get_codegen_sysroot(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
maybe_sysroot: &Option<PathBuf>,
|
||||
backend_name: &str,
|
||||
) -> MakeBackendFn {
|
||||
|
@ -7,7 +7,7 @@ use crate::errors::FileWriteFail;
|
||||
use crate::search_paths::SearchPath;
|
||||
use crate::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
|
||||
use crate::{lint, HashStableContext};
|
||||
use crate::{EarlyErrorHandler, Session};
|
||||
use crate::{EarlyDiagCtxt, Session};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
|
||||
use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey};
|
||||
use rustc_errors::emitter::HumanReadableErrorType;
|
||||
@ -1584,7 +1584,7 @@ pub fn build_configuration(sess: &Session, mut user_cfg: Cfg) -> Cfg {
|
||||
}
|
||||
|
||||
pub(super) fn build_target_config(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
opts: &Options,
|
||||
target_override: Option<Target>,
|
||||
sysroot: &Path,
|
||||
@ -1844,7 +1844,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
|
||||
}
|
||||
|
||||
pub fn get_cmd_lint_options(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
matches: &getopts::Matches,
|
||||
) -> (Vec<(String, lint::Level)>, bool, Option<lint::Level>) {
|
||||
let mut lint_opts_with_position = vec![];
|
||||
@ -1876,7 +1876,7 @@ pub fn get_cmd_lint_options(
|
||||
}
|
||||
|
||||
/// Parses the `--color` flag.
|
||||
pub fn parse_color(handler: &EarlyErrorHandler, matches: &getopts::Matches) -> ColorConfig {
|
||||
pub fn parse_color(handler: &EarlyDiagCtxt, matches: &getopts::Matches) -> ColorConfig {
|
||||
match matches.opt_str("color").as_deref() {
|
||||
Some("auto") => ColorConfig::Auto,
|
||||
Some("always") => ColorConfig::Always,
|
||||
@ -1930,7 +1930,7 @@ impl JsonUnusedExterns {
|
||||
///
|
||||
/// The first value returned is how to render JSON diagnostics, and the second
|
||||
/// is whether or not artifact notifications are enabled.
|
||||
pub fn parse_json(handler: &EarlyErrorHandler, matches: &getopts::Matches) -> JsonConfig {
|
||||
pub fn parse_json(handler: &EarlyDiagCtxt, matches: &getopts::Matches) -> JsonConfig {
|
||||
let mut json_rendered: fn(ColorConfig) -> HumanReadableErrorType =
|
||||
HumanReadableErrorType::Default;
|
||||
let mut json_color = ColorConfig::Never;
|
||||
@ -1968,7 +1968,7 @@ pub fn parse_json(handler: &EarlyErrorHandler, matches: &getopts::Matches) -> Js
|
||||
|
||||
/// Parses the `--error-format` flag.
|
||||
pub fn parse_error_format(
|
||||
handler: &mut EarlyErrorHandler,
|
||||
handler: &mut EarlyDiagCtxt,
|
||||
matches: &getopts::Matches,
|
||||
color: ColorConfig,
|
||||
json_rendered: HumanReadableErrorType,
|
||||
@ -2019,7 +2019,7 @@ pub fn parse_error_format(
|
||||
error_format
|
||||
}
|
||||
|
||||
pub fn parse_crate_edition(handler: &EarlyErrorHandler, matches: &getopts::Matches) -> Edition {
|
||||
pub fn parse_crate_edition(handler: &EarlyDiagCtxt, matches: &getopts::Matches) -> Edition {
|
||||
let edition = match matches.opt_str("edition") {
|
||||
Some(arg) => Edition::from_str(&arg).unwrap_or_else(|_| {
|
||||
handler.early_error(format!(
|
||||
@ -2046,7 +2046,7 @@ pub fn parse_crate_edition(handler: &EarlyErrorHandler, matches: &getopts::Match
|
||||
}
|
||||
|
||||
fn check_error_format_stability(
|
||||
handler: &mut EarlyErrorHandler,
|
||||
handler: &mut EarlyDiagCtxt,
|
||||
unstable_opts: &UnstableOptions,
|
||||
error_format: ErrorOutputType,
|
||||
json_rendered: HumanReadableErrorType,
|
||||
@ -2072,7 +2072,7 @@ fn check_error_format_stability(
|
||||
}
|
||||
|
||||
fn parse_output_types(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
unstable_opts: &UnstableOptions,
|
||||
matches: &getopts::Matches,
|
||||
) -> OutputTypes {
|
||||
@ -2106,7 +2106,7 @@ fn split_out_file_name(arg: &str) -> (&str, Option<OutFileName>) {
|
||||
}
|
||||
|
||||
fn should_override_cgus_and_disable_thinlto(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
output_types: &OutputTypes,
|
||||
matches: &getopts::Matches,
|
||||
mut codegen_units: Option<usize>,
|
||||
@ -2151,7 +2151,7 @@ fn should_override_cgus_and_disable_thinlto(
|
||||
}
|
||||
|
||||
fn collect_print_requests(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
cg: &mut CodegenOptions,
|
||||
unstable_opts: &mut UnstableOptions,
|
||||
matches: &getopts::Matches,
|
||||
@ -2247,10 +2247,7 @@ fn collect_print_requests(
|
||||
prints
|
||||
}
|
||||
|
||||
pub fn parse_target_triple(
|
||||
handler: &EarlyErrorHandler,
|
||||
matches: &getopts::Matches,
|
||||
) -> TargetTriple {
|
||||
pub fn parse_target_triple(handler: &EarlyDiagCtxt, matches: &getopts::Matches) -> TargetTriple {
|
||||
match matches.opt_str("target") {
|
||||
Some(target) if target.ends_with(".json") => {
|
||||
let path = Path::new(&target);
|
||||
@ -2264,7 +2261,7 @@ pub fn parse_target_triple(
|
||||
}
|
||||
|
||||
fn parse_opt_level(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
matches: &getopts::Matches,
|
||||
cg: &CodegenOptions,
|
||||
) -> OptLevel {
|
||||
@ -2317,7 +2314,7 @@ fn select_debuginfo(matches: &getopts::Matches, cg: &CodegenOptions) -> DebugInf
|
||||
}
|
||||
|
||||
fn parse_assert_incr_state(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
opt_assertion: &Option<String>,
|
||||
) -> Option<IncrementalStateAssertion> {
|
||||
match opt_assertion {
|
||||
@ -2331,7 +2328,7 @@ fn parse_assert_incr_state(
|
||||
}
|
||||
|
||||
fn parse_native_lib_kind(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
matches: &getopts::Matches,
|
||||
kind: &str,
|
||||
) -> (NativeLibKind, Option<bool>) {
|
||||
@ -2366,7 +2363,7 @@ fn parse_native_lib_kind(
|
||||
}
|
||||
|
||||
fn parse_native_lib_modifiers(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
mut kind: NativeLibKind,
|
||||
modifiers: &str,
|
||||
matches: &getopts::Matches,
|
||||
@ -2436,7 +2433,7 @@ fn parse_native_lib_modifiers(
|
||||
(kind, verbatim)
|
||||
}
|
||||
|
||||
fn parse_libs(handler: &EarlyErrorHandler, matches: &getopts::Matches) -> Vec<NativeLib> {
|
||||
fn parse_libs(handler: &EarlyDiagCtxt, matches: &getopts::Matches) -> Vec<NativeLib> {
|
||||
matches
|
||||
.opt_strs("l")
|
||||
.into_iter()
|
||||
@ -2468,7 +2465,7 @@ fn parse_libs(handler: &EarlyErrorHandler, matches: &getopts::Matches) -> Vec<Na
|
||||
}
|
||||
|
||||
pub fn parse_externs(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
matches: &getopts::Matches,
|
||||
unstable_opts: &UnstableOptions,
|
||||
) -> Externs {
|
||||
@ -2596,7 +2593,7 @@ pub fn parse_externs(
|
||||
}
|
||||
|
||||
fn parse_remap_path_prefix(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
matches: &getopts::Matches,
|
||||
unstable_opts: &UnstableOptions,
|
||||
) -> Vec<(PathBuf, PathBuf)> {
|
||||
@ -2619,7 +2616,7 @@ fn parse_remap_path_prefix(
|
||||
}
|
||||
|
||||
fn parse_logical_env(
|
||||
handler: &mut EarlyErrorHandler,
|
||||
handler: &mut EarlyDiagCtxt,
|
||||
matches: &getopts::Matches,
|
||||
) -> FxIndexMap<String, String> {
|
||||
let mut vars = FxIndexMap::default();
|
||||
@ -2637,10 +2634,7 @@ fn parse_logical_env(
|
||||
|
||||
// JUSTIFICATION: before wrapper fn is available
|
||||
#[allow(rustc::bad_opt_access)]
|
||||
pub fn build_session_options(
|
||||
handler: &mut EarlyErrorHandler,
|
||||
matches: &getopts::Matches,
|
||||
) -> Options {
|
||||
pub fn build_session_options(handler: &mut EarlyDiagCtxt, matches: &getopts::Matches) -> Options {
|
||||
let color = parse_color(handler, matches);
|
||||
|
||||
let edition = parse_crate_edition(handler, matches);
|
||||
@ -2959,7 +2953,7 @@ pub fn build_session_options(
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_pretty(handler: &EarlyErrorHandler, unstable_opts: &UnstableOptions) -> Option<PpMode> {
|
||||
fn parse_pretty(handler: &EarlyDiagCtxt, unstable_opts: &UnstableOptions) -> Option<PpMode> {
|
||||
use PpMode::*;
|
||||
|
||||
let first = match unstable_opts.unpretty.as_deref()? {
|
||||
@ -3026,7 +3020,7 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
|
||||
|
||||
pub mod nightly_options {
|
||||
use super::{OptionStability, RustcOptGroup};
|
||||
use crate::EarlyErrorHandler;
|
||||
use crate::EarlyDiagCtxt;
|
||||
use rustc_feature::UnstableFeatures;
|
||||
|
||||
pub fn is_unstable_enabled(matches: &getopts::Matches) -> bool {
|
||||
@ -3043,7 +3037,7 @@ pub mod nightly_options {
|
||||
}
|
||||
|
||||
pub fn check_nightly_options(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
matches: &getopts::Matches,
|
||||
flags: &[RustcOptGroup],
|
||||
) {
|
||||
|
@ -2,7 +2,7 @@ use crate::config::*;
|
||||
|
||||
use crate::search_paths::SearchPath;
|
||||
use crate::utils::NativeLib;
|
||||
use crate::{lint, EarlyErrorHandler};
|
||||
use crate::{lint, EarlyDiagCtxt};
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_data_structures::profiling::TimePassesFormat;
|
||||
use rustc_data_structures::stable_hasher::Hash64;
|
||||
@ -255,7 +255,7 @@ macro_rules! options {
|
||||
|
||||
impl $struct_name {
|
||||
pub fn build(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
matches: &getopts::Matches,
|
||||
) -> $struct_name {
|
||||
build_options(handler, matches, $stat, $prefix, $outputname)
|
||||
@ -319,7 +319,7 @@ type OptionSetter<O> = fn(&mut O, v: Option<&str>) -> bool;
|
||||
type OptionDescrs<O> = &'static [(&'static str, OptionSetter<O>, &'static str, &'static str)];
|
||||
|
||||
fn build_options<O: Default>(
|
||||
handler: &EarlyErrorHandler,
|
||||
handler: &EarlyDiagCtxt,
|
||||
matches: &getopts::Matches,
|
||||
descrs: OptionDescrs<O>,
|
||||
prefix: &str,
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::filesearch::make_target_lib_path;
|
||||
use crate::EarlyErrorHandler;
|
||||
use crate::EarlyDiagCtxt;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@ -46,7 +46,7 @@ impl PathKind {
|
||||
}
|
||||
|
||||
impl SearchPath {
|
||||
pub fn from_cli_opt(handler: &EarlyErrorHandler, path: &str) -> Self {
|
||||
pub fn from_cli_opt(handler: &EarlyDiagCtxt, path: &str) -> Self {
|
||||
let (kind, path) = if let Some(stripped) = path.strip_prefix("native=") {
|
||||
(PathKind::Native, stripped)
|
||||
} else if let Some(stripped) = path.strip_prefix("crate=") {
|
||||
|
@ -1357,7 +1357,7 @@ fn default_emitter(
|
||||
// JUSTIFICATION: literally session construction
|
||||
#[allow(rustc::bad_opt_access)]
|
||||
pub fn build_session(
|
||||
early_handler: EarlyErrorHandler,
|
||||
early_handler: EarlyDiagCtxt,
|
||||
sopts: config::Options,
|
||||
io: CompilerIO,
|
||||
bundle: Option<Lrc<rustc_errors::FluentBundle>>,
|
||||
@ -1726,11 +1726,11 @@ enum IncrCompSession {
|
||||
}
|
||||
|
||||
/// A wrapper around an [`DiagCtxt`] that is used for early error emissions.
|
||||
pub struct EarlyErrorHandler {
|
||||
pub struct EarlyDiagCtxt {
|
||||
handler: DiagCtxt,
|
||||
}
|
||||
|
||||
impl EarlyErrorHandler {
|
||||
impl EarlyDiagCtxt {
|
||||
pub fn new(output: ErrorOutputType) -> Self {
|
||||
let emitter = mk_emitter(output);
|
||||
Self { handler: DiagCtxt::with_emitter(emitter) }
|
||||
|
@ -15,7 +15,7 @@ use rustc_session::config::{
|
||||
use rustc_session::getopts;
|
||||
use rustc_session::lint::Level;
|
||||
use rustc_session::search_paths::SearchPath;
|
||||
use rustc_session::EarlyErrorHandler;
|
||||
use rustc_session::EarlyDiagCtxt;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_target::spec::TargetTriple;
|
||||
|
||||
@ -320,7 +320,7 @@ impl Options {
|
||||
/// Parses the given command-line for options. If an error message or other early-return has
|
||||
/// been printed, returns `Err` with the exit code.
|
||||
pub(crate) fn from_matches(
|
||||
handler: &mut EarlyErrorHandler,
|
||||
handler: &mut EarlyDiagCtxt,
|
||||
matches: &getopts::Matches,
|
||||
args: Vec<String>,
|
||||
) -> Result<(Options, RenderOptions), i32> {
|
||||
|
@ -82,7 +82,7 @@ use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_interface::interface;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::config::{make_crate_type_option, ErrorOutputType, RustcOptGroup};
|
||||
use rustc_session::{getopts, EarlyErrorHandler};
|
||||
use rustc_session::{getopts, EarlyDiagCtxt};
|
||||
|
||||
use crate::clean::utils::DOC_RUST_LANG_ORG_CHANNEL;
|
||||
|
||||
@ -157,7 +157,7 @@ pub fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
let mut handler = EarlyErrorHandler::new(ErrorOutputType::default());
|
||||
let mut handler = EarlyDiagCtxt::new(ErrorOutputType::default());
|
||||
|
||||
let using_internal_features = rustc_driver::install_ice_hook(
|
||||
"https://github.com/rust-lang/rust/issues/new\
|
||||
@ -189,7 +189,7 @@ pub fn main() {
|
||||
process::exit(exit_code);
|
||||
}
|
||||
|
||||
fn init_logging(handler: &EarlyErrorHandler) {
|
||||
fn init_logging(handler: &EarlyDiagCtxt) {
|
||||
let color_logs = match std::env::var("RUSTDOC_LOG_COLOR").as_deref() {
|
||||
Ok("always") => true,
|
||||
Ok("never") => false,
|
||||
@ -220,7 +220,7 @@ fn init_logging(handler: &EarlyErrorHandler) {
|
||||
tracing::subscriber::set_global_default(subscriber).unwrap();
|
||||
}
|
||||
|
||||
fn get_args(handler: &EarlyErrorHandler) -> Option<Vec<String>> {
|
||||
fn get_args(handler: &EarlyDiagCtxt) -> Option<Vec<String>> {
|
||||
env::args_os()
|
||||
.enumerate()
|
||||
.map(|(i, arg)| {
|
||||
@ -704,7 +704,7 @@ fn run_renderer<'tcx, T: formats::FormatRenderer<'tcx>>(
|
||||
}
|
||||
|
||||
fn main_args(
|
||||
handler: &mut EarlyErrorHandler,
|
||||
handler: &mut EarlyDiagCtxt,
|
||||
at_args: &[String],
|
||||
using_internal_features: Arc<AtomicBool>,
|
||||
) -> MainResult {
|
||||
|
@ -18,7 +18,7 @@ extern crate rustc_span;
|
||||
use rustc_interface::interface;
|
||||
use rustc_session::config::ErrorOutputType;
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_session::EarlyErrorHandler;
|
||||
use rustc_session::EarlyDiagCtxt;
|
||||
use rustc_span::symbol::Symbol;
|
||||
|
||||
use std::env;
|
||||
@ -174,7 +174,7 @@ const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust-clippy/issues/ne
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[allow(clippy::ignored_unit_patterns)]
|
||||
pub fn main() {
|
||||
let handler = EarlyErrorHandler::new(ErrorOutputType::default());
|
||||
let handler = EarlyDiagCtxt::new(ErrorOutputType::default());
|
||||
|
||||
rustc_driver::init_rustc_env_logger(&handler);
|
||||
|
||||
|
@ -173,7 +173,7 @@ fn parse_args() -> (OutputFormat, PathBuf) {
|
||||
|
||||
fn main() {
|
||||
let handler =
|
||||
rustc_session::EarlyErrorHandler::new(rustc_session::config::ErrorOutputType::default());
|
||||
rustc_session::EarlyDiagCtxt::new(rustc_session::config::ErrorOutputType::default());
|
||||
rustc_driver::init_logger(&handler, rustc_log::LoggerConfig::from_env("RUST_LOG"));
|
||||
let (format, dst) = parse_args();
|
||||
let result = main_with_result(format, &dst);
|
||||
|
@ -35,7 +35,7 @@ use rustc_middle::{
|
||||
};
|
||||
use rustc_session::config::{CrateType, ErrorOutputType, OptLevel};
|
||||
use rustc_session::search_paths::PathKind;
|
||||
use rustc_session::{CtfeBacktrace, EarlyErrorHandler};
|
||||
use rustc_session::{CtfeBacktrace, EarlyDiagCtxt};
|
||||
|
||||
use miri::{BacktraceStyle, BorrowTrackerMethod, ProvenanceMode, RetagFields};
|
||||
|
||||
@ -69,7 +69,7 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
|
||||
tcx.sess.fatal("miri cannot be run on programs that fail compilation");
|
||||
}
|
||||
|
||||
let handler = EarlyErrorHandler::new(tcx.sess.opts.error_format);
|
||||
let handler = EarlyDiagCtxt::new(tcx.sess.opts.error_format);
|
||||
init_late_loggers(&handler, tcx);
|
||||
if !tcx.crate_types().contains(&CrateType::Executable) {
|
||||
tcx.sess.fatal("miri only makes sense on bin crates");
|
||||
@ -215,7 +215,7 @@ fn rustc_logger_config() -> rustc_log::LoggerConfig {
|
||||
cfg
|
||||
}
|
||||
|
||||
fn init_early_loggers(handler: &EarlyErrorHandler) {
|
||||
fn init_early_loggers(handler: &EarlyDiagCtxt) {
|
||||
// Note that our `extern crate log` is *not* the same as rustc's; as a result, we have to
|
||||
// initialize them both, and we always initialize `miri`'s first.
|
||||
let env = env_logger::Env::new().filter("MIRI_LOG").write_style("MIRI_LOG_STYLE");
|
||||
@ -228,7 +228,7 @@ fn init_early_loggers(handler: &EarlyErrorHandler) {
|
||||
}
|
||||
}
|
||||
|
||||
fn init_late_loggers(handler: &EarlyErrorHandler, tcx: TyCtxt<'_>) {
|
||||
fn init_late_loggers(handler: &EarlyDiagCtxt, tcx: TyCtxt<'_>) {
|
||||
// If `RUSTC_LOG` is not set, then `init_early_loggers` did not call
|
||||
// `rustc_driver::init_logger`, so we have to do this now.
|
||||
if env::var_os("RUSTC_LOG").is_none() {
|
||||
@ -300,7 +300,7 @@ fn parse_comma_list<T: FromStr>(input: &str) -> Result<Vec<T>, T::Err> {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let handler = EarlyErrorHandler::new(ErrorOutputType::default());
|
||||
let handler = EarlyDiagCtxt::new(ErrorOutputType::default());
|
||||
|
||||
// Snapshot a copy of the environment before `rustc` starts messing with it.
|
||||
// (`install_ice_hook` might change `RUST_BACKTRACE`.)
|
||||
|
Loading…
Reference in New Issue
Block a user