Skip to content

Commit cde19c0

Browse files
committed
Rename Handler as DiagCtxt.
1 parent 321b656 commit cde19c0

File tree

58 files changed

+216
-204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+216
-204
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl<'a> AstValidator<'a> {
220220
}
221221
}
222222

223-
fn err_handler(&self) -> &rustc_errors::Handler {
223+
fn err_handler(&self) -> &rustc_errors::DiagCtxt {
224224
self.session.diagnostic()
225225
}
226226

@@ -697,7 +697,7 @@ impl<'a> AstValidator<'a> {
697697
/// Checks that generic parameters are in the correct order,
698698
/// which is lifetimes, then types and then consts. (`<'a, T, const N: usize>`)
699699
fn validate_generic_param_order(
700-
handler: &rustc_errors::Handler,
700+
handler: &rustc_errors::DiagCtxt,
701701
generics: &[GenericParam],
702702
span: Span,
703703
) {

compiler/rustc_ast_passes/src/show_span.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl FromStr for Mode {
3131
}
3232

3333
struct ShowSpanVisitor<'a> {
34-
span_diagnostic: &'a rustc_errors::Handler,
34+
span_diagnostic: &'a rustc_errors::DiagCtxt,
3535
mode: Mode,
3636
}
3737

@@ -58,7 +58,7 @@ impl<'a> Visitor<'a> for ShowSpanVisitor<'a> {
5858
}
5959
}
6060

61-
pub fn run(span_diagnostic: &rustc_errors::Handler, mode: &str, krate: &ast::Crate) {
61+
pub fn run(span_diagnostic: &rustc_errors::DiagCtxt, mode: &str, krate: &ast::Crate) {
6262
let Ok(mode) = mode.parse() else {
6363
return;
6464
};

compiler/rustc_attr/src/session_diagnostics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::num::IntErrorKind;
22

33
use rustc_ast as ast;
44
use rustc_errors::{
5-
error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic,
5+
error_code, Applicability, DiagCtxt, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic,
66
};
77
use rustc_macros::Diagnostic;
88
use rustc_span::{Span, Symbol};
@@ -51,7 +51,7 @@ pub(crate) struct UnknownMetaItem<'a> {
5151

5252
// Manual implementation to be able to format `expected` items correctly.
5353
impl<'a> IntoDiagnostic<'a> for UnknownMetaItem<'_> {
54-
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
54+
fn into_diagnostic(self, handler: &'a DiagCtxt) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
5555
let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>();
5656
let mut diag = handler.struct_span_err_with_code(
5757
self.span,
@@ -201,7 +201,7 @@ pub(crate) struct UnsupportedLiteral {
201201
}
202202

203203
impl<'a> IntoDiagnostic<'a> for UnsupportedLiteral {
204-
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
204+
fn into_diagnostic(self, handler: &'a DiagCtxt) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
205205
let mut diag = handler.struct_span_err_with_code(
206206
self.span,
207207
match self.reason {

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ impl UseSpans<'_> {
624624
/// Add a subdiagnostic to the use of the captured variable, if it exists.
625625
pub(super) fn var_subdiag(
626626
self,
627-
handler: Option<&rustc_errors::Handler>,
627+
handler: Option<&rustc_errors::DiagCtxt>,
628628
err: &mut Diagnostic,
629629
kind: Option<rustc_middle::mir::BorrowKind>,
630630
f: impl FnOnce(Option<CoroutineKind>, Span) -> CaptureVarCause,

compiler/rustc_builtin_macros/src/errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc_errors::{
2-
AddToDiagnostic, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic, MultiSpan,
2+
AddToDiagnostic, DiagCtxt, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic, MultiSpan,
33
SingleLabelManySpans,
44
};
55
use rustc_macros::{Diagnostic, Subdiagnostic};
@@ -448,7 +448,7 @@ pub(crate) struct EnvNotDefinedWithUserMessage {
448448
// Hand-written implementation to support custom user messages.
449449
impl<'a> IntoDiagnostic<'a> for EnvNotDefinedWithUserMessage {
450450
#[track_caller]
451-
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
451+
fn into_diagnostic(self, handler: &'a DiagCtxt) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
452452
#[expect(
453453
rustc::untranslatable_diagnostic,
454454
reason = "cannot translate user-provided messages"
@@ -802,7 +802,7 @@ pub(crate) struct AsmClobberNoReg {
802802
}
803803

804804
impl<'a> IntoDiagnostic<'a> for AsmClobberNoReg {
805-
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
805+
fn into_diagnostic(self, handler: &'a DiagCtxt) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
806806
let mut diag =
807807
handler.struct_err(crate::fluent_generated::builtin_macros_asm_clobber_no_reg);
808808
diag.set_span(self.spans.clone());

compiler/rustc_builtin_macros/src/proc_macro_harness.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ enum ProcMacro {
3838
struct CollectProcMacros<'a> {
3939
macros: Vec<ProcMacro>,
4040
in_root: bool,
41-
handler: &'a rustc_errors::Handler,
41+
handler: &'a rustc_errors::DiagCtxt,
4242
source_map: &'a SourceMap,
4343
is_proc_macro_crate: bool,
4444
is_test_crate: bool,
@@ -52,7 +52,7 @@ pub fn inject(
5252
is_proc_macro_crate: bool,
5353
has_proc_macro_decls: bool,
5454
is_test_crate: bool,
55-
handler: &rustc_errors::Handler,
55+
handler: &rustc_errors::DiagCtxt,
5656
) {
5757
let ecfg = ExpansionConfig::default("proc_macro".to_string(), features);
5858
let mut cx = ExtCtxt::new(sess, ecfg, resolver, None);

compiler/rustc_builtin_macros/src/test_harness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ fn get_test_name(i: &ast::Item) -> Option<Symbol> {
389389
attr::first_attr_value_str_by_name(&i.attrs, sym::rustc_test_marker)
390390
}
391391

392-
fn get_test_runner(sd: &rustc_errors::Handler, krate: &ast::Crate) -> Option<ast::Path> {
392+
fn get_test_runner(sd: &rustc_errors::DiagCtxt, krate: &ast::Crate) -> Option<ast::Path> {
393393
let test_attr = attr::find_by_name(&krate.attrs, sym::test_runner)?;
394394
let meta_list = test_attr.meta_item_list()?;
395395
let span = test_attr.span;

compiler/rustc_codegen_cranelift/src/concurrency_limiter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl ConcurrencyLimiter {
4646
}
4747
}
4848

49-
pub(super) fn acquire(&mut self, handler: &rustc_errors::Handler) -> ConcurrencyLimiterToken {
49+
pub(super) fn acquire(&mut self, handler: &rustc_errors::DiagCtxt) -> ConcurrencyLimiterToken {
5050
let mut state = self.state.lock().unwrap();
5151
loop {
5252
state.assert_invariants();

compiler/rustc_codegen_gcc/src/back/lto.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput};
3030
use rustc_codegen_ssa::traits::*;
3131
use rustc_codegen_ssa::{looks_like_rust_object_file, ModuleCodegen, ModuleKind};
3232
use rustc_data_structures::memmap::Mmap;
33-
use rustc_errors::{FatalError, Handler};
33+
use rustc_errors::{FatalError, DiagCtxt};
3434
use rustc_hir::def_id::LOCAL_CRATE;
3535
use rustc_middle::dep_graph::WorkProduct;
3636
use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel};
@@ -61,7 +61,7 @@ struct LtoData {
6161
tmp_path: TempDir,
6262
}
6363

64-
fn prepare_lto(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &Handler) -> Result<LtoData, FatalError> {
64+
fn prepare_lto(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &DiagCtxt) -> Result<LtoData, FatalError> {
6565
let export_threshold = match cgcx.lto {
6666
// We're just doing LTO for our one crate
6767
Lto::ThinLocal => SymbolExportLevel::Rust,
@@ -192,7 +192,7 @@ pub(crate) fn run_fat(
192192
)
193193
}
194194

195-
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,
195+
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,
196196
//symbols_below_threshold: &[*const libc::c_char],
197197
) -> Result<LtoModuleCodegen<GccCodegenBackend>, FatalError> {
198198
let _timer = cgcx.prof.generic_activity("GCC_fat_lto_build_monolithic_module");

compiler/rustc_codegen_gcc/src/back/write.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use gccjit::OutputKind;
44
use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
55
use rustc_codegen_ssa::back::link::ensure_removed;
66
use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, ModuleConfig};
7-
use rustc_errors::Handler;
7+
use rustc_errors::DiagCtxt;
88
use rustc_fs_util::link_or_copy;
99
use rustc_session::config::OutputType;
1010
use rustc_span::fatal_error::FatalError;
@@ -13,7 +13,7 @@ use rustc_target::spec::SplitDebuginfo;
1313
use crate::{GccCodegenBackend, GccContext};
1414
use crate::errors::CopyBitcode;
1515

16-
pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &Handler, module: ModuleCodegen<GccContext>, config: &ModuleConfig) -> Result<CompiledModule, FatalError> {
16+
pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &DiagCtxt, module: ModuleCodegen<GccContext>, config: &ModuleConfig) -> Result<CompiledModule, FatalError> {
1717
let _timer = cgcx.prof.generic_activity_with_arg("GCC_module_codegen", &*module.name);
1818
{
1919
let context = &module.module_llvm.context;
@@ -148,7 +148,7 @@ pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, diag_hand
148148
))
149149
}
150150

151-
pub(crate) fn link(_cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &Handler, mut _modules: Vec<ModuleCodegen<GccContext>>) -> Result<ModuleCodegen<GccContext>, FatalError> {
151+
pub(crate) fn link(_cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &DiagCtxt, mut _modules: Vec<ModuleCodegen<GccContext>>) -> Result<ModuleCodegen<GccContext>, FatalError> {
152152
unimplemented!();
153153
}
154154

0 commit comments

Comments
 (0)