Rename Handler
as DiagCtxt
.
This commit is contained in:
parent
321b6565a5
commit
cde19c016e
58 changed files with 216 additions and 204 deletions
|
@ -220,7 +220,7 @@ impl<'a> AstValidator<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn err_handler(&self) -> &rustc_errors::Handler {
|
fn err_handler(&self) -> &rustc_errors::DiagCtxt {
|
||||||
self.session.diagnostic()
|
self.session.diagnostic()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,7 +697,7 @@ impl<'a> AstValidator<'a> {
|
||||||
/// Checks that generic parameters are in the correct order,
|
/// Checks that generic parameters are in the correct order,
|
||||||
/// which is lifetimes, then types and then consts. (`<'a, T, const N: usize>`)
|
/// which is lifetimes, then types and then consts. (`<'a, T, const N: usize>`)
|
||||||
fn validate_generic_param_order(
|
fn validate_generic_param_order(
|
||||||
handler: &rustc_errors::Handler,
|
handler: &rustc_errors::DiagCtxt,
|
||||||
generics: &[GenericParam],
|
generics: &[GenericParam],
|
||||||
span: Span,
|
span: Span,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl FromStr for Mode {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ShowSpanVisitor<'a> {
|
struct ShowSpanVisitor<'a> {
|
||||||
span_diagnostic: &'a rustc_errors::Handler,
|
span_diagnostic: &'a rustc_errors::DiagCtxt,
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ impl<'a> Visitor<'a> for ShowSpanVisitor<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(span_diagnostic: &rustc_errors::Handler, mode: &str, krate: &ast::Crate) {
|
pub fn run(span_diagnostic: &rustc_errors::DiagCtxt, mode: &str, krate: &ast::Crate) {
|
||||||
let Ok(mode) = mode.parse() else {
|
let Ok(mode) = mode.parse() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::num::IntErrorKind;
|
||||||
|
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic,
|
error_code, Applicability, DiagCtxt, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic,
|
||||||
};
|
};
|
||||||
use rustc_macros::Diagnostic;
|
use rustc_macros::Diagnostic;
|
||||||
use rustc_span::{Span, Symbol};
|
use rustc_span::{Span, Symbol};
|
||||||
|
@ -51,7 +51,7 @@ pub(crate) struct UnknownMetaItem<'a> {
|
||||||
|
|
||||||
// Manual implementation to be able to format `expected` items correctly.
|
// Manual implementation to be able to format `expected` items correctly.
|
||||||
impl<'a> IntoDiagnostic<'a> for UnknownMetaItem<'_> {
|
impl<'a> IntoDiagnostic<'a> for UnknownMetaItem<'_> {
|
||||||
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
fn into_diagnostic(self, handler: &'a DiagCtxt) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||||
let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>();
|
let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>();
|
||||||
let mut diag = handler.struct_span_err_with_code(
|
let mut diag = handler.struct_span_err_with_code(
|
||||||
self.span,
|
self.span,
|
||||||
|
@ -201,7 +201,7 @@ pub(crate) struct UnsupportedLiteral {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IntoDiagnostic<'a> for UnsupportedLiteral {
|
impl<'a> IntoDiagnostic<'a> for UnsupportedLiteral {
|
||||||
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
fn into_diagnostic(self, handler: &'a DiagCtxt) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_span_err_with_code(
|
let mut diag = handler.struct_span_err_with_code(
|
||||||
self.span,
|
self.span,
|
||||||
match self.reason {
|
match self.reason {
|
||||||
|
|
|
@ -624,7 +624,7 @@ impl UseSpans<'_> {
|
||||||
/// Add a subdiagnostic to the use of the captured variable, if it exists.
|
/// Add a subdiagnostic to the use of the captured variable, if it exists.
|
||||||
pub(super) fn var_subdiag(
|
pub(super) fn var_subdiag(
|
||||||
self,
|
self,
|
||||||
handler: Option<&rustc_errors::Handler>,
|
handler: Option<&rustc_errors::DiagCtxt>,
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
kind: Option<rustc_middle::mir::BorrowKind>,
|
kind: Option<rustc_middle::mir::BorrowKind>,
|
||||||
f: impl FnOnce(Option<CoroutineKind>, Span) -> CaptureVarCause,
|
f: impl FnOnce(Option<CoroutineKind>, Span) -> CaptureVarCause,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
AddToDiagnostic, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic, MultiSpan,
|
AddToDiagnostic, DiagCtxt, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic, MultiSpan,
|
||||||
SingleLabelManySpans,
|
SingleLabelManySpans,
|
||||||
};
|
};
|
||||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||||
|
@ -448,7 +448,7 @@ pub(crate) struct EnvNotDefinedWithUserMessage {
|
||||||
// Hand-written implementation to support custom user messages.
|
// Hand-written implementation to support custom user messages.
|
||||||
impl<'a> IntoDiagnostic<'a> for EnvNotDefinedWithUserMessage {
|
impl<'a> IntoDiagnostic<'a> for EnvNotDefinedWithUserMessage {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
fn into_diagnostic(self, handler: &'a DiagCtxt) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||||
#[expect(
|
#[expect(
|
||||||
rustc::untranslatable_diagnostic,
|
rustc::untranslatable_diagnostic,
|
||||||
reason = "cannot translate user-provided messages"
|
reason = "cannot translate user-provided messages"
|
||||||
|
@ -802,7 +802,7 @@ pub(crate) struct AsmClobberNoReg {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IntoDiagnostic<'a> for AsmClobberNoReg {
|
impl<'a> IntoDiagnostic<'a> for AsmClobberNoReg {
|
||||||
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
fn into_diagnostic(self, handler: &'a DiagCtxt) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||||
let mut diag =
|
let mut diag =
|
||||||
handler.struct_err(crate::fluent_generated::builtin_macros_asm_clobber_no_reg);
|
handler.struct_err(crate::fluent_generated::builtin_macros_asm_clobber_no_reg);
|
||||||
diag.set_span(self.spans.clone());
|
diag.set_span(self.spans.clone());
|
||||||
|
|
|
@ -38,7 +38,7 @@ enum ProcMacro {
|
||||||
struct CollectProcMacros<'a> {
|
struct CollectProcMacros<'a> {
|
||||||
macros: Vec<ProcMacro>,
|
macros: Vec<ProcMacro>,
|
||||||
in_root: bool,
|
in_root: bool,
|
||||||
handler: &'a rustc_errors::Handler,
|
handler: &'a rustc_errors::DiagCtxt,
|
||||||
source_map: &'a SourceMap,
|
source_map: &'a SourceMap,
|
||||||
is_proc_macro_crate: bool,
|
is_proc_macro_crate: bool,
|
||||||
is_test_crate: bool,
|
is_test_crate: bool,
|
||||||
|
@ -52,7 +52,7 @@ pub fn inject(
|
||||||
is_proc_macro_crate: bool,
|
is_proc_macro_crate: bool,
|
||||||
has_proc_macro_decls: bool,
|
has_proc_macro_decls: bool,
|
||||||
is_test_crate: bool,
|
is_test_crate: bool,
|
||||||
handler: &rustc_errors::Handler,
|
handler: &rustc_errors::DiagCtxt,
|
||||||
) {
|
) {
|
||||||
let ecfg = ExpansionConfig::default("proc_macro".to_string(), features);
|
let ecfg = ExpansionConfig::default("proc_macro".to_string(), features);
|
||||||
let mut cx = ExtCtxt::new(sess, ecfg, resolver, None);
|
let mut cx = ExtCtxt::new(sess, ecfg, resolver, None);
|
||||||
|
|
|
@ -389,7 +389,7 @@ fn get_test_name(i: &ast::Item) -> Option<Symbol> {
|
||||||
attr::first_attr_value_str_by_name(&i.attrs, sym::rustc_test_marker)
|
attr::first_attr_value_str_by_name(&i.attrs, sym::rustc_test_marker)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_test_runner(sd: &rustc_errors::Handler, krate: &ast::Crate) -> Option<ast::Path> {
|
fn get_test_runner(sd: &rustc_errors::DiagCtxt, krate: &ast::Crate) -> Option<ast::Path> {
|
||||||
let test_attr = attr::find_by_name(&krate.attrs, sym::test_runner)?;
|
let test_attr = attr::find_by_name(&krate.attrs, sym::test_runner)?;
|
||||||
let meta_list = test_attr.meta_item_list()?;
|
let meta_list = test_attr.meta_item_list()?;
|
||||||
let span = test_attr.span;
|
let span = test_attr.span;
|
||||||
|
|
|
@ -46,7 +46,7 @@ impl ConcurrencyLimiter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn acquire(&mut self, handler: &rustc_errors::Handler) -> ConcurrencyLimiterToken {
|
pub(super) fn acquire(&mut self, handler: &rustc_errors::DiagCtxt) -> ConcurrencyLimiterToken {
|
||||||
let mut state = self.state.lock().unwrap();
|
let mut state = self.state.lock().unwrap();
|
||||||
loop {
|
loop {
|
||||||
state.assert_invariants();
|
state.assert_invariants();
|
||||||
|
|
|
@ -30,7 +30,7 @@ use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput};
|
||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
use rustc_codegen_ssa::{looks_like_rust_object_file, ModuleCodegen, ModuleKind};
|
use rustc_codegen_ssa::{looks_like_rust_object_file, ModuleCodegen, ModuleKind};
|
||||||
use rustc_data_structures::memmap::Mmap;
|
use rustc_data_structures::memmap::Mmap;
|
||||||
use rustc_errors::{FatalError, Handler};
|
use rustc_errors::{FatalError, DiagCtxt};
|
||||||
use rustc_hir::def_id::LOCAL_CRATE;
|
use rustc_hir::def_id::LOCAL_CRATE;
|
||||||
use rustc_middle::dep_graph::WorkProduct;
|
use rustc_middle::dep_graph::WorkProduct;
|
||||||
use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel};
|
use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel};
|
||||||
|
@ -61,7 +61,7 @@ struct LtoData {
|
||||||
tmp_path: TempDir,
|
tmp_path: TempDir,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_lto(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &Handler) -> Result<LtoData, FatalError> {
|
fn prepare_lto(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &DiagCtxt) -> Result<LtoData, FatalError> {
|
||||||
let export_threshold = match cgcx.lto {
|
let export_threshold = match cgcx.lto {
|
||||||
// We're just doing LTO for our one crate
|
// We're just doing LTO for our one crate
|
||||||
Lto::ThinLocal => SymbolExportLevel::Rust,
|
Lto::ThinLocal => SymbolExportLevel::Rust,
|
||||||
|
@ -192,7 +192,7 @@ pub(crate) fn run_fat(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fat_lto(cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &Handler, modules: Vec<FatLtoInput<GccCodegenBackend>>, cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>, mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>, tmp_path: TempDir,
|
fn fat_lto(cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &DiagCtxt, modules: Vec<FatLtoInput<GccCodegenBackend>>, cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>, mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>, tmp_path: TempDir,
|
||||||
//symbols_below_threshold: &[*const libc::c_char],
|
//symbols_below_threshold: &[*const libc::c_char],
|
||||||
) -> Result<LtoModuleCodegen<GccCodegenBackend>, FatalError> {
|
) -> Result<LtoModuleCodegen<GccCodegenBackend>, FatalError> {
|
||||||
let _timer = cgcx.prof.generic_activity("GCC_fat_lto_build_monolithic_module");
|
let _timer = cgcx.prof.generic_activity("GCC_fat_lto_build_monolithic_module");
|
||||||
|
|
|
@ -4,7 +4,7 @@ use gccjit::OutputKind;
|
||||||
use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
|
use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
|
||||||
use rustc_codegen_ssa::back::link::ensure_removed;
|
use rustc_codegen_ssa::back::link::ensure_removed;
|
||||||
use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, ModuleConfig};
|
use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, ModuleConfig};
|
||||||
use rustc_errors::Handler;
|
use rustc_errors::DiagCtxt;
|
||||||
use rustc_fs_util::link_or_copy;
|
use rustc_fs_util::link_or_copy;
|
||||||
use rustc_session::config::OutputType;
|
use rustc_session::config::OutputType;
|
||||||
use rustc_span::fatal_error::FatalError;
|
use rustc_span::fatal_error::FatalError;
|
||||||
|
@ -13,7 +13,7 @@ use rustc_target::spec::SplitDebuginfo;
|
||||||
use crate::{GccCodegenBackend, GccContext};
|
use crate::{GccCodegenBackend, GccContext};
|
||||||
use crate::errors::CopyBitcode;
|
use crate::errors::CopyBitcode;
|
||||||
|
|
||||||
pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &Handler, module: ModuleCodegen<GccContext>, config: &ModuleConfig) -> Result<CompiledModule, FatalError> {
|
pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &DiagCtxt, module: ModuleCodegen<GccContext>, config: &ModuleConfig) -> Result<CompiledModule, FatalError> {
|
||||||
let _timer = cgcx.prof.generic_activity_with_arg("GCC_module_codegen", &*module.name);
|
let _timer = cgcx.prof.generic_activity_with_arg("GCC_module_codegen", &*module.name);
|
||||||
{
|
{
|
||||||
let context = &module.module_llvm.context;
|
let context = &module.module_llvm.context;
|
||||||
|
@ -148,7 +148,7 @@ pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, diag_hand
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn link(_cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &Handler, mut _modules: Vec<ModuleCodegen<GccContext>>) -> Result<ModuleCodegen<GccContext>, FatalError> {
|
pub(crate) fn link(_cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &DiagCtxt, mut _modules: Vec<ModuleCodegen<GccContext>>) -> Result<ModuleCodegen<GccContext>, FatalError> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
DiagnosticArgValue, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic, IntoDiagnosticArg,
|
DiagCtxt, DiagnosticArgValue, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic,
|
||||||
|
IntoDiagnosticArg,
|
||||||
};
|
};
|
||||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
@ -111,7 +112,7 @@ pub(crate) struct TargetFeatureDisableOrEnable<'a> {
|
||||||
pub(crate) struct MissingFeatures;
|
pub(crate) struct MissingFeatures;
|
||||||
|
|
||||||
impl IntoDiagnostic<'_, ErrorGuaranteed> for TargetFeatureDisableOrEnable<'_> {
|
impl IntoDiagnostic<'_, ErrorGuaranteed> for TargetFeatureDisableOrEnable<'_> {
|
||||||
fn into_diagnostic(self, handler: &'_ Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
fn into_diagnostic(self, handler: &'_ DiagCtxt) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_err(fluent::codegen_gcc_target_feature_disable_or_enable);
|
let mut diag = handler.struct_err(fluent::codegen_gcc_target_feature_disable_or_enable);
|
||||||
if let Some(span) = self.span {
|
if let Some(span) = self.span {
|
||||||
diag.set_span(span);
|
diag.set_span(span);
|
||||||
|
|
|
@ -100,7 +100,7 @@ use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModul
|
||||||
use rustc_data_structures::fx::FxIndexMap;
|
use rustc_data_structures::fx::FxIndexMap;
|
||||||
use rustc_data_structures::sync::IntoDynSyncSend;
|
use rustc_data_structures::sync::IntoDynSyncSend;
|
||||||
use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, ThinBufferMethods, WriteBackendMethods};
|
use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, ThinBufferMethods, WriteBackendMethods};
|
||||||
use rustc_errors::{ErrorGuaranteed, Handler};
|
use rustc_errors::{ErrorGuaranteed, DiagCtxt};
|
||||||
use rustc_metadata::EncodedMetadata;
|
use rustc_metadata::EncodedMetadata;
|
||||||
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
||||||
use rustc_middle::util::Providers;
|
use rustc_middle::util::Providers;
|
||||||
|
@ -330,7 +330,7 @@ impl WriteBackendMethods for GccCodegenBackend {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn optimize(_cgcx: &CodegenContext<Self>, _diag_handler: &Handler, module: &ModuleCodegen<Self::Module>, config: &ModuleConfig) -> Result<(), FatalError> {
|
unsafe fn optimize(_cgcx: &CodegenContext<Self>, _diag_handler: &DiagCtxt, module: &ModuleCodegen<Self::Module>, config: &ModuleConfig) -> Result<(), FatalError> {
|
||||||
module.module_llvm.context.set_optimization_level(to_gcc_opt_level(config.opt_level));
|
module.module_llvm.context.set_optimization_level(to_gcc_opt_level(config.opt_level));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -344,7 +344,7 @@ impl WriteBackendMethods for GccCodegenBackend {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn codegen(cgcx: &CodegenContext<Self>, diag_handler: &Handler, module: ModuleCodegen<Self::Module>, config: &ModuleConfig) -> Result<CompiledModule, FatalError> {
|
unsafe fn codegen(cgcx: &CodegenContext<Self>, diag_handler: &DiagCtxt, module: ModuleCodegen<Self::Module>, config: &ModuleConfig) -> Result<CompiledModule, FatalError> {
|
||||||
back::write::codegen(cgcx, diag_handler, module, config)
|
back::write::codegen(cgcx, diag_handler, module, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ impl WriteBackendMethods for GccCodegenBackend {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_link(cgcx: &CodegenContext<Self>, diag_handler: &Handler, modules: Vec<ModuleCodegen<Self::Module>>) -> Result<ModuleCodegen<Self::Module>, FatalError> {
|
fn run_link(cgcx: &CodegenContext<Self>, diag_handler: &DiagCtxt, modules: Vec<ModuleCodegen<Self::Module>>) -> Result<ModuleCodegen<Self::Module>, FatalError> {
|
||||||
back::write::link(cgcx, diag_handler, modules)
|
back::write::link(cgcx, diag_handler, modules)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ use rustc_codegen_ssa::traits::*;
|
||||||
use rustc_codegen_ssa::{looks_like_rust_object_file, ModuleCodegen, ModuleKind};
|
use rustc_codegen_ssa::{looks_like_rust_object_file, ModuleCodegen, ModuleKind};
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_data_structures::memmap::Mmap;
|
use rustc_data_structures::memmap::Mmap;
|
||||||
use rustc_errors::{FatalError, Handler};
|
use rustc_errors::{DiagCtxt, FatalError};
|
||||||
use rustc_hir::def_id::LOCAL_CRATE;
|
use rustc_hir::def_id::LOCAL_CRATE;
|
||||||
use rustc_middle::bug;
|
use rustc_middle::bug;
|
||||||
use rustc_middle::dep_graph::WorkProduct;
|
use rustc_middle::dep_graph::WorkProduct;
|
||||||
|
@ -47,7 +47,7 @@ pub fn crate_type_allows_lto(crate_type: CrateType) -> bool {
|
||||||
|
|
||||||
fn prepare_lto(
|
fn prepare_lto(
|
||||||
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||||
diag_handler: &Handler,
|
diag_handler: &DiagCtxt,
|
||||||
) -> Result<(Vec<CString>, Vec<(SerializedModule<ModuleBuffer>, CString)>), FatalError> {
|
) -> Result<(Vec<CString>, Vec<(SerializedModule<ModuleBuffer>, CString)>), FatalError> {
|
||||||
let export_threshold = match cgcx.lto {
|
let export_threshold = match cgcx.lto {
|
||||||
// We're just doing LTO for our one crate
|
// We're just doing LTO for our one crate
|
||||||
|
@ -250,7 +250,7 @@ pub(crate) fn prepare_thin(module: ModuleCodegen<ModuleLlvm>) -> (String, ThinBu
|
||||||
|
|
||||||
fn fat_lto(
|
fn fat_lto(
|
||||||
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||||
diag_handler: &Handler,
|
diag_handler: &DiagCtxt,
|
||||||
modules: Vec<FatLtoInput<LlvmCodegenBackend>>,
|
modules: Vec<FatLtoInput<LlvmCodegenBackend>>,
|
||||||
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
|
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
|
||||||
mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
|
mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
|
||||||
|
@ -452,7 +452,7 @@ impl Drop for Linker<'_> {
|
||||||
/// they all go out of scope.
|
/// they all go out of scope.
|
||||||
fn thin_lto(
|
fn thin_lto(
|
||||||
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||||
diag_handler: &Handler,
|
diag_handler: &DiagCtxt,
|
||||||
modules: Vec<(String, ThinBuffer)>,
|
modules: Vec<(String, ThinBuffer)>,
|
||||||
serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
|
serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
|
||||||
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
|
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
|
||||||
|
@ -609,7 +609,7 @@ fn thin_lto(
|
||||||
|
|
||||||
pub(crate) fn run_pass_manager(
|
pub(crate) fn run_pass_manager(
|
||||||
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||||
diag_handler: &Handler,
|
diag_handler: &DiagCtxt,
|
||||||
module: &mut ModuleCodegen<ModuleLlvm>,
|
module: &mut ModuleCodegen<ModuleLlvm>,
|
||||||
thin: bool,
|
thin: bool,
|
||||||
) -> Result<(), FatalError> {
|
) -> Result<(), FatalError> {
|
||||||
|
@ -868,7 +868,7 @@ pub fn parse_module<'a>(
|
||||||
cx: &'a llvm::Context,
|
cx: &'a llvm::Context,
|
||||||
name: &CStr,
|
name: &CStr,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
diag_handler: &Handler,
|
diag_handler: &DiagCtxt,
|
||||||
) -> Result<&'a llvm::Module, FatalError> {
|
) -> Result<&'a llvm::Module, FatalError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMRustParseBitcodeForLTO(cx, data.as_ptr(), data.len(), name.as_ptr())
|
llvm::LLVMRustParseBitcodeForLTO(cx, data.as_ptr(), data.len(), name.as_ptr())
|
||||||
|
|
|
@ -26,7 +26,7 @@ use rustc_codegen_ssa::traits::*;
|
||||||
use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
|
use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
|
||||||
use rustc_data_structures::profiling::SelfProfilerRef;
|
use rustc_data_structures::profiling::SelfProfilerRef;
|
||||||
use rustc_data_structures::small_c_str::SmallCStr;
|
use rustc_data_structures::small_c_str::SmallCStr;
|
||||||
use rustc_errors::{FatalError, Handler, Level};
|
use rustc_errors::{DiagCtxt, FatalError, Level};
|
||||||
use rustc_fs_util::{link_or_copy, path_to_c_string};
|
use rustc_fs_util::{link_or_copy, path_to_c_string};
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_session::config::{self, Lto, OutputType, Passes, SplitDwarfKind, SwitchWithOptPath};
|
use rustc_session::config::{self, Lto, OutputType, Passes, SplitDwarfKind, SwitchWithOptPath};
|
||||||
|
@ -45,7 +45,7 @@ use std::slice;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub fn llvm_err<'a>(handler: &rustc_errors::Handler, err: LlvmError<'a>) -> FatalError {
|
pub fn llvm_err<'a>(handler: &rustc_errors::DiagCtxt, err: LlvmError<'a>) -> FatalError {
|
||||||
match llvm::last_error() {
|
match llvm::last_error() {
|
||||||
Some(llvm_err) => handler.emit_almost_fatal(WithLlvmError(err, llvm_err)),
|
Some(llvm_err) => handler.emit_almost_fatal(WithLlvmError(err, llvm_err)),
|
||||||
None => handler.emit_almost_fatal(err),
|
None => handler.emit_almost_fatal(err),
|
||||||
|
@ -53,7 +53,7 @@ pub fn llvm_err<'a>(handler: &rustc_errors::Handler, err: LlvmError<'a>) -> Fata
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_output_file<'ll>(
|
pub fn write_output_file<'ll>(
|
||||||
handler: &rustc_errors::Handler,
|
handler: &rustc_errors::DiagCtxt,
|
||||||
target: &'ll llvm::TargetMachine,
|
target: &'ll llvm::TargetMachine,
|
||||||
pm: &llvm::PassManager<'ll>,
|
pm: &llvm::PassManager<'ll>,
|
||||||
m: &'ll llvm::Module,
|
m: &'ll llvm::Module,
|
||||||
|
@ -332,7 +332,7 @@ pub enum CodegenDiagnosticsStage {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DiagnosticHandlers<'a> {
|
pub struct DiagnosticHandlers<'a> {
|
||||||
data: *mut (&'a CodegenContext<LlvmCodegenBackend>, &'a Handler),
|
data: *mut (&'a CodegenContext<LlvmCodegenBackend>, &'a DiagCtxt),
|
||||||
llcx: &'a llvm::Context,
|
llcx: &'a llvm::Context,
|
||||||
old_handler: Option<&'a llvm::DiagnosticHandler>,
|
old_handler: Option<&'a llvm::DiagnosticHandler>,
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,7 @@ pub struct DiagnosticHandlers<'a> {
|
||||||
impl<'a> DiagnosticHandlers<'a> {
|
impl<'a> DiagnosticHandlers<'a> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
cgcx: &'a CodegenContext<LlvmCodegenBackend>,
|
cgcx: &'a CodegenContext<LlvmCodegenBackend>,
|
||||||
handler: &'a Handler,
|
handler: &'a DiagCtxt,
|
||||||
llcx: &'a llvm::Context,
|
llcx: &'a llvm::Context,
|
||||||
module: &ModuleCodegen<ModuleLlvm>,
|
module: &ModuleCodegen<ModuleLlvm>,
|
||||||
stage: CodegenDiagnosticsStage,
|
stage: CodegenDiagnosticsStage,
|
||||||
|
@ -429,7 +429,7 @@ unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void
|
||||||
if user.is_null() {
|
if user.is_null() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let (cgcx, diag_handler) = *(user as *const (&CodegenContext<LlvmCodegenBackend>, &Handler));
|
let (cgcx, diag_handler) = *(user as *const (&CodegenContext<LlvmCodegenBackend>, &DiagCtxt));
|
||||||
|
|
||||||
match llvm::diagnostic::Diagnostic::unpack(info) {
|
match llvm::diagnostic::Diagnostic::unpack(info) {
|
||||||
llvm::diagnostic::InlineAsm(inline) => {
|
llvm::diagnostic::InlineAsm(inline) => {
|
||||||
|
@ -507,7 +507,7 @@ fn get_instr_profile_output_path(config: &ModuleConfig) -> Option<CString> {
|
||||||
|
|
||||||
pub(crate) unsafe fn llvm_optimize(
|
pub(crate) unsafe fn llvm_optimize(
|
||||||
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||||
diag_handler: &Handler,
|
diag_handler: &DiagCtxt,
|
||||||
module: &ModuleCodegen<ModuleLlvm>,
|
module: &ModuleCodegen<ModuleLlvm>,
|
||||||
config: &ModuleConfig,
|
config: &ModuleConfig,
|
||||||
opt_level: config::OptLevel,
|
opt_level: config::OptLevel,
|
||||||
|
@ -594,7 +594,7 @@ pub(crate) unsafe fn llvm_optimize(
|
||||||
// Unsafe due to LLVM calls.
|
// Unsafe due to LLVM calls.
|
||||||
pub(crate) unsafe fn optimize(
|
pub(crate) unsafe fn optimize(
|
||||||
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||||
diag_handler: &Handler,
|
diag_handler: &DiagCtxt,
|
||||||
module: &ModuleCodegen<ModuleLlvm>,
|
module: &ModuleCodegen<ModuleLlvm>,
|
||||||
config: &ModuleConfig,
|
config: &ModuleConfig,
|
||||||
) -> Result<(), FatalError> {
|
) -> Result<(), FatalError> {
|
||||||
|
@ -628,7 +628,7 @@ pub(crate) unsafe fn optimize(
|
||||||
|
|
||||||
pub(crate) fn link(
|
pub(crate) fn link(
|
||||||
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||||
diag_handler: &Handler,
|
diag_handler: &DiagCtxt,
|
||||||
mut modules: Vec<ModuleCodegen<ModuleLlvm>>,
|
mut modules: Vec<ModuleCodegen<ModuleLlvm>>,
|
||||||
) -> Result<ModuleCodegen<ModuleLlvm>, FatalError> {
|
) -> Result<ModuleCodegen<ModuleLlvm>, FatalError> {
|
||||||
use super::lto::{Linker, ModuleBuffer};
|
use super::lto::{Linker, ModuleBuffer};
|
||||||
|
@ -651,7 +651,7 @@ pub(crate) fn link(
|
||||||
|
|
||||||
pub(crate) unsafe fn codegen(
|
pub(crate) unsafe fn codegen(
|
||||||
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||||
diag_handler: &Handler,
|
diag_handler: &DiagCtxt,
|
||||||
module: ModuleCodegen<ModuleLlvm>,
|
module: ModuleCodegen<ModuleLlvm>,
|
||||||
config: &ModuleConfig,
|
config: &ModuleConfig,
|
||||||
) -> Result<CompiledModule, FatalError> {
|
) -> Result<CompiledModule, FatalError> {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::path::Path;
|
||||||
use crate::fluent_generated as fluent;
|
use crate::fluent_generated as fluent;
|
||||||
use rustc_data_structures::small_c_str::SmallCStr;
|
use rustc_data_structures::small_c_str::SmallCStr;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
DiagnosticBuilder, EmissionGuarantee, ErrorGuaranteed, FatalError, Handler, IntoDiagnostic,
|
DiagCtxt, DiagnosticBuilder, EmissionGuarantee, ErrorGuaranteed, FatalError, IntoDiagnostic,
|
||||||
};
|
};
|
||||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
@ -102,7 +102,7 @@ pub(crate) struct DynamicLinkingWithLTO;
|
||||||
pub(crate) struct ParseTargetMachineConfig<'a>(pub LlvmError<'a>);
|
pub(crate) struct ParseTargetMachineConfig<'a>(pub LlvmError<'a>);
|
||||||
|
|
||||||
impl IntoDiagnostic<'_, FatalError> for ParseTargetMachineConfig<'_> {
|
impl IntoDiagnostic<'_, FatalError> for ParseTargetMachineConfig<'_> {
|
||||||
fn into_diagnostic(self, handler: &'_ Handler) -> DiagnosticBuilder<'_, FatalError> {
|
fn into_diagnostic(self, handler: &'_ DiagCtxt) -> DiagnosticBuilder<'_, FatalError> {
|
||||||
let diag: DiagnosticBuilder<'_, FatalError> = self.0.into_diagnostic(handler);
|
let diag: DiagnosticBuilder<'_, FatalError> = self.0.into_diagnostic(handler);
|
||||||
let (message, _) = diag.styled_message().first().expect("`LlvmError` with no message");
|
let (message, _) = diag.styled_message().first().expect("`LlvmError` with no message");
|
||||||
let message = handler.eagerly_translate_to_string(message.clone(), diag.args());
|
let message = handler.eagerly_translate_to_string(message.clone(), diag.args());
|
||||||
|
@ -125,7 +125,7 @@ pub(crate) struct TargetFeatureDisableOrEnable<'a> {
|
||||||
pub(crate) struct MissingFeatures;
|
pub(crate) struct MissingFeatures;
|
||||||
|
|
||||||
impl IntoDiagnostic<'_, ErrorGuaranteed> for TargetFeatureDisableOrEnable<'_> {
|
impl IntoDiagnostic<'_, ErrorGuaranteed> for TargetFeatureDisableOrEnable<'_> {
|
||||||
fn into_diagnostic(self, handler: &'_ Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
fn into_diagnostic(self, handler: &'_ DiagCtxt) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_err(fluent::codegen_llvm_target_feature_disable_or_enable);
|
let mut diag = handler.struct_err(fluent::codegen_llvm_target_feature_disable_or_enable);
|
||||||
if let Some(span) = self.span {
|
if let Some(span) = self.span {
|
||||||
diag.set_span(span);
|
diag.set_span(span);
|
||||||
|
@ -185,7 +185,7 @@ pub enum LlvmError<'a> {
|
||||||
pub(crate) struct WithLlvmError<'a>(pub LlvmError<'a>, pub String);
|
pub(crate) struct WithLlvmError<'a>(pub LlvmError<'a>, pub String);
|
||||||
|
|
||||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for WithLlvmError<'_> {
|
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for WithLlvmError<'_> {
|
||||||
fn into_diagnostic(self, handler: &'_ Handler) -> DiagnosticBuilder<'_, G> {
|
fn into_diagnostic(self, handler: &'_ DiagCtxt) -> DiagnosticBuilder<'_, G> {
|
||||||
use LlvmError::*;
|
use LlvmError::*;
|
||||||
let msg_with_llvm_err = match &self.0 {
|
let msg_with_llvm_err = match &self.0 {
|
||||||
WriteOutput { .. } => fluent::codegen_llvm_write_output_with_llvm_err,
|
WriteOutput { .. } => fluent::codegen_llvm_write_output_with_llvm_err,
|
||||||
|
|
|
@ -40,7 +40,7 @@ use rustc_codegen_ssa::traits::*;
|
||||||
use rustc_codegen_ssa::ModuleCodegen;
|
use rustc_codegen_ssa::ModuleCodegen;
|
||||||
use rustc_codegen_ssa::{CodegenResults, CompiledModule};
|
use rustc_codegen_ssa::{CodegenResults, CompiledModule};
|
||||||
use rustc_data_structures::fx::FxIndexMap;
|
use rustc_data_structures::fx::FxIndexMap;
|
||||||
use rustc_errors::{ErrorGuaranteed, FatalError, Handler};
|
use rustc_errors::{DiagCtxt, ErrorGuaranteed, FatalError};
|
||||||
use rustc_metadata::EncodedMetadata;
|
use rustc_metadata::EncodedMetadata;
|
||||||
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
|
@ -200,7 +200,7 @@ impl WriteBackendMethods for LlvmCodegenBackend {
|
||||||
}
|
}
|
||||||
fn run_link(
|
fn run_link(
|
||||||
cgcx: &CodegenContext<Self>,
|
cgcx: &CodegenContext<Self>,
|
||||||
diag_handler: &Handler,
|
diag_handler: &DiagCtxt,
|
||||||
modules: Vec<ModuleCodegen<Self::Module>>,
|
modules: Vec<ModuleCodegen<Self::Module>>,
|
||||||
) -> Result<ModuleCodegen<Self::Module>, FatalError> {
|
) -> Result<ModuleCodegen<Self::Module>, FatalError> {
|
||||||
back::write::link(cgcx, diag_handler, modules)
|
back::write::link(cgcx, diag_handler, modules)
|
||||||
|
@ -221,7 +221,7 @@ impl WriteBackendMethods for LlvmCodegenBackend {
|
||||||
}
|
}
|
||||||
unsafe fn optimize(
|
unsafe fn optimize(
|
||||||
cgcx: &CodegenContext<Self>,
|
cgcx: &CodegenContext<Self>,
|
||||||
diag_handler: &Handler,
|
diag_handler: &DiagCtxt,
|
||||||
module: &ModuleCodegen<Self::Module>,
|
module: &ModuleCodegen<Self::Module>,
|
||||||
config: &ModuleConfig,
|
config: &ModuleConfig,
|
||||||
) -> Result<(), FatalError> {
|
) -> Result<(), FatalError> {
|
||||||
|
@ -242,7 +242,7 @@ impl WriteBackendMethods for LlvmCodegenBackend {
|
||||||
}
|
}
|
||||||
unsafe fn codegen(
|
unsafe fn codegen(
|
||||||
cgcx: &CodegenContext<Self>,
|
cgcx: &CodegenContext<Self>,
|
||||||
diag_handler: &Handler,
|
diag_handler: &DiagCtxt,
|
||||||
module: ModuleCodegen<Self::Module>,
|
module: ModuleCodegen<Self::Module>,
|
||||||
config: &ModuleConfig,
|
config: &ModuleConfig,
|
||||||
) -> Result<CompiledModule, FatalError> {
|
) -> Result<CompiledModule, FatalError> {
|
||||||
|
@ -447,7 +447,7 @@ impl ModuleLlvm {
|
||||||
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||||
name: &CStr,
|
name: &CStr,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
) -> Result<Self, FatalError> {
|
) -> Result<Self, FatalError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let llcx = llvm::LLVMRustContextCreate(cgcx.fewer_names);
|
let llcx = llvm::LLVMRustContextCreate(cgcx.fewer_names);
|
||||||
|
|
|
@ -4,7 +4,7 @@ use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_data_structures::fx::FxIndexMap;
|
use rustc_data_structures::fx::FxIndexMap;
|
||||||
use rustc_data_structures::memmap::Mmap;
|
use rustc_data_structures::memmap::Mmap;
|
||||||
use rustc_data_structures::temp_dir::MaybeTempDir;
|
use rustc_data_structures::temp_dir::MaybeTempDir;
|
||||||
use rustc_errors::{ErrorGuaranteed, Handler};
|
use rustc_errors::{DiagCtxt, ErrorGuaranteed};
|
||||||
use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize};
|
use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize};
|
||||||
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
||||||
use rustc_metadata::find_native_static_library;
|
use rustc_metadata::find_native_static_library;
|
||||||
|
@ -52,7 +52,7 @@ use std::path::{Path, PathBuf};
|
||||||
use std::process::{ExitStatus, Output, Stdio};
|
use std::process::{ExitStatus, Output, Stdio};
|
||||||
use std::{env, fmt, fs, io, mem, str};
|
use std::{env, fmt, fs, io, mem, str};
|
||||||
|
|
||||||
pub fn ensure_removed(diag_handler: &Handler, path: &Path) {
|
pub fn ensure_removed(diag_handler: &DiagCtxt, path: &Path) {
|
||||||
if let Err(e) = fs::remove_file(path) {
|
if let Err(e) = fs::remove_file(path) {
|
||||||
if e.kind() != io::ErrorKind::NotFound {
|
if e.kind() != io::ErrorKind::NotFound {
|
||||||
diag_handler.err(format!("failed to remove {}: {}", path.display(), e));
|
diag_handler.err(format!("failed to remove {}: {}", path.display(), e));
|
||||||
|
|
|
@ -14,7 +14,7 @@ use rustc_data_structures::memmap::Mmap;
|
||||||
use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard};
|
use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard};
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_errors::emitter::Emitter;
|
use rustc_errors::emitter::Emitter;
|
||||||
use rustc_errors::{translation::Translate, DiagnosticId, FatalError, Handler, Level};
|
use rustc_errors::{translation::Translate, DiagCtxt, DiagnosticId, FatalError, Level};
|
||||||
use rustc_errors::{DiagnosticMessage, Style};
|
use rustc_errors::{DiagnosticMessage, Style};
|
||||||
use rustc_fs_util::link_or_copy;
|
use rustc_fs_util::link_or_copy;
|
||||||
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
||||||
|
@ -344,7 +344,7 @@ pub struct CodegenContext<B: WriteBackendMethods> {
|
||||||
/// how to call the compiler with the same arguments.
|
/// how to call the compiler with the same arguments.
|
||||||
pub expanded_args: Vec<String>,
|
pub expanded_args: Vec<String>,
|
||||||
|
|
||||||
/// Handler to use for diagnostics produced during codegen.
|
/// Emitter to use for diagnostics produced during codegen.
|
||||||
pub diag_emitter: SharedEmitter,
|
pub diag_emitter: SharedEmitter,
|
||||||
/// LLVM optimizations for which we want to print remarks.
|
/// LLVM optimizations for which we want to print remarks.
|
||||||
pub remark: Passes,
|
pub remark: Passes,
|
||||||
|
@ -359,8 +359,8 @@ pub struct CodegenContext<B: WriteBackendMethods> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<B: WriteBackendMethods> CodegenContext<B> {
|
impl<B: WriteBackendMethods> CodegenContext<B> {
|
||||||
pub fn create_diag_handler(&self) -> Handler {
|
pub fn create_diag_handler(&self) -> DiagCtxt {
|
||||||
Handler::with_emitter(Box::new(self.diag_emitter.clone()))
|
DiagCtxt::with_emitter(Box::new(self.diag_emitter.clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn config(&self, kind: ModuleKind) -> &ModuleConfig {
|
pub fn config(&self, kind: ModuleKind) -> &ModuleConfig {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::assert_module_sources::CguReuse;
|
||||||
use crate::back::command::Command;
|
use crate::back::command::Command;
|
||||||
use crate::fluent_generated as fluent;
|
use crate::fluent_generated as fluent;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
DiagnosticArgValue, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic,
|
DiagCtxt, DiagnosticArgValue, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic,
|
||||||
IntoDiagnosticArg,
|
IntoDiagnosticArg,
|
||||||
};
|
};
|
||||||
use rustc_macros::Diagnostic;
|
use rustc_macros::Diagnostic;
|
||||||
|
@ -210,7 +210,7 @@ pub enum LinkRlibError {
|
||||||
pub struct ThorinErrorWrapper(pub thorin::Error);
|
pub struct ThorinErrorWrapper(pub thorin::Error);
|
||||||
|
|
||||||
impl IntoDiagnostic<'_> for ThorinErrorWrapper {
|
impl IntoDiagnostic<'_> for ThorinErrorWrapper {
|
||||||
fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
fn into_diagnostic(self, handler: &DiagCtxt) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
let mut diag;
|
let mut diag;
|
||||||
match self.0 {
|
match self.0 {
|
||||||
thorin::Error::ReadInput(_) => {
|
thorin::Error::ReadInput(_) => {
|
||||||
|
@ -412,7 +412,7 @@ pub struct LinkingFailed<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnostic<'_> for LinkingFailed<'_> {
|
impl IntoDiagnostic<'_> for LinkingFailed<'_> {
|
||||||
fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
fn into_diagnostic(self, handler: &DiagCtxt) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_err(fluent::codegen_ssa_linking_failed);
|
let mut diag = handler.struct_err(fluent::codegen_ssa_linking_failed);
|
||||||
diag.set_arg("linker_path", format!("{}", self.linker_path.display()));
|
diag.set_arg("linker_path", format!("{}", self.linker_path.display()));
|
||||||
diag.set_arg("exit_status", format!("{}", self.exit_status));
|
diag.set_arg("exit_status", format!("{}", self.exit_status));
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule};
|
||||||
use crate::back::write::{CodegenContext, FatLtoInput, ModuleConfig};
|
use crate::back::write::{CodegenContext, FatLtoInput, ModuleConfig};
|
||||||
use crate::{CompiledModule, ModuleCodegen};
|
use crate::{CompiledModule, ModuleCodegen};
|
||||||
|
|
||||||
use rustc_errors::{FatalError, Handler};
|
use rustc_errors::{DiagCtxt, FatalError};
|
||||||
use rustc_middle::dep_graph::WorkProduct;
|
use rustc_middle::dep_graph::WorkProduct;
|
||||||
|
|
||||||
pub trait WriteBackendMethods: 'static + Sized + Clone {
|
pub trait WriteBackendMethods: 'static + Sized + Clone {
|
||||||
|
@ -16,7 +16,7 @@ pub trait WriteBackendMethods: 'static + Sized + Clone {
|
||||||
/// Merge all modules into main_module and returning it
|
/// Merge all modules into main_module and returning it
|
||||||
fn run_link(
|
fn run_link(
|
||||||
cgcx: &CodegenContext<Self>,
|
cgcx: &CodegenContext<Self>,
|
||||||
diag_handler: &Handler,
|
diag_handler: &DiagCtxt,
|
||||||
modules: Vec<ModuleCodegen<Self::Module>>,
|
modules: Vec<ModuleCodegen<Self::Module>>,
|
||||||
) -> Result<ModuleCodegen<Self::Module>, FatalError>;
|
) -> Result<ModuleCodegen<Self::Module>, FatalError>;
|
||||||
/// Performs fat LTO by merging all modules into a single one and returning it
|
/// Performs fat LTO by merging all modules into a single one and returning it
|
||||||
|
@ -38,7 +38,7 @@ pub trait WriteBackendMethods: 'static + Sized + Clone {
|
||||||
fn print_statistics(&self);
|
fn print_statistics(&self);
|
||||||
unsafe fn optimize(
|
unsafe fn optimize(
|
||||||
cgcx: &CodegenContext<Self>,
|
cgcx: &CodegenContext<Self>,
|
||||||
diag_handler: &Handler,
|
diag_handler: &DiagCtxt,
|
||||||
module: &ModuleCodegen<Self::Module>,
|
module: &ModuleCodegen<Self::Module>,
|
||||||
config: &ModuleConfig,
|
config: &ModuleConfig,
|
||||||
) -> Result<(), FatalError>;
|
) -> Result<(), FatalError>;
|
||||||
|
@ -52,7 +52,7 @@ pub trait WriteBackendMethods: 'static + Sized + Clone {
|
||||||
) -> Result<ModuleCodegen<Self::Module>, FatalError>;
|
) -> Result<ModuleCodegen<Self::Module>, FatalError>;
|
||||||
unsafe fn codegen(
|
unsafe fn codegen(
|
||||||
cgcx: &CodegenContext<Self>,
|
cgcx: &CodegenContext<Self>,
|
||||||
diag_handler: &Handler,
|
diag_handler: &DiagCtxt,
|
||||||
module: ModuleCodegen<Self::Module>,
|
module: ModuleCodegen<Self::Module>,
|
||||||
config: &ModuleConfig,
|
config: &ModuleConfig,
|
||||||
) -> Result<CompiledModule, FatalError>;
|
) -> Result<CompiledModule, FatalError>;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
DiagnosticArgValue, DiagnosticBuilder, DiagnosticMessage, EmissionGuarantee, Handler,
|
DiagCtxt, DiagnosticArgValue, DiagnosticBuilder, DiagnosticMessage, EmissionGuarantee,
|
||||||
IntoDiagnostic,
|
IntoDiagnostic,
|
||||||
};
|
};
|
||||||
use rustc_hir::ConstContext;
|
use rustc_hir::ConstContext;
|
||||||
|
@ -434,7 +434,7 @@ pub trait ReportErrorExt {
|
||||||
fn diagnostic_message(&self) -> DiagnosticMessage;
|
fn diagnostic_message(&self) -> DiagnosticMessage;
|
||||||
fn add_args<G: EmissionGuarantee>(
|
fn add_args<G: EmissionGuarantee>(
|
||||||
self,
|
self,
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
builder: &mut DiagnosticBuilder<'_, G>,
|
builder: &mut DiagnosticBuilder<'_, G>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -454,7 +454,7 @@ pub trait ReportErrorExt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bad_pointer_message(msg: CheckInAllocMsg, handler: &Handler) -> String {
|
fn bad_pointer_message(msg: CheckInAllocMsg, handler: &DiagCtxt) -> String {
|
||||||
use crate::fluent_generated::*;
|
use crate::fluent_generated::*;
|
||||||
|
|
||||||
let msg = match msg {
|
let msg = match msg {
|
||||||
|
@ -514,7 +514,7 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
|
||||||
|
|
||||||
fn add_args<G: EmissionGuarantee>(
|
fn add_args<G: EmissionGuarantee>(
|
||||||
self,
|
self,
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
builder: &mut DiagnosticBuilder<'_, G>,
|
builder: &mut DiagnosticBuilder<'_, G>,
|
||||||
) {
|
) {
|
||||||
use UndefinedBehaviorInfo::*;
|
use UndefinedBehaviorInfo::*;
|
||||||
|
@ -678,7 +678,11 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_args<G: EmissionGuarantee>(self, handler: &Handler, err: &mut DiagnosticBuilder<'_, G>) {
|
fn add_args<G: EmissionGuarantee>(
|
||||||
|
self,
|
||||||
|
handler: &DiagCtxt,
|
||||||
|
err: &mut DiagnosticBuilder<'_, G>,
|
||||||
|
) {
|
||||||
use crate::fluent_generated as fluent;
|
use crate::fluent_generated as fluent;
|
||||||
use rustc_middle::mir::interpret::ValidationErrorKind::*;
|
use rustc_middle::mir::interpret::ValidationErrorKind::*;
|
||||||
|
|
||||||
|
@ -704,7 +708,7 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
|
||||||
fn add_range_arg<G: EmissionGuarantee>(
|
fn add_range_arg<G: EmissionGuarantee>(
|
||||||
r: WrappingRange,
|
r: WrappingRange,
|
||||||
max_hi: u128,
|
max_hi: u128,
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
err: &mut DiagnosticBuilder<'_, G>,
|
err: &mut DiagnosticBuilder<'_, G>,
|
||||||
) {
|
) {
|
||||||
let WrappingRange { start: lo, end: hi } = r;
|
let WrappingRange { start: lo, end: hi } = r;
|
||||||
|
@ -804,7 +808,7 @@ impl ReportErrorExt for UnsupportedOpInfo {
|
||||||
UnsupportedOpInfo::ReadExternStatic(_) => const_eval_read_extern_static,
|
UnsupportedOpInfo::ReadExternStatic(_) => const_eval_read_extern_static,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn add_args<G: EmissionGuarantee>(self, _: &Handler, builder: &mut DiagnosticBuilder<'_, G>) {
|
fn add_args<G: EmissionGuarantee>(self, _: &DiagCtxt, builder: &mut DiagnosticBuilder<'_, G>) {
|
||||||
use crate::fluent_generated::*;
|
use crate::fluent_generated::*;
|
||||||
|
|
||||||
use UnsupportedOpInfo::*;
|
use UnsupportedOpInfo::*;
|
||||||
|
@ -839,7 +843,7 @@ impl<'tcx> ReportErrorExt for InterpError<'tcx> {
|
||||||
}
|
}
|
||||||
fn add_args<G: EmissionGuarantee>(
|
fn add_args<G: EmissionGuarantee>(
|
||||||
self,
|
self,
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
builder: &mut DiagnosticBuilder<'_, G>,
|
builder: &mut DiagnosticBuilder<'_, G>,
|
||||||
) {
|
) {
|
||||||
match self {
|
match self {
|
||||||
|
@ -871,7 +875,7 @@ impl<'tcx> ReportErrorExt for InvalidProgramInfo<'tcx> {
|
||||||
}
|
}
|
||||||
fn add_args<G: EmissionGuarantee>(
|
fn add_args<G: EmissionGuarantee>(
|
||||||
self,
|
self,
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
builder: &mut DiagnosticBuilder<'_, G>,
|
builder: &mut DiagnosticBuilder<'_, G>,
|
||||||
) {
|
) {
|
||||||
match self {
|
match self {
|
||||||
|
@ -904,5 +908,5 @@ impl ReportErrorExt for ResourceExhaustionInfo {
|
||||||
ResourceExhaustionInfo::AddressSpaceFull => const_eval_address_space_full,
|
ResourceExhaustionInfo::AddressSpaceFull => const_eval_address_space_full,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn add_args<G: EmissionGuarantee>(self, _: &Handler, _: &mut DiagnosticBuilder<'_, G>) {}
|
fn add_args<G: EmissionGuarantee>(self, _: &DiagCtxt, _: &mut DiagnosticBuilder<'_, G>) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ use rustc_data_structures::profiling::{
|
||||||
use rustc_data_structures::sync::SeqCst;
|
use rustc_data_structures::sync::SeqCst;
|
||||||
use rustc_errors::registry::{InvalidErrorCode, Registry};
|
use rustc_errors::registry::{InvalidErrorCode, Registry};
|
||||||
use rustc_errors::{markdown, ColorConfig};
|
use rustc_errors::{markdown, ColorConfig};
|
||||||
use rustc_errors::{ErrorGuaranteed, Handler, PResult};
|
use rustc_errors::{DiagCtxt, ErrorGuaranteed, PResult};
|
||||||
use rustc_feature::find_gated_cfg;
|
use rustc_feature::find_gated_cfg;
|
||||||
use rustc_interface::util::{self, collect_crate_types, get_codegen_backend};
|
use rustc_interface::util::{self, collect_crate_types, get_codegen_backend};
|
||||||
use rustc_interface::{interface, Queries};
|
use rustc_interface::{interface, Queries};
|
||||||
|
@ -1310,7 +1310,10 @@ fn ice_path() -> &'static Option<PathBuf> {
|
||||||
/// internal features.
|
/// 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(bug_report_url: &'static str, extra_info: fn(&Handler)) -> Arc<AtomicBool> {
|
pub fn install_ice_hook(
|
||||||
|
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
|
||||||
|
@ -1388,7 +1391,7 @@ pub fn install_ice_hook(bug_report_url: &'static str, extra_info: fn(&Handler))
|
||||||
fn report_ice(
|
fn report_ice(
|
||||||
info: &panic::PanicInfo<'_>,
|
info: &panic::PanicInfo<'_>,
|
||||||
bug_report_url: &str,
|
bug_report_url: &str,
|
||||||
extra_info: fn(&Handler),
|
extra_info: fn(&DiagCtxt),
|
||||||
using_internal_features: &AtomicBool,
|
using_internal_features: &AtomicBool,
|
||||||
) {
|
) {
|
||||||
let fallback_bundle =
|
let fallback_bundle =
|
||||||
|
@ -1397,7 +1400,7 @@ fn report_ice(
|
||||||
rustc_errors::ColorConfig::Auto,
|
rustc_errors::ColorConfig::Auto,
|
||||||
fallback_bundle,
|
fallback_bundle,
|
||||||
));
|
));
|
||||||
let handler = rustc_errors::Handler::with_emitter(emitter);
|
let handler = rustc_errors::DiagCtxt::with_emitter(emitter);
|
||||||
|
|
||||||
// a .span_bug or .bug call has already printed what
|
// a .span_bug or .bug call has already printed what
|
||||||
// it wants to print.
|
// it wants to print.
|
||||||
|
|
|
@ -886,7 +886,7 @@ impl Diagnostic {
|
||||||
/// interpolated variables).
|
/// interpolated variables).
|
||||||
pub fn eager_subdiagnostic(
|
pub fn eager_subdiagnostic(
|
||||||
&mut self,
|
&mut self,
|
||||||
handler: &crate::Handler,
|
handler: &crate::DiagCtxt,
|
||||||
subdiagnostic: impl AddToDiagnostic,
|
subdiagnostic: impl AddToDiagnostic,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
subdiagnostic.add_to_diagnostic_with(self, |diag, msg| {
|
subdiagnostic.add_to_diagnostic_with(self, |diag, msg| {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::diagnostic::IntoDiagnosticArg;
|
use crate::diagnostic::IntoDiagnosticArg;
|
||||||
|
use crate::{DiagCtxt, Level, MultiSpan, StashKey};
|
||||||
use crate::{
|
use crate::{
|
||||||
Diagnostic, DiagnosticId, DiagnosticMessage, DiagnosticStyledString, ErrorGuaranteed,
|
Diagnostic, DiagnosticId, DiagnosticMessage, DiagnosticStyledString, ErrorGuaranteed,
|
||||||
ExplicitBug, SubdiagnosticMessage,
|
ExplicitBug, SubdiagnosticMessage,
|
||||||
};
|
};
|
||||||
use crate::{Handler, Level, MultiSpan, StashKey};
|
|
||||||
use rustc_lint_defs::Applicability;
|
use rustc_lint_defs::Applicability;
|
||||||
use rustc_span::source_map::Spanned;
|
use rustc_span::source_map::Spanned;
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@ use std::thread::panicking;
|
||||||
/// `#[derive(Diagnostic)]` -- see [rustc_macros::Diagnostic].
|
/// `#[derive(Diagnostic)]` -- see [rustc_macros::Diagnostic].
|
||||||
#[rustc_diagnostic_item = "IntoDiagnostic"]
|
#[rustc_diagnostic_item = "IntoDiagnostic"]
|
||||||
pub trait IntoDiagnostic<'a, G: EmissionGuarantee = ErrorGuaranteed> {
|
pub trait IntoDiagnostic<'a, G: EmissionGuarantee = ErrorGuaranteed> {
|
||||||
/// Write out as a diagnostic out of `Handler`.
|
/// Write out as a diagnostic out of `DiagCtxt`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, G>;
|
fn into_diagnostic(self, handler: &'a DiagCtxt) -> DiagnosticBuilder<'a, G>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T, G> IntoDiagnostic<'a, G> for Spanned<T>
|
impl<'a, T, G> IntoDiagnostic<'a, G> for Spanned<T>
|
||||||
|
@ -29,7 +29,7 @@ where
|
||||||
T: IntoDiagnostic<'a, G>,
|
T: IntoDiagnostic<'a, G>,
|
||||||
G: EmissionGuarantee,
|
G: EmissionGuarantee,
|
||||||
{
|
{
|
||||||
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, G> {
|
fn into_diagnostic(self, handler: &'a DiagCtxt) -> DiagnosticBuilder<'a, G> {
|
||||||
let mut diag = self.node.into_diagnostic(handler);
|
let mut diag = self.node.into_diagnostic(handler);
|
||||||
diag.set_span(self.span);
|
diag.set_span(self.span);
|
||||||
diag
|
diag
|
||||||
|
@ -74,8 +74,8 @@ struct DiagnosticBuilderInner<'a> {
|
||||||
enum DiagnosticBuilderState<'a> {
|
enum DiagnosticBuilderState<'a> {
|
||||||
/// Initial state of a `DiagnosticBuilder`, before `.emit()` or `.cancel()`.
|
/// Initial state of a `DiagnosticBuilder`, before `.emit()` or `.cancel()`.
|
||||||
///
|
///
|
||||||
/// The `Diagnostic` will be emitted through this `Handler`.
|
/// The `Diagnostic` will be emitted through this `DiagCtxt`.
|
||||||
Emittable(&'a Handler),
|
Emittable(&'a DiagCtxt),
|
||||||
|
|
||||||
/// State of a `DiagnosticBuilder`, after `.emit()` or *during* `.cancel()`.
|
/// State of a `DiagnosticBuilder`, after `.emit()` or *during* `.cancel()`.
|
||||||
///
|
///
|
||||||
|
@ -95,7 +95,7 @@ enum DiagnosticBuilderState<'a> {
|
||||||
// `DiagnosticBuilderState` should be pointer-sized.
|
// `DiagnosticBuilderState` should be pointer-sized.
|
||||||
rustc_data_structures::static_assert_size!(
|
rustc_data_structures::static_assert_size!(
|
||||||
DiagnosticBuilderState<'_>,
|
DiagnosticBuilderState<'_>,
|
||||||
std::mem::size_of::<&Handler>()
|
std::mem::size_of::<&DiagCtxt>()
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Trait for types that `DiagnosticBuilder::emit` can return as a "guarantee"
|
/// Trait for types that `DiagnosticBuilder::emit` can return as a "guarantee"
|
||||||
|
@ -110,7 +110,7 @@ pub trait EmissionGuarantee: Sized {
|
||||||
/// Creates a new `DiagnosticBuilder` that will return this type of guarantee.
|
/// Creates a new `DiagnosticBuilder` that will return this type of guarantee.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn make_diagnostic_builder(
|
fn make_diagnostic_builder(
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, Self>;
|
) -> DiagnosticBuilder<'_, Self>;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ impl<'a> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||||
impl EmissionGuarantee for ErrorGuaranteed {
|
impl EmissionGuarantee for ErrorGuaranteed {
|
||||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
||||||
match db.inner.state {
|
match db.inner.state {
|
||||||
// First `.emit()` call, the `&Handler` is still available.
|
// First `.emit()` call, the `&DiagCtxt` is still available.
|
||||||
DiagnosticBuilderState::Emittable(handler) => {
|
DiagnosticBuilderState::Emittable(handler) => {
|
||||||
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
|
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ impl EmissionGuarantee for ErrorGuaranteed {
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn make_diagnostic_builder(
|
fn make_diagnostic_builder(
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, Self> {
|
) -> DiagnosticBuilder<'_, Self> {
|
||||||
DiagnosticBuilder::new(handler, Level::Error { lint: false }, msg)
|
DiagnosticBuilder::new(handler, Level::Error { lint: false }, msg)
|
||||||
|
@ -177,7 +177,7 @@ impl EmissionGuarantee for ErrorGuaranteed {
|
||||||
impl EmissionGuarantee for () {
|
impl EmissionGuarantee for () {
|
||||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
||||||
match db.inner.state {
|
match db.inner.state {
|
||||||
// First `.emit()` call, the `&Handler` is still available.
|
// First `.emit()` call, the `&DiagCtxt` is still available.
|
||||||
DiagnosticBuilderState::Emittable(handler) => {
|
DiagnosticBuilderState::Emittable(handler) => {
|
||||||
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
|
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ impl EmissionGuarantee for () {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_diagnostic_builder(
|
fn make_diagnostic_builder(
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, Self> {
|
) -> DiagnosticBuilder<'_, Self> {
|
||||||
DiagnosticBuilder::new(handler, Level::Warning(None), msg)
|
DiagnosticBuilder::new(handler, Level::Warning(None), msg)
|
||||||
|
@ -204,7 +204,7 @@ pub struct Noted;
|
||||||
impl EmissionGuarantee for Noted {
|
impl EmissionGuarantee for Noted {
|
||||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
||||||
match db.inner.state {
|
match db.inner.state {
|
||||||
// First `.emit()` call, the `&Handler` is still available.
|
// First `.emit()` call, the `&DiagCtxt` is still available.
|
||||||
DiagnosticBuilderState::Emittable(handler) => {
|
DiagnosticBuilderState::Emittable(handler) => {
|
||||||
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
|
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
|
||||||
handler.emit_diagnostic_without_consuming(&mut db.inner.diagnostic);
|
handler.emit_diagnostic_without_consuming(&mut db.inner.diagnostic);
|
||||||
|
@ -217,7 +217,7 @@ impl EmissionGuarantee for Noted {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_diagnostic_builder(
|
fn make_diagnostic_builder(
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, Self> {
|
) -> DiagnosticBuilder<'_, Self> {
|
||||||
DiagnosticBuilder::new(handler, Level::Note, msg)
|
DiagnosticBuilder::new(handler, Level::Note, msg)
|
||||||
|
@ -232,7 +232,7 @@ pub struct Bug;
|
||||||
impl EmissionGuarantee for Bug {
|
impl EmissionGuarantee for Bug {
|
||||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
||||||
match db.inner.state {
|
match db.inner.state {
|
||||||
// First `.emit()` call, the `&Handler` is still available.
|
// First `.emit()` call, the `&DiagCtxt` is still available.
|
||||||
DiagnosticBuilderState::Emittable(handler) => {
|
DiagnosticBuilderState::Emittable(handler) => {
|
||||||
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
|
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ impl EmissionGuarantee for Bug {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_diagnostic_builder(
|
fn make_diagnostic_builder(
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, Self> {
|
) -> DiagnosticBuilder<'_, Self> {
|
||||||
DiagnosticBuilder::new(handler, Level::Bug, msg)
|
DiagnosticBuilder::new(handler, Level::Bug, msg)
|
||||||
|
@ -256,7 +256,7 @@ impl EmissionGuarantee for Bug {
|
||||||
impl EmissionGuarantee for ! {
|
impl EmissionGuarantee for ! {
|
||||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
||||||
match db.inner.state {
|
match db.inner.state {
|
||||||
// First `.emit()` call, the `&Handler` is still available.
|
// First `.emit()` call, the `&DiagCtxt` is still available.
|
||||||
DiagnosticBuilderState::Emittable(handler) => {
|
DiagnosticBuilderState::Emittable(handler) => {
|
||||||
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
|
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ impl EmissionGuarantee for ! {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_diagnostic_builder(
|
fn make_diagnostic_builder(
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, Self> {
|
) -> DiagnosticBuilder<'_, Self> {
|
||||||
DiagnosticBuilder::new(handler, Level::Fatal, msg)
|
DiagnosticBuilder::new(handler, Level::Fatal, msg)
|
||||||
|
@ -280,7 +280,7 @@ impl EmissionGuarantee for ! {
|
||||||
impl EmissionGuarantee for rustc_span::fatal_error::FatalError {
|
impl EmissionGuarantee for rustc_span::fatal_error::FatalError {
|
||||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
||||||
match db.inner.state {
|
match db.inner.state {
|
||||||
// First `.emit()` call, the `&Handler` is still available.
|
// First `.emit()` call, the `&DiagCtxt` is still available.
|
||||||
DiagnosticBuilderState::Emittable(handler) => {
|
DiagnosticBuilderState::Emittable(handler) => {
|
||||||
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
|
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ impl EmissionGuarantee for rustc_span::fatal_error::FatalError {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_diagnostic_builder(
|
fn make_diagnostic_builder(
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
) -> DiagnosticBuilder<'_, Self> {
|
) -> DiagnosticBuilder<'_, Self> {
|
||||||
DiagnosticBuilder::new(handler, Level::Fatal, msg)
|
DiagnosticBuilder::new(handler, Level::Fatal, msg)
|
||||||
|
@ -340,10 +340,10 @@ impl<G: EmissionGuarantee> DerefMut for DiagnosticBuilder<'_, G> {
|
||||||
|
|
||||||
impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
/// Convenience function for internal use, clients should use one of the
|
/// Convenience function for internal use, clients should use one of the
|
||||||
/// `struct_*` methods on [`Handler`].
|
/// `struct_*` methods on [`DiagCtxt`].
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub(crate) fn new<M: Into<DiagnosticMessage>>(
|
pub(crate) fn new<M: Into<DiagnosticMessage>>(
|
||||||
handler: &'a Handler,
|
handler: &'a DiagCtxt,
|
||||||
level: Level,
|
level: Level,
|
||||||
message: M,
|
message: M,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -354,7 +354,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
/// Creates a new `DiagnosticBuilder` with an already constructed
|
/// Creates a new `DiagnosticBuilder` with an already constructed
|
||||||
/// diagnostic.
|
/// diagnostic.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub(crate) fn new_diagnostic(handler: &'a Handler, diagnostic: Diagnostic) -> Self {
|
pub(crate) fn new_diagnostic(handler: &'a DiagCtxt, diagnostic: Diagnostic) -> Self {
|
||||||
debug!("Created new diagnostic");
|
debug!("Created new diagnostic");
|
||||||
Self {
|
Self {
|
||||||
inner: DiagnosticBuilderInner {
|
inner: DiagnosticBuilderInner {
|
||||||
|
@ -398,7 +398,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
|
|
||||||
/// Stashes diagnostic for possible later improvement in a different,
|
/// Stashes diagnostic for possible later improvement in a different,
|
||||||
/// later stage of the compiler. The diagnostic can be accessed with
|
/// later stage of the compiler. The diagnostic can be accessed with
|
||||||
/// the provided `span` and `key` through [`Handler::steal_diagnostic()`].
|
/// the provided `span` and `key` through [`DiagCtxt::steal_diagnostic()`].
|
||||||
///
|
///
|
||||||
/// As with `buffer`, this is unless the handler has disabled such buffering.
|
/// As with `buffer`, this is unless the handler has disabled such buffering.
|
||||||
pub fn stash(self, span: Span, key: StashKey) {
|
pub fn stash(self, span: Span, key: StashKey) {
|
||||||
|
@ -409,9 +409,9 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
|
|
||||||
/// Converts the builder to a `Diagnostic` for later emission,
|
/// Converts the builder to a `Diagnostic` for later emission,
|
||||||
/// unless handler has disabled such buffering, or `.emit()` was called.
|
/// unless handler has disabled such buffering, or `.emit()` was called.
|
||||||
pub fn into_diagnostic(mut self) -> Option<(Diagnostic, &'a Handler)> {
|
pub fn into_diagnostic(mut self) -> Option<(Diagnostic, &'a DiagCtxt)> {
|
||||||
let handler = match self.inner.state {
|
let handler = match self.inner.state {
|
||||||
// No `.emit()` calls, the `&Handler` is still available.
|
// No `.emit()` calls, the `&DiagCtxt` is still available.
|
||||||
DiagnosticBuilderState::Emittable(handler) => handler,
|
DiagnosticBuilderState::Emittable(handler) => handler,
|
||||||
// `.emit()` was previously called, nothing we can do.
|
// `.emit()` was previously called, nothing we can do.
|
||||||
DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation => {
|
DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation => {
|
||||||
|
@ -440,8 +440,8 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
|
||||||
Some((diagnostic, handler))
|
Some((diagnostic, handler))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the [`Handler`] if available
|
/// Retrieves the [`DiagCtxt`] if available
|
||||||
pub fn handler(&self) -> Option<&Handler> {
|
pub fn handler(&self) -> Option<&DiagCtxt> {
|
||||||
match self.inner.state {
|
match self.inner.state {
|
||||||
DiagnosticBuilderState::Emittable(handler) => Some(handler),
|
DiagnosticBuilderState::Emittable(handler) => Some(handler),
|
||||||
DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation => None,
|
DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation => None,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::diagnostic::DiagnosticLocation;
|
use crate::diagnostic::DiagnosticLocation;
|
||||||
use crate::{fluent_generated as fluent, AddToDiagnostic};
|
use crate::{fluent_generated as fluent, AddToDiagnostic};
|
||||||
use crate::{DiagnosticArgValue, DiagnosticBuilder, Handler, IntoDiagnostic, IntoDiagnosticArg};
|
use crate::{DiagCtxt, DiagnosticArgValue, DiagnosticBuilder, IntoDiagnostic, IntoDiagnosticArg};
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
|
@ -246,7 +246,7 @@ impl<Id> IntoDiagnosticArg for hir::def::Res<Id> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnostic<'_, !> for TargetDataLayoutErrors<'_> {
|
impl IntoDiagnostic<'_, !> for TargetDataLayoutErrors<'_> {
|
||||||
fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, !> {
|
fn into_diagnostic(self, handler: &DiagCtxt) -> DiagnosticBuilder<'_, !> {
|
||||||
let mut diag;
|
let mut diag;
|
||||||
match self {
|
match self {
|
||||||
TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => {
|
TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => {
|
||||||
|
|
|
@ -16,8 +16,8 @@ use crate::snippet::{
|
||||||
use crate::styled_buffer::StyledBuffer;
|
use crate::styled_buffer::StyledBuffer;
|
||||||
use crate::translation::{to_fluent_args, Translate};
|
use crate::translation::{to_fluent_args, Translate};
|
||||||
use crate::{
|
use crate::{
|
||||||
diagnostic::DiagnosticLocation, CodeSuggestion, Diagnostic, DiagnosticId, DiagnosticMessage,
|
diagnostic::DiagnosticLocation, CodeSuggestion, DiagCtxt, Diagnostic, DiagnosticId,
|
||||||
FluentBundle, Handler, LazyFallbackBundle, Level, MultiSpan, SubDiagnostic,
|
DiagnosticMessage, FluentBundle, LazyFallbackBundle, Level, MultiSpan, SubDiagnostic,
|
||||||
SubstitutionHighlight, SuggestionStyle, TerminalUrl,
|
SubstitutionHighlight, SuggestionStyle, TerminalUrl,
|
||||||
};
|
};
|
||||||
use rustc_lint_defs::pluralize;
|
use rustc_lint_defs::pluralize;
|
||||||
|
@ -556,7 +556,7 @@ impl Emitter for EmitterWriter {
|
||||||
/// Fatal diagnostics are forwarded to `fatal_handler` to avoid silent
|
/// Fatal diagnostics are forwarded to `fatal_handler` to avoid silent
|
||||||
/// failures of rustc, as witnessed e.g. in issue #89358.
|
/// failures of rustc, as witnessed e.g. in issue #89358.
|
||||||
pub struct SilentEmitter {
|
pub struct SilentEmitter {
|
||||||
pub fatal_handler: Handler,
|
pub fatal_handler: DiagCtxt,
|
||||||
pub fatal_note: Option<String>,
|
pub fatal_note: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use crate::emitter::ColorConfig;
|
use crate::emitter::ColorConfig;
|
||||||
use crate::Handler;
|
use crate::DiagCtxt;
|
||||||
use rustc_span::BytePos;
|
use rustc_span::BytePos;
|
||||||
|
|
||||||
use std::str;
|
use std::str;
|
||||||
|
@ -61,7 +61,7 @@ fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) {
|
||||||
);
|
);
|
||||||
|
|
||||||
let span = Span::with_root_ctxt(BytePos(span.0), BytePos(span.1));
|
let span = Span::with_root_ctxt(BytePos(span.0), BytePos(span.1));
|
||||||
let handler = Handler::with_emitter(Box::new(je));
|
let handler = DiagCtxt::with_emitter(Box::new(je));
|
||||||
handler.span_err(span, "foo");
|
handler.span_err(span, "foo");
|
||||||
|
|
||||||
let bytes = output.lock().unwrap();
|
let bytes = output.lock().unwrap();
|
||||||
|
|
|
@ -412,7 +412,7 @@ use std::backtrace::{Backtrace, BacktraceStatus};
|
||||||
/// A handler deals with errors and other compiler output.
|
/// A handler deals with errors and other compiler output.
|
||||||
/// Certain errors (fatal, bug, unimpl) may cause immediate exit,
|
/// Certain errors (fatal, bug, unimpl) may cause immediate exit,
|
||||||
/// others log errors for later reporting.
|
/// others log errors for later reporting.
|
||||||
pub struct Handler {
|
pub struct DiagCtxt {
|
||||||
inner: Lock<HandlerInner>,
|
inner: Lock<HandlerInner>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,7 +572,7 @@ impl Drop for HandlerInner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Handler {
|
impl DiagCtxt {
|
||||||
pub fn with_tty_emitter(
|
pub fn with_tty_emitter(
|
||||||
sm: Option<Lrc<SourceMap>>,
|
sm: Option<Lrc<SourceMap>>,
|
||||||
fallback_bundle: LazyFallbackBundle,
|
fallback_bundle: LazyFallbackBundle,
|
||||||
|
@ -1413,9 +1413,9 @@ impl Handler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: we prefer implementing operations on `Handler`, rather than
|
// Note: we prefer implementing operations on `DiagCtxt`, rather than
|
||||||
// `HandlerInner`, whenever possible. This minimizes functions where
|
// `HandlerInner`, whenever possible. This minimizes functions where
|
||||||
// `Handler::foo()` just borrows `inner` and forwards a call to
|
// `DiagCtxt::foo()` just borrows `inner` and forwards a call to
|
||||||
// `HanderInner::foo`.
|
// `HanderInner::foo`.
|
||||||
impl HandlerInner {
|
impl HandlerInner {
|
||||||
/// Emit all stashed diagnostics.
|
/// Emit all stashed diagnostics.
|
||||||
|
|
|
@ -1350,7 +1350,7 @@ pub fn get_exprs_from_tts(cx: &mut ExtCtxt<'_>, tts: TokenStream) -> Option<Vec<
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_macro_name_and_helper_attrs(
|
pub fn parse_macro_name_and_helper_attrs(
|
||||||
diag: &rustc_errors::Handler,
|
diag: &rustc_errors::DiagCtxt,
|
||||||
attr: &Attribute,
|
attr: &Attribute,
|
||||||
macro_type: &str,
|
macro_type: &str,
|
||||||
) -> Option<(Symbol, Vec<Symbol>)> {
|
) -> Option<(Symbol, Vec<Symbol>)> {
|
||||||
|
|
|
@ -8,7 +8,7 @@ use rustc_span::{BytePos, Span};
|
||||||
|
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_errors::emitter::EmitterWriter;
|
use rustc_errors::emitter::EmitterWriter;
|
||||||
use rustc_errors::{Handler, MultiSpan, PResult};
|
use rustc_errors::{DiagCtxt, MultiSpan, PResult};
|
||||||
use termcolor::WriteColor;
|
use termcolor::WriteColor;
|
||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
@ -23,7 +23,7 @@ fn string_to_parser(ps: &ParseSess, source_str: String) -> Parser<'_> {
|
||||||
new_parser_from_source_str(ps, PathBuf::from("bogofile").into(), source_str)
|
new_parser_from_source_str(ps, PathBuf::from("bogofile").into(), source_str)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_test_handler() -> (Handler, Lrc<SourceMap>, Arc<Mutex<Vec<u8>>>) {
|
fn create_test_handler() -> (DiagCtxt, Lrc<SourceMap>, Arc<Mutex<Vec<u8>>>) {
|
||||||
let output = Arc::new(Mutex::new(Vec::new()));
|
let output = Arc::new(Mutex::new(Vec::new()));
|
||||||
let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||||
let fallback_bundle = rustc_errors::fallback_fluent_bundle(
|
let fallback_bundle = rustc_errors::fallback_fluent_bundle(
|
||||||
|
@ -33,7 +33,7 @@ fn create_test_handler() -> (Handler, Lrc<SourceMap>, Arc<Mutex<Vec<u8>>>) {
|
||||||
let emitter = EmitterWriter::new(Box::new(Shared { data: output.clone() }), fallback_bundle)
|
let emitter = EmitterWriter::new(Box::new(Shared { data: output.clone() }), fallback_bundle)
|
||||||
.sm(Some(source_map.clone()))
|
.sm(Some(source_map.clone()))
|
||||||
.diagnostic_width(Some(140));
|
.diagnostic_width(Some(140));
|
||||||
let handler = Handler::with_emitter(Box::new(emitter));
|
let handler = DiagCtxt::with_emitter(Box::new(emitter));
|
||||||
(handler, source_map, output)
|
(handler, source_map, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::fluent_generated as fluent;
|
use crate::fluent_generated as fluent;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic,
|
error_code, Applicability, DiagCtxt, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic,
|
||||||
MultiSpan,
|
MultiSpan,
|
||||||
};
|
};
|
||||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||||
|
@ -317,7 +317,7 @@ pub struct MissingTypeParams {
|
||||||
// Manual implementation of `IntoDiagnostic` to be able to call `span_to_snippet`.
|
// Manual implementation of `IntoDiagnostic` to be able to call `span_to_snippet`.
|
||||||
impl<'a> IntoDiagnostic<'a> for MissingTypeParams {
|
impl<'a> IntoDiagnostic<'a> for MissingTypeParams {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
fn into_diagnostic(self, handler: &'a DiagCtxt) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||||
let mut err = handler.struct_span_err_with_code(
|
let mut err = handler.struct_span_err_with_code(
|
||||||
self.span,
|
self.span,
|
||||||
fluent::hir_analysis_missing_type_params,
|
fluent::hir_analysis_missing_type_params,
|
||||||
|
|
|
@ -8,7 +8,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_data_structures::stable_hasher::StableHasher;
|
use rustc_data_structures::stable_hasher::StableHasher;
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_errors::registry::Registry;
|
use rustc_errors::registry::Registry;
|
||||||
use rustc_errors::{ErrorGuaranteed, Handler};
|
use rustc_errors::{DiagCtxt, ErrorGuaranteed};
|
||||||
use rustc_lint::LintStore;
|
use rustc_lint::LintStore;
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
use rustc_middle::util::Providers;
|
use rustc_middle::util::Providers;
|
||||||
|
@ -42,7 +42,7 @@ pub struct Compiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts strings provided as `--cfg [cfgspec]` into a `Cfg`.
|
/// Converts strings provided as `--cfg [cfgspec]` into a `Cfg`.
|
||||||
pub(crate) fn parse_cfg(handler: &Handler, cfgs: Vec<String>) -> Cfg {
|
pub(crate) fn parse_cfg(handler: &DiagCtxt, cfgs: Vec<String>) -> Cfg {
|
||||||
cfgs.into_iter()
|
cfgs.into_iter()
|
||||||
.map(|s| {
|
.map(|s| {
|
||||||
let sess = ParseSess::with_silent_emitter(Some(format!(
|
let sess = ParseSess::with_silent_emitter(Some(format!(
|
||||||
|
@ -101,7 +101,7 @@ pub(crate) fn parse_cfg(handler: &Handler, cfgs: Vec<String>) -> Cfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts strings provided as `--check-cfg [specs]` into a `CheckCfg`.
|
/// Converts strings provided as `--check-cfg [specs]` into a `CheckCfg`.
|
||||||
pub(crate) fn parse_check_cfg(handler: &Handler, specs: Vec<String>) -> CheckCfg {
|
pub(crate) fn parse_check_cfg(handler: &DiagCtxt, specs: Vec<String>) -> CheckCfg {
|
||||||
// If any --check-cfg is passed then exhaustive_values and exhaustive_names
|
// If any --check-cfg is passed then exhaustive_values and exhaustive_names
|
||||||
// are enabled by default.
|
// are enabled by default.
|
||||||
let exhaustive_names = !specs.is_empty();
|
let exhaustive_names = !specs.is_empty();
|
||||||
|
@ -433,14 +433,14 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn try_print_query_stack(
|
pub fn try_print_query_stack(
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
num_frames: Option<usize>,
|
num_frames: Option<usize>,
|
||||||
file: Option<std::fs::File>,
|
file: Option<std::fs::File>,
|
||||||
) {
|
) {
|
||||||
eprintln!("query stack during panic:");
|
eprintln!("query stack during panic:");
|
||||||
|
|
||||||
// Be careful relying on global state here: this code is called from
|
// Be careful relying on global state here: this code is called from
|
||||||
// a panic hook, which means that the global `Handler` may be in a weird
|
// a panic hook, which means that the global `DiagCtxt` may be in a weird
|
||||||
// state if it was responsible for triggering the panic.
|
// state if it was responsible for triggering the panic.
|
||||||
let i = ty::tls::with_context_opt(|icx| {
|
let i = ty::tls::with_context_opt(|icx| {
|
||||||
if let Some(icx) = icx {
|
if let Some(icx) = icx {
|
||||||
|
|
|
@ -89,7 +89,7 @@ impl<'a> DiagnosticDerive<'a> {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(
|
fn into_diagnostic(
|
||||||
self,
|
self,
|
||||||
#handler: &'__diagnostic_handler_sess rustc_errors::Handler
|
#handler: &'__diagnostic_handler_sess rustc_errors::DiagCtxt
|
||||||
) -> rustc_errors::DiagnosticBuilder<'__diagnostic_handler_sess, G> {
|
) -> rustc_errors::DiagnosticBuilder<'__diagnostic_handler_sess, G> {
|
||||||
use rustc_errors::IntoDiagnosticArg;
|
use rustc_errors::IntoDiagnosticArg;
|
||||||
#implementation
|
#implementation
|
||||||
|
|
|
@ -498,7 +498,7 @@ pub(crate) struct MultipleCandidates {
|
||||||
impl IntoDiagnostic<'_> for MultipleCandidates {
|
impl IntoDiagnostic<'_> for MultipleCandidates {
|
||||||
fn into_diagnostic(
|
fn into_diagnostic(
|
||||||
self,
|
self,
|
||||||
handler: &'_ rustc_errors::Handler,
|
handler: &'_ rustc_errors::DiagCtxt,
|
||||||
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_err(fluent::metadata_multiple_candidates);
|
let mut diag = handler.struct_err(fluent::metadata_multiple_candidates);
|
||||||
diag.set_arg("crate_name", self.crate_name);
|
diag.set_arg("crate_name", self.crate_name);
|
||||||
|
@ -597,7 +597,7 @@ impl IntoDiagnostic<'_> for InvalidMetadataFiles {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(
|
fn into_diagnostic(
|
||||||
self,
|
self,
|
||||||
handler: &'_ rustc_errors::Handler,
|
handler: &'_ rustc_errors::DiagCtxt,
|
||||||
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_err(fluent::metadata_invalid_meta_files);
|
let mut diag = handler.struct_err(fluent::metadata_invalid_meta_files);
|
||||||
diag.set_arg("crate_name", self.crate_name);
|
diag.set_arg("crate_name", self.crate_name);
|
||||||
|
@ -627,7 +627,7 @@ impl IntoDiagnostic<'_> for CannotFindCrate {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(
|
fn into_diagnostic(
|
||||||
self,
|
self,
|
||||||
handler: &'_ rustc_errors::Handler,
|
handler: &'_ rustc_errors::DiagCtxt,
|
||||||
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_err(fluent::metadata_cannot_find_crate);
|
let mut diag = handler.struct_err(fluent::metadata_cannot_find_crate);
|
||||||
diag.set_arg("crate_name", self.crate_name);
|
diag.set_arg("crate_name", self.crate_name);
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::ty::normalize_erasing_regions::NormalizationError;
|
||||||
use crate::ty::{self, ConstKind, Ty, TyCtxt, TypeVisitableExt};
|
use crate::ty::{self, ConstKind, Ty, TyCtxt, TypeVisitableExt};
|
||||||
use rustc_error_messages::DiagnosticMessage;
|
use rustc_error_messages::DiagnosticMessage;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
DiagnosticArgValue, DiagnosticBuilder, Handler, IntoDiagnostic, IntoDiagnosticArg,
|
DiagCtxt, DiagnosticArgValue, DiagnosticBuilder, IntoDiagnostic, IntoDiagnosticArg,
|
||||||
};
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
|
@ -1273,7 +1273,7 @@ pub enum FnAbiError<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b> IntoDiagnostic<'a, !> for FnAbiError<'b> {
|
impl<'a, 'b> IntoDiagnostic<'a, !> for FnAbiError<'b> {
|
||||||
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, !> {
|
fn into_diagnostic(self, handler: &'a DiagCtxt) -> DiagnosticBuilder<'a, !> {
|
||||||
match self {
|
match self {
|
||||||
Self::Layout(e) => e.into_diagnostic().into_diagnostic(handler),
|
Self::Layout(e) => e.into_diagnostic().into_diagnostic(handler),
|
||||||
Self::AdjustForForeignAbi(call::AdjustForForeignAbiError::Unsupported {
|
Self::AdjustForForeignAbi(call::AdjustForForeignAbiError::Unsupported {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::fluent_generated as fluent;
|
use crate::fluent_generated as fluent;
|
||||||
use rustc_errors::DiagnosticArgValue;
|
use rustc_errors::DiagnosticArgValue;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
error_code, AddToDiagnostic, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
|
error_code, AddToDiagnostic, Applicability, DiagCtxt, Diagnostic, DiagnosticBuilder,
|
||||||
Handler, IntoDiagnostic, MultiSpan, SubdiagnosticMessage,
|
ErrorGuaranteed, IntoDiagnostic, MultiSpan, SubdiagnosticMessage,
|
||||||
};
|
};
|
||||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
|
@ -461,7 +461,7 @@ pub(crate) struct NonExhaustivePatternsTypeNotEmpty<'p, 'tcx, 'm> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IntoDiagnostic<'a> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> {
|
impl<'a> IntoDiagnostic<'a> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> {
|
||||||
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
fn into_diagnostic(self, handler: &'a DiagCtxt) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_span_err_with_code(
|
let mut diag = handler.struct_span_err_with_code(
|
||||||
self.span,
|
self.span,
|
||||||
fluent::mir_build_non_exhaustive_patterns_type_not_empty,
|
fluent::mir_build_non_exhaustive_patterns_type_not_empty,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
Applicability, DecorateLint, DiagnosticArgValue, DiagnosticBuilder, DiagnosticMessage,
|
Applicability, DecorateLint, DiagCtxt, DiagnosticArgValue, DiagnosticBuilder,
|
||||||
EmissionGuarantee, ErrorGuaranteed, Handler, IntoDiagnostic,
|
DiagnosticMessage, EmissionGuarantee, ErrorGuaranteed, IntoDiagnostic,
|
||||||
};
|
};
|
||||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||||
use rustc_middle::mir::{AssertKind, UnsafetyViolationDetails};
|
use rustc_middle::mir::{AssertKind, UnsafetyViolationDetails};
|
||||||
|
@ -64,7 +64,10 @@ pub(crate) struct RequiresUnsafe {
|
||||||
// but this would result in a lot of duplication.
|
// but this would result in a lot of duplication.
|
||||||
impl<'sess> IntoDiagnostic<'sess> for RequiresUnsafe {
|
impl<'sess> IntoDiagnostic<'sess> for RequiresUnsafe {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(self, handler: &'sess Handler) -> DiagnosticBuilder<'sess, ErrorGuaranteed> {
|
fn into_diagnostic(
|
||||||
|
self,
|
||||||
|
handler: &'sess DiagCtxt,
|
||||||
|
) -> DiagnosticBuilder<'sess, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_err(fluent::mir_transform_requires_unsafe);
|
let mut diag = handler.struct_err(fluent::mir_transform_requires_unsafe);
|
||||||
diag.code(rustc_errors::DiagnosticId::Error("E0133".to_string()));
|
diag.code(rustc_errors::DiagnosticId::Error("E0133".to_string()));
|
||||||
diag.set_span(self.span);
|
diag.set_span(self.span);
|
||||||
|
|
|
@ -51,7 +51,7 @@ impl IntoDiagnostic<'_> for UnusedGenericParamsHint {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(
|
fn into_diagnostic(
|
||||||
self,
|
self,
|
||||||
handler: &'_ rustc_errors::Handler,
|
handler: &'_ rustc_errors::DiagCtxt,
|
||||||
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_err(fluent::monomorphize_unused_generic_params);
|
let mut diag = handler.struct_err(fluent::monomorphize_unused_generic_params);
|
||||||
diag.set_span(self.span);
|
diag.set_span(self.span);
|
||||||
|
|
|
@ -1042,7 +1042,7 @@ impl<'a> IntoDiagnostic<'a> for ExpectedIdentifier {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(
|
fn into_diagnostic(
|
||||||
self,
|
self,
|
||||||
handler: &'a rustc_errors::Handler,
|
handler: &'a rustc_errors::DiagCtxt,
|
||||||
) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
|
) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||||
let token_descr = TokenDescription::from_token(&self.token);
|
let token_descr = TokenDescription::from_token(&self.token);
|
||||||
|
|
||||||
|
@ -1099,7 +1099,7 @@ impl<'a> IntoDiagnostic<'a> for ExpectedSemi {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(
|
fn into_diagnostic(
|
||||||
self,
|
self,
|
||||||
handler: &'a rustc_errors::Handler,
|
handler: &'a rustc_errors::DiagCtxt,
|
||||||
) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
|
) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||||
let token_descr = TokenDescription::from_token(&self.token);
|
let token_descr = TokenDescription::from_token(&self.token);
|
||||||
|
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
use std::iter::once;
|
use std::iter::once;
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
|
|
||||||
use rustc_errors::{Applicability, Handler};
|
use rustc_errors::{Applicability, DiagCtxt};
|
||||||
use rustc_lexer::unescape::{EscapeError, Mode};
|
use rustc_lexer::unescape::{EscapeError, Mode};
|
||||||
use rustc_span::{BytePos, Span};
|
use rustc_span::{BytePos, Span};
|
||||||
|
|
||||||
use crate::errors::{MoreThanOneCharNote, MoreThanOneCharSugg, NoBraceUnicodeSub, UnescapeError};
|
use crate::errors::{MoreThanOneCharNote, MoreThanOneCharSugg, NoBraceUnicodeSub, UnescapeError};
|
||||||
|
|
||||||
pub(crate) fn emit_unescape_error(
|
pub(crate) fn emit_unescape_error(
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
// interior part of the literal, between quotes
|
// interior part of the literal, between quotes
|
||||||
lit: &str,
|
lit: &str,
|
||||||
// full span of the literal, including quotes and any prefix
|
// full span of the literal, including quotes and any prefix
|
||||||
|
|
|
@ -34,8 +34,8 @@ use rustc_ast::{
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
pluralize, AddToDiagnostic, Applicability, Diagnostic, DiagnosticBuilder, DiagnosticMessage,
|
pluralize, AddToDiagnostic, Applicability, DiagCtxt, Diagnostic, DiagnosticBuilder,
|
||||||
ErrorGuaranteed, FatalError, Handler, IntoDiagnostic, MultiSpan, PResult,
|
DiagnosticMessage, ErrorGuaranteed, FatalError, IntoDiagnostic, MultiSpan, PResult,
|
||||||
};
|
};
|
||||||
use rustc_session::errors::ExprParenthesesNeeded;
|
use rustc_session::errors::ExprParenthesesNeeded;
|
||||||
use rustc_span::source_map::Spanned;
|
use rustc_span::source_map::Spanned;
|
||||||
|
@ -253,7 +253,7 @@ impl<'a> Parser<'a> {
|
||||||
self.diagnostic().span_bug(sp, msg)
|
self.diagnostic().span_bug(sp, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn diagnostic(&self) -> &'a Handler {
|
pub(super) fn diagnostic(&self) -> &'a DiagCtxt {
|
||||||
&self.sess.span_diagnostic
|
&self.sess.span_diagnostic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -867,7 +867,7 @@ impl IntoDiagnostic<'_> for InvalidAttrAtCrateLevel {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(
|
fn into_diagnostic(
|
||||||
self,
|
self,
|
||||||
handler: &'_ rustc_errors::Handler,
|
handler: &'_ rustc_errors::DiagCtxt,
|
||||||
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_err(fluent::passes_invalid_attr_at_crate_level);
|
let mut diag = handler.struct_err(fluent::passes_invalid_attr_at_crate_level);
|
||||||
diag.set_span(self.span);
|
diag.set_span(self.span);
|
||||||
|
@ -1020,7 +1020,7 @@ impl<'a> IntoDiagnostic<'_> for BreakNonLoop<'a> {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(
|
fn into_diagnostic(
|
||||||
self,
|
self,
|
||||||
handler: &rustc_errors::Handler,
|
handler: &rustc_errors::DiagCtxt,
|
||||||
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_span_err_with_code(
|
let mut diag = handler.struct_span_err_with_code(
|
||||||
self.span,
|
self.span,
|
||||||
|
@ -1169,7 +1169,7 @@ impl IntoDiagnostic<'_> for NakedFunctionsAsmBlock {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(
|
fn into_diagnostic(
|
||||||
self,
|
self,
|
||||||
handler: &rustc_errors::Handler,
|
handler: &rustc_errors::DiagCtxt,
|
||||||
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_span_err_with_code(
|
let mut diag = handler.struct_span_err_with_code(
|
||||||
self.span,
|
self.span,
|
||||||
|
@ -1285,7 +1285,7 @@ impl<'a> IntoDiagnostic<'a> for NoMainErr {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(
|
fn into_diagnostic(
|
||||||
self,
|
self,
|
||||||
handler: &'a rustc_errors::Handler,
|
handler: &'a rustc_errors::DiagCtxt,
|
||||||
) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
|
) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_span_err_with_code(
|
let mut diag = handler.struct_span_err_with_code(
|
||||||
DUMMY_SP,
|
DUMMY_SP,
|
||||||
|
@ -1348,7 +1348,7 @@ impl IntoDiagnostic<'_> for DuplicateLangItem {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(
|
fn into_diagnostic(
|
||||||
self,
|
self,
|
||||||
handler: &rustc_errors::Handler,
|
handler: &rustc_errors::DiagCtxt,
|
||||||
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_err_with_code(
|
let mut diag = handler.struct_err_with_code(
|
||||||
match self.duplicate {
|
match self.duplicate {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::query::DepKind;
|
||||||
use crate::query::{QueryContext, QueryStackFrame};
|
use crate::query::{QueryContext, QueryStackFrame};
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
Diagnostic, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic, Level,
|
DiagCtxt, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic, Level,
|
||||||
};
|
};
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
|
@ -610,12 +610,12 @@ pub(crate) fn report_cycle<'a>(
|
||||||
pub fn print_query_stack<Qcx: QueryContext>(
|
pub fn print_query_stack<Qcx: QueryContext>(
|
||||||
qcx: Qcx,
|
qcx: Qcx,
|
||||||
mut current_query: Option<QueryJobId>,
|
mut current_query: Option<QueryJobId>,
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
num_frames: Option<usize>,
|
num_frames: Option<usize>,
|
||||||
mut file: Option<std::fs::File>,
|
mut file: Option<std::fs::File>,
|
||||||
) -> usize {
|
) -> usize {
|
||||||
// Be careful relying on global state here: this code is called from
|
// Be careful relying on global state here: this code is called from
|
||||||
// a panic hook, which means that the global `Handler` may be in a weird
|
// a panic hook, which means that the global `DiagCtxt` may be in a weird
|
||||||
// state if it was responsible for triggering the panic.
|
// state if it was responsible for triggering the panic.
|
||||||
let mut count_printed = 0;
|
let mut count_printed = 0;
|
||||||
let mut count_total = 0;
|
let mut count_total = 0;
|
||||||
|
|
|
@ -17,7 +17,7 @@ impl<'a> IntoDiagnostic<'a> for FeatureGateError {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(
|
fn into_diagnostic(
|
||||||
self,
|
self,
|
||||||
handler: &'a rustc_errors::Handler,
|
handler: &'a rustc_errors::DiagCtxt,
|
||||||
) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
|
) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_err(self.explain);
|
let mut diag = handler.struct_err(self.explain);
|
||||||
diag.set_span(self.span);
|
diag.set_span(self.span);
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::lint::{
|
||||||
use rustc_ast::node_id::NodeId;
|
use rustc_ast::node_id::NodeId;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc};
|
use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc};
|
||||||
use rustc_errors::{emitter::SilentEmitter, Handler};
|
use rustc_errors::{emitter::SilentEmitter, DiagCtxt};
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
fallback_fluent_bundle, Diagnostic, DiagnosticBuilder, DiagnosticId, DiagnosticMessage,
|
fallback_fluent_bundle, Diagnostic, DiagnosticBuilder, DiagnosticId, DiagnosticMessage,
|
||||||
ErrorGuaranteed, IntoDiagnostic, MultiSpan, Noted, StashKey,
|
ErrorGuaranteed, IntoDiagnostic, MultiSpan, Noted, StashKey,
|
||||||
|
@ -189,7 +189,7 @@ pub fn add_feature_diagnostics_for_issue(
|
||||||
|
|
||||||
/// Info about a parsing session.
|
/// Info about a parsing session.
|
||||||
pub struct ParseSess {
|
pub struct ParseSess {
|
||||||
pub span_diagnostic: Handler,
|
pub span_diagnostic: DiagCtxt,
|
||||||
pub unstable_features: UnstableFeatures,
|
pub unstable_features: UnstableFeatures,
|
||||||
pub config: Cfg,
|
pub config: Cfg,
|
||||||
pub check_config: CheckCfg,
|
pub check_config: CheckCfg,
|
||||||
|
@ -227,11 +227,11 @@ impl ParseSess {
|
||||||
pub fn new(locale_resources: Vec<&'static str>, file_path_mapping: FilePathMapping) -> Self {
|
pub fn new(locale_resources: Vec<&'static str>, file_path_mapping: FilePathMapping) -> Self {
|
||||||
let fallback_bundle = fallback_fluent_bundle(locale_resources, false);
|
let fallback_bundle = fallback_fluent_bundle(locale_resources, false);
|
||||||
let sm = Lrc::new(SourceMap::new(file_path_mapping));
|
let sm = Lrc::new(SourceMap::new(file_path_mapping));
|
||||||
let handler = Handler::with_tty_emitter(Some(sm.clone()), fallback_bundle);
|
let handler = DiagCtxt::with_tty_emitter(Some(sm.clone()), fallback_bundle);
|
||||||
ParseSess::with_span_handler(handler, sm)
|
ParseSess::with_span_handler(handler, sm)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_span_handler(handler: Handler, source_map: Lrc<SourceMap>) -> Self {
|
pub fn with_span_handler(handler: DiagCtxt, source_map: Lrc<SourceMap>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
span_diagnostic: handler,
|
span_diagnostic: handler,
|
||||||
unstable_features: UnstableFeatures::from_environment(None),
|
unstable_features: UnstableFeatures::from_environment(None),
|
||||||
|
@ -256,8 +256,8 @@ impl ParseSess {
|
||||||
pub fn with_silent_emitter(fatal_note: Option<String>) -> Self {
|
pub fn with_silent_emitter(fatal_note: Option<String>) -> Self {
|
||||||
let fallback_bundle = fallback_fluent_bundle(Vec::new(), false);
|
let fallback_bundle = fallback_fluent_bundle(Vec::new(), false);
|
||||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||||
let fatal_handler = Handler::with_tty_emitter(None, fallback_bundle).disable_warnings();
|
let fatal_handler = DiagCtxt::with_tty_emitter(None, fallback_bundle).disable_warnings();
|
||||||
let handler = Handler::with_emitter(Box::new(SilentEmitter { fatal_handler, fatal_note }))
|
let handler = DiagCtxt::with_emitter(Box::new(SilentEmitter { fatal_handler, fatal_note }))
|
||||||
.disable_warnings();
|
.disable_warnings();
|
||||||
ParseSess::with_span_handler(handler, sm)
|
ParseSess::with_span_handler(handler, sm)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,9 @@ use rustc_errors::emitter::{DynEmitter, EmitterWriter, HumanReadableErrorType};
|
||||||
use rustc_errors::json::JsonEmitter;
|
use rustc_errors::json::JsonEmitter;
|
||||||
use rustc_errors::registry::Registry;
|
use rustc_errors::registry::Registry;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
error_code, fallback_fluent_bundle, DiagnosticBuilder, DiagnosticId, DiagnosticMessage,
|
error_code, fallback_fluent_bundle, DiagCtxt, DiagnosticBuilder, DiagnosticId,
|
||||||
ErrorGuaranteed, FluentBundle, Handler, IntoDiagnostic, LazyFallbackBundle, MultiSpan, Noted,
|
DiagnosticMessage, ErrorGuaranteed, FluentBundle, IntoDiagnostic, LazyFallbackBundle,
|
||||||
TerminalUrl,
|
MultiSpan, Noted, TerminalUrl,
|
||||||
};
|
};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
pub use rustc_span::def_id::StableCrateId;
|
pub use rustc_span::def_id::StableCrateId;
|
||||||
|
@ -677,7 +677,7 @@ impl Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn diagnostic(&self) -> &Handler {
|
pub fn diagnostic(&self) -> &DiagCtxt {
|
||||||
&self.parse_sess.span_diagnostic
|
&self.parse_sess.span_diagnostic
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1416,7 +1416,7 @@ pub fn build_session(
|
||||||
);
|
);
|
||||||
let emitter = default_emitter(&sopts, registry, source_map.clone(), bundle, fallback_bundle);
|
let emitter = default_emitter(&sopts, registry, source_map.clone(), bundle, fallback_bundle);
|
||||||
|
|
||||||
let mut span_diagnostic = Handler::with_emitter(emitter)
|
let mut span_diagnostic = DiagCtxt::with_emitter(emitter)
|
||||||
.with_flags(sopts.unstable_opts.diagnostic_handler_flags(can_emit_warnings));
|
.with_flags(sopts.unstable_opts.diagnostic_handler_flags(can_emit_warnings));
|
||||||
if let Some(ice_file) = ice_file {
|
if let Some(ice_file) = ice_file {
|
||||||
span_diagnostic = span_diagnostic.with_ice_file(ice_file);
|
span_diagnostic = span_diagnostic.with_ice_file(ice_file);
|
||||||
|
@ -1725,15 +1725,15 @@ enum IncrCompSession {
|
||||||
InvalidBecauseOfErrors { session_directory: PathBuf },
|
InvalidBecauseOfErrors { session_directory: PathBuf },
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A wrapper around an [`Handler`] that is used for early error emissions.
|
/// A wrapper around an [`DiagCtxt`] that is used for early error emissions.
|
||||||
pub struct EarlyErrorHandler {
|
pub struct EarlyErrorHandler {
|
||||||
handler: Handler,
|
handler: DiagCtxt,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EarlyErrorHandler {
|
impl EarlyErrorHandler {
|
||||||
pub fn new(output: ErrorOutputType) -> Self {
|
pub fn new(output: ErrorOutputType) -> Self {
|
||||||
let emitter = mk_emitter(output);
|
let emitter = mk_emitter(output);
|
||||||
Self { handler: Handler::with_emitter(emitter) }
|
Self { handler: DiagCtxt::with_emitter(emitter) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn abort_if_errors(&self) {
|
pub fn abort_if_errors(&self) {
|
||||||
|
@ -1747,7 +1747,7 @@ impl EarlyErrorHandler {
|
||||||
self.handler.abort_if_errors();
|
self.handler.abort_if_errors();
|
||||||
|
|
||||||
let emitter = mk_emitter(output);
|
let emitter = mk_emitter(output);
|
||||||
self.handler = Handler::with_emitter(emitter);
|
self.handler = DiagCtxt::with_emitter(emitter);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
#[allow(rustc::untranslatable_diagnostic)]
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub struct TestOutput {
|
||||||
impl IntoDiagnostic<'_> for TestOutput {
|
impl IntoDiagnostic<'_> for TestOutput {
|
||||||
fn into_diagnostic(
|
fn into_diagnostic(
|
||||||
self,
|
self,
|
||||||
handler: &'_ rustc_errors::Handler,
|
handler: &'_ rustc_errors::DiagCtxt,
|
||||||
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
let TestOutput { span, kind, content } = self;
|
let TestOutput { span, kind, content } = self;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::fluent_generated as fluent;
|
use crate::fluent_generated as fluent;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
AddToDiagnostic, Applicability, Diagnostic, ErrorGuaranteed, Handler, IntoDiagnostic,
|
AddToDiagnostic, Applicability, DiagCtxt, Diagnostic, ErrorGuaranteed, IntoDiagnostic,
|
||||||
SubdiagnosticMessage,
|
SubdiagnosticMessage,
|
||||||
};
|
};
|
||||||
use rustc_macros::Diagnostic;
|
use rustc_macros::Diagnostic;
|
||||||
|
@ -61,7 +61,7 @@ impl IntoDiagnostic<'_> for NegativePositiveConflict<'_> {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn into_diagnostic(
|
fn into_diagnostic(
|
||||||
self,
|
self,
|
||||||
handler: &Handler,
|
handler: &DiagCtxt,
|
||||||
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
let mut diag = handler.struct_err(fluent::trait_selection_negative_positive_conflict);
|
let mut diag = handler.struct_err(fluent::trait_selection_negative_positive_conflict);
|
||||||
diag.set_arg("trait_desc", self.trait_desc.print_only_trait_path().to_string());
|
diag.set_arg("trait_desc", self.trait_desc.print_only_trait_path().to_string());
|
||||||
|
|
|
@ -803,7 +803,7 @@ impl Options {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prints deprecation warnings for deprecated options
|
/// Prints deprecation warnings for deprecated options
|
||||||
fn check_deprecated_options(matches: &getopts::Matches, diag: &rustc_errors::Handler) {
|
fn check_deprecated_options(matches: &getopts::Matches, diag: &rustc_errors::DiagCtxt) {
|
||||||
let deprecated_flags = [];
|
let deprecated_flags = [];
|
||||||
|
|
||||||
for &flag in deprecated_flags.iter() {
|
for &flag in deprecated_flags.iter() {
|
||||||
|
|
|
@ -120,7 +120,7 @@ impl<'tcx> DocContext<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new diagnostic `Handler` that can be used to emit warnings and errors.
|
/// Creates a new `DiagCtxt` that can be used to emit warnings and errors.
|
||||||
///
|
///
|
||||||
/// If the given `error_format` is `ErrorOutputType::Json` and no `SourceMap` is given, a new one
|
/// If the given `error_format` is `ErrorOutputType::Json` and no `SourceMap` is given, a new one
|
||||||
/// will be created for the handler.
|
/// will be created for the handler.
|
||||||
|
@ -129,7 +129,7 @@ pub(crate) fn new_handler(
|
||||||
source_map: Option<Lrc<source_map::SourceMap>>,
|
source_map: Option<Lrc<source_map::SourceMap>>,
|
||||||
diagnostic_width: Option<usize>,
|
diagnostic_width: Option<usize>,
|
||||||
unstable_opts: &UnstableOptions,
|
unstable_opts: &UnstableOptions,
|
||||||
) -> rustc_errors::Handler {
|
) -> rustc_errors::DiagCtxt {
|
||||||
let fallback_bundle = rustc_errors::fallback_fluent_bundle(
|
let fallback_bundle = rustc_errors::fallback_fluent_bundle(
|
||||||
rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(),
|
rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(),
|
||||||
false,
|
false,
|
||||||
|
@ -169,7 +169,7 @@ pub(crate) fn new_handler(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
rustc_errors::Handler::with_emitter(emitter)
|
rustc_errors::DiagCtxt::with_emitter(emitter)
|
||||||
.with_flags(unstable_opts.diagnostic_handler_flags(true))
|
.with_flags(unstable_opts.diagnostic_handler_flags(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ pub(crate) fn run_global_ctxt(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn report_deprecated_attr(name: &str, diag: &rustc_errors::Handler, sp: Span) {
|
fn report_deprecated_attr(name: &str, diag: &rustc_errors::DiagCtxt, sp: Span) {
|
||||||
let mut msg =
|
let mut msg =
|
||||||
diag.struct_span_warn(sp, format!("the `#![doc({name})]` attribute is deprecated"));
|
diag.struct_span_warn(sp, format!("the `#![doc({name})]` attribute is deprecated"));
|
||||||
msg.note(
|
msg.note(
|
||||||
|
|
|
@ -558,7 +558,7 @@ pub(crate) fn make_test(
|
||||||
let result = rustc_driver::catch_fatal_errors(|| {
|
let result = rustc_driver::catch_fatal_errors(|| {
|
||||||
rustc_span::create_session_if_not_set_then(edition, |_| {
|
rustc_span::create_session_if_not_set_then(edition, |_| {
|
||||||
use rustc_errors::emitter::{Emitter, EmitterWriter};
|
use rustc_errors::emitter::{Emitter, EmitterWriter};
|
||||||
use rustc_errors::Handler;
|
use rustc_errors::DiagCtxt;
|
||||||
use rustc_parse::parser::ForceCollect;
|
use rustc_parse::parser::ForceCollect;
|
||||||
use rustc_span::source_map::FilePathMapping;
|
use rustc_span::source_map::FilePathMapping;
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@ pub(crate) fn make_test(
|
||||||
let emitter = EmitterWriter::new(Box::new(io::sink()), fallback_bundle);
|
let emitter = EmitterWriter::new(Box::new(io::sink()), fallback_bundle);
|
||||||
|
|
||||||
// FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser
|
// FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser
|
||||||
let handler = Handler::with_emitter(Box::new(emitter)).disable_warnings();
|
let handler = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
|
||||||
let sess = ParseSess::with_span_handler(handler, sm);
|
let sess = ParseSess::with_span_handler(handler, sm);
|
||||||
|
|
||||||
let mut found_main = false;
|
let mut found_main = false;
|
||||||
|
@ -740,7 +740,7 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> bool {
|
||||||
rustc_driver::catch_fatal_errors(|| {
|
rustc_driver::catch_fatal_errors(|| {
|
||||||
rustc_span::create_session_if_not_set_then(edition, |_| {
|
rustc_span::create_session_if_not_set_then(edition, |_| {
|
||||||
use rustc_errors::emitter::EmitterWriter;
|
use rustc_errors::emitter::EmitterWriter;
|
||||||
use rustc_errors::Handler;
|
use rustc_errors::DiagCtxt;
|
||||||
use rustc_span::source_map::FilePathMapping;
|
use rustc_span::source_map::FilePathMapping;
|
||||||
|
|
||||||
let filename = FileName::anon_source_code(source);
|
let filename = FileName::anon_source_code(source);
|
||||||
|
@ -754,7 +754,7 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> bool {
|
||||||
|
|
||||||
let emitter = EmitterWriter::new(Box::new(io::sink()), fallback_bundle);
|
let emitter = EmitterWriter::new(Box::new(io::sink()), fallback_bundle);
|
||||||
|
|
||||||
let handler = Handler::with_emitter(Box::new(emitter)).disable_warnings();
|
let handler = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
|
||||||
let sess = ParseSess::with_span_handler(handler, sm);
|
let sess = ParseSess::with_span_handler(handler, sm);
|
||||||
let mut parser =
|
let mut parser =
|
||||||
match maybe_new_parser_from_source_str(&sess, filename, source.to_owned()) {
|
match maybe_new_parser_from_source_str(&sess, filename, source.to_owned()) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ impl ExternalHtml {
|
||||||
md_before_content: &[String],
|
md_before_content: &[String],
|
||||||
md_after_content: &[String],
|
md_after_content: &[String],
|
||||||
nightly_build: bool,
|
nightly_build: bool,
|
||||||
diag: &rustc_errors::Handler,
|
diag: &rustc_errors::DiagCtxt,
|
||||||
id_map: &mut IdMap,
|
id_map: &mut IdMap,
|
||||||
edition: Edition,
|
edition: Edition,
|
||||||
playground: &Option<Playground>,
|
playground: &Option<Playground>,
|
||||||
|
@ -79,7 +79,7 @@ pub(crate) enum LoadStringError {
|
||||||
|
|
||||||
pub(crate) fn load_string<P: AsRef<Path>>(
|
pub(crate) fn load_string<P: AsRef<Path>>(
|
||||||
file_path: P,
|
file_path: P,
|
||||||
diag: &rustc_errors::Handler,
|
diag: &rustc_errors::DiagCtxt,
|
||||||
) -> Result<String, LoadStringError> {
|
) -> Result<String, LoadStringError> {
|
||||||
let file_path = file_path.as_ref();
|
let file_path = file_path.as_ref();
|
||||||
let contents = match fs::read(file_path) {
|
let contents = match fs::read(file_path) {
|
||||||
|
@ -102,7 +102,7 @@ pub(crate) fn load_string<P: AsRef<Path>>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_external_files(names: &[String], diag: &rustc_errors::Handler) -> Option<String> {
|
fn load_external_files(names: &[String], diag: &rustc_errors::DiagCtxt) -> Option<String> {
|
||||||
let mut out = String::new();
|
let mut out = String::new();
|
||||||
for name in names {
|
for name in names {
|
||||||
let Ok(s) = load_string(name, diag) else { return None };
|
let Ok(s) = load_string(name, diag) else { return None };
|
||||||
|
|
|
@ -673,7 +673,7 @@ fn usage(argv0: &str) {
|
||||||
/// A result type used by several functions under `main()`.
|
/// A result type used by several functions under `main()`.
|
||||||
type MainResult = Result<(), ErrorGuaranteed>;
|
type MainResult = Result<(), ErrorGuaranteed>;
|
||||||
|
|
||||||
fn wrap_return(diag: &rustc_errors::Handler, res: Result<(), String>) -> MainResult {
|
fn wrap_return(diag: &rustc_errors::DiagCtxt, res: Result<(), String>) -> MainResult {
|
||||||
match res {
|
match res {
|
||||||
Ok(()) => diag.has_errors().map_or(Ok(()), Err),
|
Ok(()) => diag.has_errors().map_or(Ok(()), Err),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
@ -774,7 +774,7 @@ fn main_args(
|
||||||
}
|
}
|
||||||
|
|
||||||
// need to move these items separately because we lose them by the time the closure is called,
|
// need to move these items separately because we lose them by the time the closure is called,
|
||||||
// but we can't create the Handler ahead of time because it's not Send
|
// but we can't create the handler ahead of time because it's not Send
|
||||||
let show_coverage = options.show_coverage;
|
let show_coverage = options.show_coverage;
|
||||||
let run_check = options.run_check;
|
let run_check = options.run_check;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use rustc_data_structures::sync::{Lock, Lrc};
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
emitter::Emitter,
|
emitter::Emitter,
|
||||||
translation::{to_fluent_args, Translate},
|
translation::{to_fluent_args, Translate},
|
||||||
Applicability, Diagnostic, Handler, LazyFallbackBundle,
|
Applicability, DiagCtxt, Diagnostic, LazyFallbackBundle,
|
||||||
};
|
};
|
||||||
use rustc_parse::parse_stream_from_source_str;
|
use rustc_parse::parse_stream_from_source_str;
|
||||||
use rustc_resolve::rustdoc::source_span_for_markdown_range;
|
use rustc_resolve::rustdoc::source_span_for_markdown_range;
|
||||||
|
@ -42,7 +42,7 @@ fn check_rust_syntax(
|
||||||
let emitter = BufferEmitter { buffer: Lrc::clone(&buffer), fallback_bundle };
|
let emitter = BufferEmitter { buffer: Lrc::clone(&buffer), fallback_bundle };
|
||||||
|
|
||||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||||
let handler = Handler::with_emitter(Box::new(emitter)).disable_warnings();
|
let handler = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
|
||||||
let source = dox[code_block.code].to_owned();
|
let source = dox[code_block.code].to_owned();
|
||||||
let sess = ParseSess::with_span_handler(handler, sm);
|
let sess = ParseSess::with_span_handler(handler, sm);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ pub(crate) struct ScrapeExamplesOptions {
|
||||||
impl ScrapeExamplesOptions {
|
impl ScrapeExamplesOptions {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
matches: &getopts::Matches,
|
matches: &getopts::Matches,
|
||||||
diag: &rustc_errors::Handler,
|
diag: &rustc_errors::DiagCtxt,
|
||||||
) -> Result<Option<Self>, i32> {
|
) -> Result<Option<Self>, i32> {
|
||||||
let output_path = matches.opt_str("scrape-examples-output-path");
|
let output_path = matches.opt_str("scrape-examples-output-path");
|
||||||
let target_crates = matches.opt_strs("scrape-examples-target-crate");
|
let target_crates = matches.opt_strs("scrape-examples-target-crate");
|
||||||
|
@ -337,10 +337,11 @@ pub(crate) fn run(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: the Handler must be passed in explicitly because sess isn't available while parsing options
|
// Note: the DiagCtxt must be passed in explicitly because sess isn't available while parsing
|
||||||
|
// options.
|
||||||
pub(crate) fn load_call_locations(
|
pub(crate) fn load_call_locations(
|
||||||
with_examples: Vec<String>,
|
with_examples: Vec<String>,
|
||||||
diag: &rustc_errors::Handler,
|
diag: &rustc_errors::DiagCtxt,
|
||||||
) -> Result<AllCallLocations, i32> {
|
) -> Result<AllCallLocations, i32> {
|
||||||
let inner = || {
|
let inner = || {
|
||||||
let mut all_calls: AllCallLocations = FxHashMap::default();
|
let mut all_calls: AllCallLocations = FxHashMap::default();
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::iter::Peekable;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::str::Chars;
|
use std::str::Chars;
|
||||||
|
|
||||||
use rustc_errors::Handler;
|
use rustc_errors::DiagCtxt;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
@ -236,7 +236,7 @@ pub(crate) fn get_differences(
|
||||||
pub(crate) fn test_theme_against<P: AsRef<Path>>(
|
pub(crate) fn test_theme_against<P: AsRef<Path>>(
|
||||||
f: &P,
|
f: &P,
|
||||||
origin: &FxHashMap<String, CssPath>,
|
origin: &FxHashMap<String, CssPath>,
|
||||||
diag: &Handler,
|
diag: &DiagCtxt,
|
||||||
) -> (bool, Vec<String>) {
|
) -> (bool, Vec<String>) {
|
||||||
let against = match fs::read_to_string(f)
|
let against = match fs::read_to_string(f)
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
|
|
|
@ -6,7 +6,7 @@ use clippy_utils::diagnostics::span_lint;
|
||||||
use rustc_ast::{CoroutineKind, Fn, FnRetTy, Item, ItemKind};
|
use rustc_ast::{CoroutineKind, Fn, FnRetTy, Item, ItemKind};
|
||||||
use rustc_data_structures::sync::Lrc;
|
use rustc_data_structures::sync::Lrc;
|
||||||
use rustc_errors::emitter::EmitterWriter;
|
use rustc_errors::emitter::EmitterWriter;
|
||||||
use rustc_errors::Handler;
|
use rustc_errors::DiagCtxt;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_parse::maybe_new_parser_from_source_str;
|
use rustc_parse::maybe_new_parser_from_source_str;
|
||||||
use rustc_parse::parser::ForceCollect;
|
use rustc_parse::parser::ForceCollect;
|
||||||
|
@ -45,7 +45,7 @@ pub fn check(
|
||||||
let fallback_bundle =
|
let fallback_bundle =
|
||||||
rustc_errors::fallback_fluent_bundle(rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), false);
|
rustc_errors::fallback_fluent_bundle(rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), false);
|
||||||
let emitter = EmitterWriter::new(Box::new(io::sink()), fallback_bundle);
|
let emitter = EmitterWriter::new(Box::new(io::sink()), fallback_bundle);
|
||||||
let handler = Handler::with_emitter(Box::new(emitter)).disable_warnings();
|
let handler = DiagCtxt::with_emitter(Box::new(emitter)).disable_warnings();
|
||||||
#[expect(clippy::arc_with_non_send_sync)] // `Lrc` is expected by with_span_handler
|
#[expect(clippy::arc_with_non_send_sync)] // `Lrc` is expected by with_span_handler
|
||||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||||
let sess = ParseSess::with_span_handler(handler, sm);
|
let sess = ParseSess::with_span_handler(handler, sm);
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
|
use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
|
||||||
use rustc_errors::emitter::{DynEmitter, Emitter, EmitterWriter};
|
use rustc_errors::emitter::{DynEmitter, Emitter, EmitterWriter};
|
||||||
use rustc_errors::translation::Translate;
|
use rustc_errors::translation::Translate;
|
||||||
use rustc_errors::{ColorConfig, Diagnostic, Handler, Level as DiagnosticLevel};
|
use rustc_errors::{ColorConfig, DiagCtxt, Diagnostic, Level as DiagnosticLevel};
|
||||||
use rustc_session::parse::ParseSess as RawParseSess;
|
use rustc_session::parse::ParseSess as RawParseSess;
|
||||||
use rustc_span::{
|
use rustc_span::{
|
||||||
source_map::{FilePathMapping, SourceMap},
|
source_map::{FilePathMapping, SourceMap},
|
||||||
|
@ -124,7 +124,7 @@ fn default_handler(
|
||||||
can_reset: Lrc<AtomicBool>,
|
can_reset: Lrc<AtomicBool>,
|
||||||
hide_parse_errors: bool,
|
hide_parse_errors: bool,
|
||||||
color: Color,
|
color: Color,
|
||||||
) -> Handler {
|
) -> DiagCtxt {
|
||||||
let supports_color = term::stderr().map_or(false, |term| term.supports_color());
|
let supports_color = term::stderr().map_or(false, |term| term.supports_color());
|
||||||
let emit_color = if supports_color {
|
let emit_color = if supports_color {
|
||||||
ColorConfig::from(color)
|
ColorConfig::from(color)
|
||||||
|
@ -141,7 +141,7 @@ fn default_handler(
|
||||||
);
|
);
|
||||||
Box::new(EmitterWriter::stderr(emit_color, fallback_bundle).sm(Some(source_map.clone())))
|
Box::new(EmitterWriter::stderr(emit_color, fallback_bundle).sm(Some(source_map.clone())))
|
||||||
};
|
};
|
||||||
Handler::with_emitter(Box::new(SilentOnIgnoredFilesEmitter {
|
DiagCtxt::with_emitter(Box::new(SilentOnIgnoredFilesEmitter {
|
||||||
has_non_ignorable_parser_errors: false,
|
has_non_ignorable_parser_errors: false,
|
||||||
source_map,
|
source_map,
|
||||||
emitter,
|
emitter,
|
||||||
|
@ -218,7 +218,7 @@ impl ParseSess {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn set_silent_emitter(&mut self) {
|
pub(crate) fn set_silent_emitter(&mut self) {
|
||||||
self.parse_sess.span_diagnostic = Handler::with_emitter(silent_emitter());
|
self.parse_sess.span_diagnostic = DiagCtxt::with_emitter(silent_emitter());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn span_to_filename(&self, span: Span) -> FileName {
|
pub(crate) fn span_to_filename(&self, span: Span) -> FileName {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue