From 579cac249f4bb67fe35536b2ddafb2236ef61e0e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 13 Jun 2026 14:43:13 +0200 Subject: [PATCH 1/2] Rename `rustc_infer/src/errors.rs` into `rustc_infer/src/diagnostics.rs` --- compiler/rustc_infer/src/{errors.rs => diagnostics.rs} | 0 compiler/rustc_infer/src/infer/opaque_types/mod.rs | 2 +- compiler/rustc_infer/src/lib.rs | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename compiler/rustc_infer/src/{errors.rs => diagnostics.rs} (100%) diff --git a/compiler/rustc_infer/src/errors.rs b/compiler/rustc_infer/src/diagnostics.rs similarity index 100% rename from compiler/rustc_infer/src/errors.rs rename to compiler/rustc_infer/src/diagnostics.rs diff --git a/compiler/rustc_infer/src/infer/opaque_types/mod.rs b/compiler/rustc_infer/src/infer/opaque_types/mod.rs index 786eec30f05c9..c5c58ae1a29b4 100644 --- a/compiler/rustc_infer/src/infer/opaque_types/mod.rs +++ b/compiler/rustc_infer/src/infer/opaque_types/mod.rs @@ -12,7 +12,7 @@ use rustc_span::Span; use tracing::{debug, instrument}; use super::{DefineOpaqueTypes, RegionVariableOrigin}; -use crate::errors::OpaqueHiddenTypeDiag; +use crate::diagnostics::OpaqueHiddenTypeDiag; use crate::infer::{InferCtxt, InferOk}; use crate::traits::{self, Obligation, PredicateObligations}; diff --git a/compiler/rustc_infer/src/lib.rs b/compiler/rustc_infer/src/lib.rs index 2595c1a7b2764..f2cf938a48385 100644 --- a/compiler/rustc_infer/src/lib.rs +++ b/compiler/rustc_infer/src/lib.rs @@ -18,6 +18,6 @@ #![recursion_limit = "512"] // For rustdoc // tidy-alphabetical-end -mod errors; +mod diagnostics; pub mod infer; pub mod traits; From d4b261017282d8e8fbe40ba8683ffd54ca80bdc7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 13 Jun 2026 14:51:05 +0200 Subject: [PATCH 2/2] Rename `rustc_interface/src/errors.rs` into `rustc_interface/src/diagnostics.rs` --- .../src/{errors.rs => diagnostics.rs} | 0 compiler/rustc_interface/src/lib.rs | 2 +- compiler/rustc_interface/src/passes.rs | 38 +++++++++++-------- compiler/rustc_interface/src/queries.rs | 2 +- compiler/rustc_interface/src/util.rs | 16 ++++---- 5 files changed, 33 insertions(+), 25 deletions(-) rename compiler/rustc_interface/src/{errors.rs => diagnostics.rs} (100%) diff --git a/compiler/rustc_interface/src/errors.rs b/compiler/rustc_interface/src/diagnostics.rs similarity index 100% rename from compiler/rustc_interface/src/errors.rs rename to compiler/rustc_interface/src/diagnostics.rs diff --git a/compiler/rustc_interface/src/lib.rs b/compiler/rustc_interface/src/lib.rs index b5e4a384861f6..77ee7b8896beb 100644 --- a/compiler/rustc_interface/src/lib.rs +++ b/compiler/rustc_interface/src/lib.rs @@ -6,7 +6,7 @@ // tidy-alphabetical-end mod callbacks; -pub mod errors; +pub mod diagnostics; pub mod interface; mod limits; pub mod passes; diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 62cdc2ca60f34..25f2882345358 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -49,7 +49,7 @@ use rustc_trait_selection::{solve, traits}; use tracing::{info, instrument}; use crate::interface::Compiler; -use crate::{errors, limits, proc_macro_decls, util}; +use crate::{diagnostics, limits, proc_macro_decls, util}; pub fn parse<'a>(sess: &'a Session) -> ast::Crate { let mut krate = sess @@ -271,10 +271,10 @@ fn configure_and_expand( if crate_types.len() > 1 { if is_executable_crate { - sess.dcx().emit_err(errors::MixedBinCrate); + sess.dcx().emit_err(diagnostics::MixedBinCrate); } if is_proc_macro_crate { - sess.dcx().emit_err(errors::MixedProcMacroCrate); + sess.dcx().emit_err(diagnostics::MixedProcMacroCrate); } } if crate_types.contains(&CrateType::Sdylib) && !tcx.features().export_stable() { @@ -282,7 +282,7 @@ fn configure_and_expand( } if is_proc_macro_crate && !sess.panic_strategy().unwinds() { - sess.dcx().emit_warn(errors::ProcMacroCratePanicAbort); + sess.dcx().emit_warn(diagnostics::ProcMacroCratePanicAbort); } sess.time("maybe_create_a_macro_crate", || { @@ -458,9 +458,13 @@ fn early_lint_checks(tcx: TyCtxt<'_>, (): ()) { }) .as_str(); - sess.dcx().emit_err(errors::FerrisIdentifier { spans, first_span, ferris_fix }); + sess.dcx().emit_err(diagnostics::FerrisIdentifier { + spans, + first_span, + ferris_fix, + }); } else { - sess.dcx().emit_err(errors::EmojiIdentifier { spans, ident }); + sess.dcx().emit_err(diagnostics::EmojiIdentifier { spans, ident }); } } }); @@ -773,7 +777,8 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P } } Err(error) => { - sess.dcx().emit_fatal(errors::ErrorWritingDependencies { path: deps_filename, error }); + sess.dcx() + .emit_fatal(diagnostics::ErrorWritingDependencies { path: deps_filename, error }); } } } @@ -824,10 +829,11 @@ pub fn write_dep_info(tcx: TyCtxt<'_>) { if let Some(input_path) = sess.io.input.opt_path() { if sess.opts.will_create_output_file() { if output_contains_path(&output_paths, input_path) { - sess.dcx().emit_fatal(errors::InputFileWouldBeOverWritten { path: input_path }); + sess.dcx() + .emit_fatal(diagnostics::InputFileWouldBeOverWritten { path: input_path }); } if let Some(dir_path) = output_conflicts_with_dir(&output_paths) { - sess.dcx().emit_fatal(errors::GeneratedFileConflictsWithDirectory { + sess.dcx().emit_fatal(diagnostics::GeneratedFileConflictsWithDirectory { input_path, dir_path, }); @@ -837,7 +843,7 @@ pub fn write_dep_info(tcx: TyCtxt<'_>) { if let Some(ref dir) = sess.io.temps_dir { if fs::create_dir_all(dir).is_err() { - sess.dcx().emit_fatal(errors::TempsDirError); + sess.dcx().emit_fatal(diagnostics::TempsDirError); } } @@ -849,7 +855,7 @@ pub fn write_dep_info(tcx: TyCtxt<'_>) { if !only_dep_info { if let Some(ref dir) = sess.io.output_dir { if fs::create_dir_all(dir).is_err() { - sess.dcx().emit_fatal(errors::OutDirError); + sess.dcx().emit_fatal(diagnostics::OutDirError); } } } @@ -1353,7 +1359,7 @@ pub fn get_crate_name(sess: &Session, krate_attrs: &[ast::Attribute]) -> Symbol if let Some((attr_crate_name, span)) = attr_crate_name && attr_crate_name != crate_name { - sess.dcx().emit_err(errors::CrateNameDoesNotMatch { + sess.dcx().emit_err(diagnostics::CrateNameDoesNotMatch { span, crate_name, attr_crate_name, @@ -1370,7 +1376,7 @@ pub fn get_crate_name(sess: &Session, krate_attrs: &[ast::Attribute]) -> Symbol && let Some(file_stem) = path.file_stem().and_then(|s| s.to_str()) { if file_stem.starts_with('-') { - sess.dcx().emit_err(errors::CrateNameInvalid { crate_name: file_stem }); + sess.dcx().emit_err(diagnostics::CrateNameInvalid { crate_name: file_stem }); } else { return validate(Symbol::intern(&file_stem.replace('-', "_")), None); } @@ -1413,7 +1419,7 @@ pub fn collect_crate_types( // styles at all other locations if session.opts.test { if !session.target.executables { - session.dcx().emit_warn(errors::UnsupportedCrateTypeForTarget { + session.dcx().emit_warn(diagnostics::UnsupportedCrateTypeForTarget { crate_type: CrateType::Executable, target_triple: &session.opts.target_triple, }); @@ -1459,13 +1465,13 @@ pub fn collect_crate_types( base.retain(|crate_type| { if invalid_output_for_target(session, *crate_type) { - session.dcx().emit_warn(errors::UnsupportedCrateTypeForTarget { + session.dcx().emit_warn(diagnostics::UnsupportedCrateTypeForTarget { crate_type: *crate_type, target_triple: &session.opts.target_triple, }); false } else if !backend_crate_types.contains(crate_type) { - session.dcx().emit_warn(errors::UnsupportedCrateTypeForCodegenBackend { + session.dcx().emit_warn(diagnostics::UnsupportedCrateTypeForCodegenBackend { crate_type: *crate_type, codegen_backend: codegen_backend_name, }); diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index 6026cfd5f71fe..025a5a55d0abd 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -12,7 +12,7 @@ use rustc_middle::ty::TyCtxt; use rustc_session::Session; use rustc_session::config::{self, OutputFilenames, OutputType}; -use crate::errors::FailedWritingFile; +use crate::diagnostics::FailedWritingFile; use crate::passes; pub struct Linker { diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 6e74ec64ad241..c78e419033d78 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -30,7 +30,7 @@ use rustc_span::{SessionGlobals, Symbol, sym}; use rustc_target::spec::Target; use tracing::info; -use crate::errors; +use crate::diagnostics; use crate::passes::parse_crate_name; /// Function pointer type that constructs a new CodegenBackend. @@ -90,12 +90,14 @@ pub(crate) fn check_abi_required_features(sess: &Session) { for feature in abi_feature_constraints.required { if !sess.unstable_target_features.contains(&Symbol::intern(feature)) { - sess.dcx().emit_warn(errors::AbiRequiredTargetFeature { feature, enabled: "enabled" }); + sess.dcx() + .emit_warn(diagnostics::AbiRequiredTargetFeature { feature, enabled: "enabled" }); } } for feature in abi_feature_constraints.incompatible { if sess.unstable_target_features.contains(&Symbol::intern(feature)) { - sess.dcx().emit_warn(errors::AbiRequiredTargetFeature { feature, enabled: "disabled" }); + sess.dcx() + .emit_warn(diagnostics::AbiRequiredTargetFeature { feature, enabled: "disabled" }); } } } @@ -609,7 +611,7 @@ pub fn build_output_filenames(attrs: &[ast::Attribute], sess: &Session) -> Outpu &sess.opts.output_types, sess.io.output_file == Some(OutFileName::Stdout), ) { - sess.dcx().emit_fatal(errors::MultipleOutputTypesToStdout); + sess.dcx().emit_fatal(diagnostics::MultipleOutputTypesToStdout); } let crate_name = @@ -650,16 +652,16 @@ pub fn build_output_filenames(attrs: &[ast::Attribute], sess: &Session) -> Outpu let unnamed_output_types = sess.opts.output_types.values().filter(|a| a.is_none()).count(); let ofile = if unnamed_output_types > 1 { - sess.dcx().emit_warn(errors::MultipleOutputTypesAdaption); + sess.dcx().emit_warn(diagnostics::MultipleOutputTypesAdaption); None } else { if !sess.opts.cg.extra_filename.is_empty() { - sess.dcx().emit_warn(errors::IgnoringExtraFilename); + sess.dcx().emit_warn(diagnostics::IgnoringExtraFilename); } Some(out_file.clone()) }; if sess.io.output_dir.is_some() { - sess.dcx().emit_warn(errors::IgnoringOutDir); + sess.dcx().emit_warn(diagnostics::IgnoringOutDir); } let out_filestem =