errors: generate typed identifiers in each crate
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
f9216b7564
commit
d1fcf61117
151 changed files with 1721 additions and 1440 deletions
|
@ -23,11 +23,14 @@ use rustc_codegen_ssa::{traits::CodegenBackend, CodegenErrors, CodegenResults};
|
|||
use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
|
||||
use rustc_data_structures::sync::SeqCst;
|
||||
use rustc_errors::registry::{InvalidErrorCode, Registry};
|
||||
use rustc_errors::{ErrorGuaranteed, PResult, TerminalUrl};
|
||||
use rustc_errors::{
|
||||
DiagnosticMessage, ErrorGuaranteed, PResult, SubdiagnosticMessage, TerminalUrl,
|
||||
};
|
||||
use rustc_feature::find_gated_cfg;
|
||||
use rustc_interface::util::{self, collect_crate_types, get_codegen_backend};
|
||||
use rustc_interface::{interface, Queries};
|
||||
use rustc_lint::LintStore;
|
||||
use rustc_macros::fluent_messages;
|
||||
use rustc_metadata::locator;
|
||||
use rustc_session::config::{nightly_options, CG_OPTIONS, Z_OPTIONS};
|
||||
use rustc_session::config::{ErrorOutputType, Input, OutputType, PrintRequest, TrimmedDefPaths};
|
||||
|
@ -61,6 +64,44 @@ use crate::session_diagnostics::{
|
|||
RLinkWrongFileType, RlinkNotAFile, RlinkUnableToRead,
|
||||
};
|
||||
|
||||
fluent_messages! { "../locales/en-US.ftl" }
|
||||
|
||||
pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
|
||||
// tidy-alphabetical-start
|
||||
crate::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_ast_lowering::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_ast_passes::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_attr::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_borrowck::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_builtin_macros::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_codegen_ssa::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_const_eval::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_error_messages::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_expand::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_hir_analysis::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_hir_typeck::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_incremental::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_infer::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_interface::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_lint::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_metadata::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_middle::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_mir_build::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_mir_dataflow::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_monomorphize::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_parse::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_passes::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_plugin_impl::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_privacy::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_query_system::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_resolve::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_session::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_symbol_mangling::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_trait_selection::DEFAULT_LOCALE_RESOURCE,
|
||||
rustc_ty_utils::DEFAULT_LOCALE_RESOURCE,
|
||||
// tidy-alphabetical-end
|
||||
];
|
||||
|
||||
/// Exit status code used for successful compilation and help output.
|
||||
pub const EXIT_SUCCESS: i32 = 0;
|
||||
|
||||
|
@ -218,6 +259,7 @@ fn run_compiler(
|
|||
output_file: ofile,
|
||||
output_dir: odir,
|
||||
file_loader,
|
||||
locale_resources: DEFAULT_LOCALE_RESOURCES,
|
||||
lint_caps: Default::default(),
|
||||
parse_sess_created: None,
|
||||
register_lints: None,
|
||||
|
@ -320,7 +362,7 @@ fn run_compiler(
|
|||
}
|
||||
|
||||
// Make sure name resolution and macro expansion is run.
|
||||
queries.global_ctxt()?.enter(|tcx| tcx.resolver_for_lowering(()));
|
||||
queries.global_ctxt()?;
|
||||
|
||||
if callbacks.after_expansion(compiler, queries) == Compilation::Stop {
|
||||
return early_exit();
|
||||
|
@ -1162,7 +1204,7 @@ static DEFAULT_HOOK: LazyLock<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send +
|
|||
/// hook.
|
||||
pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
|
||||
let fallback_bundle =
|
||||
rustc_errors::fallback_fluent_bundle(rustc_errors::DEFAULT_LOCALE_RESOURCES, false);
|
||||
rustc_errors::fallback_fluent_bundle(crate::DEFAULT_LOCALE_RESOURCES, false);
|
||||
let emitter = Box::new(rustc_errors::emitter::EmitterWriter::stderr(
|
||||
rustc_errors::ColorConfig::Auto,
|
||||
None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue