Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use rustc_macros::Diagnostic;
use rustc_metadata::EncodedMetadata;
use rustc_metadata::fs::{METADATA_FILENAME, copy_to_stdout, emit_wrapper_file};
use rustc_middle::bug;
use rustc_middle::error::DuplicateEiiImpls;
use rustc_middle::diagnostics::DuplicateEiiImpls;
use rustc_middle::lint::emit_lint_base;
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
use rustc_middle::middle::dependency_format::Linkage;
Expand Down
24 changes: 12 additions & 12 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ pub mod args;
pub mod pretty;
#[macro_use]
mod print;
mod diagnostics;
pub mod highlighter;
mod session_diagnostics;

// Keep the OS parts of this `cfg` in sync with the `cfg` on the `libc`
// dependency in `compiler/rustc_driver/Cargo.toml`, to keep
Expand All @@ -103,7 +103,7 @@ mod signal_handler {
pub(super) fn install() {}
}

use crate::session_diagnostics::{
use crate::diagnostics::{
CantEmitMIR, RLinkEmptyVersionNumber, RLinkEncodingVersionMismatch, RLinkRustcVersionMismatch,
RLinkWrongFileType, RlinkCorruptFile, RlinkNotAFile, RlinkUnableToRead, UnstableFeatureUsage,
};
Expand Down Expand Up @@ -1539,17 +1539,17 @@ fn report_ice(
if !info.payload().is::<rustc_errors::ExplicitBug>()
&& !info.payload().is::<rustc_errors::DelayedBugPanic>()
{
dcx.emit_err(session_diagnostics::Ice);
dcx.emit_err(diagnostics::Ice);
}

if using_internal_features.load(std::sync::atomic::Ordering::Relaxed) {
dcx.emit_note(session_diagnostics::IceBugReportInternalFeature);
dcx.emit_note(diagnostics::IceBugReportInternalFeature);
} else {
dcx.emit_note(session_diagnostics::IceBugReport { bug_report_url });
dcx.emit_note(diagnostics::IceBugReport { bug_report_url });

// Only emit update nightly hint for users on nightly builds.
if rustc_feature::UnstableFeatures::from_environment(None).is_nightly_build() {
dcx.emit_note(session_diagnostics::UpdateNightlyNote);
dcx.emit_note(diagnostics::UpdateNightlyNote);
}
}

Expand All @@ -1562,20 +1562,20 @@ fn report_ice(
// Create the ICE dump target file.
match crate::fs::File::options().create(true).append(true).open(path) {
Ok(mut file) => {
dcx.emit_note(session_diagnostics::IcePath { path: path.clone() });
dcx.emit_note(diagnostics::IcePath { path: path.clone() });
if FIRST_PANIC.swap(false, Ordering::SeqCst) {
let _ = write!(file, "\n\nrustc version: {version}\nplatform: {tuple}");
}
Some(file)
}
Err(err) => {
// The path ICE couldn't be written to disk, provide feedback to the user as to why.
dcx.emit_warn(session_diagnostics::IcePathError {
dcx.emit_warn(diagnostics::IcePathError {
path: path.clone(),
error: err.to_string(),
env_var: std::env::var_os("RUSTC_ICE")
.map(PathBuf::from)
.map(|env_var| session_diagnostics::IcePathErrorEnv { env_var }),
.map(|env_var| diagnostics::IcePathErrorEnv { env_var }),
});
None
}
Expand All @@ -1584,12 +1584,12 @@ fn report_ice(
None
};

dcx.emit_note(session_diagnostics::IceVersion { version, triple: tuple });
dcx.emit_note(diagnostics::IceVersion { version, triple: tuple });

if let Some((flags, excluded_cargo_defaults)) = rustc_session::utils::extra_compiler_flags() {
dcx.emit_note(session_diagnostics::IceFlags { flags: flags.join(" ") });
dcx.emit_note(diagnostics::IceFlags { flags: flags.join(" ") });
if excluded_cargo_defaults {
dcx.emit_note(session_diagnostics::IceExcludeCargoDefaults);
dcx.emit_note(diagnostics::IceExcludeCargoDefaults);
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mod macros;
pub mod arena;

pub mod dep_graph;
pub mod error;
pub mod diagnostics;
pub mod hir;
pub mod hooks;
pub mod ich;
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_middle/src/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ impl<'tcx> TyCtxt<'tcx> {
/// If not found, fatally aborts compilation.
pub fn require_lang_item(self, lang_item: LangItem, span: Span) -> DefId {
self.lang_items().get(lang_item).unwrap_or_else(|| {
self.dcx().emit_fatal(crate::error::RequiresLangItem { span, name: lang_item.name() });
self.dcx()
.emit_fatal(crate::diagnostics::RequiresLangItem { span, name: lang_item.name() });
})
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_span::def_id::DefId;
use rustc_span::{DUMMY_SP, Span, Symbol};

use super::{AllocId, AllocRange, ConstAllocation, Pointer, Scalar};
use crate::error;
use crate::diagnostics;
use crate::mir::interpret::CtfeProvenance;
use crate::mir::{ConstAlloc, ConstValue};
use crate::ty::{self, Ty, TyCtxt, ValTree, layout, tls};
Expand Down Expand Up @@ -47,7 +47,7 @@ impl ErrorHandled {
match self {
&ErrorHandled::Reported(err, span) => {
if !err.allowed_in_infallible && !span.is_dummy() {
tcx.dcx().emit_note(error::ErroneousConstant { span });
tcx.dcx().emit_note(diagnostics::ErroneousConstant { span });
}
}
&ErrorHandled::TooGeneric(_) => {}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_middle/src/mir/interpret/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use super::{
};
use crate::mir::interpret::ValTreeCreationError;
use crate::ty::{self, ConstToValTreeResult, GenericArgs, TyCtxt, TypeVisitableExt};
use crate::{error, mir};
use crate::{diagnostics, mir};

impl<'tcx> TyCtxt<'tcx> {
/// Evaluates a constant without providing any generic parameters. This is useful to evaluate consts
Expand Down Expand Up @@ -219,21 +219,21 @@ impl<'tcx> TyCtxt<'tcx> {
ValTreeCreationError::NonSupportedType(ty) => Ok(Err(ty)),
// Report the others.
ValTreeCreationError::NodesOverflow => {
let handled = self.dcx().emit_err(error::MaxNumNodesInValtree {
let handled = self.dcx().emit_err(diagnostics::MaxNumNodesInValtree {
span,
global_const_id: cid.display(self),
});
Err(ReportedErrorInfo::allowed_in_infallible(handled).into())
}
ValTreeCreationError::InvalidConst => {
let handled = self.dcx().emit_err(error::InvalidConstInValtree {
let handled = self.dcx().emit_err(diagnostics::InvalidConstInValtree {
span,
global_const_id: cid.display(self),
});
Err(ReportedErrorInfo::allowed_in_infallible(handled).into())
}
ValTreeCreationError::CyclicConst => {
let handled = self.dcx().emit_err(error::CyclicConstInValtree {
let handled = self.dcx().emit_err(diagnostics::CyclicConstInValtree {
span,
global_const_id: cid.display(self),
});
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/traits/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use rustc_macros::{StableHash, TypeFoldable, TypeVisitable};
use rustc_span::Span;

use crate::error::DropCheckOverflow;
use crate::diagnostics::DropCheckOverflow;
use crate::infer::canonical::{Canonical, CanonicalQueryInput, QueryResponse};
use crate::traits::solve;
pub use crate::traits::solve::NoSolution;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/traits/specialization_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustc_hir::def_id::{DefId, DefIdMap};
use rustc_hir::find_attr;
use rustc_macros::{StableHash, TyDecodable, TyEncodable};

use crate::error::StrictCoherenceNeedsNegativeCoherence;
use crate::diagnostics::StrictCoherenceNeedsNegativeCoherence;
use crate::ty::fast_reject::SimplifiedType;
use crate::ty::{self, TyCtxt, TypeVisitableExt};

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ impl<'tcx> AdtDef<'tcx> {
Ok(Discr { val: b, ty })
} else {
info!("invalid enum discriminant: {:#?}", val);
let guar = tcx.dcx().emit_err(crate::error::ConstEvalNonIntError {
let guar = tcx.dcx().emit_err(crate::diagnostics::ConstEvalNonIntError {
span: tcx.def_span(expr_did),
});
Err(guar)
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,9 @@ impl<'tcx> TyCtxt<'tcx> {
self.verify_query_key_hashes();

if let Err((path, error)) = self.dep_graph.finish_encoding() {
self.sess.dcx().emit_fatal(crate::error::FailedWritingFile { path: &path, error });
self.sess
.dcx()
.emit_fatal(crate::diagnostics::FailedWritingFile { path: &path, error });
}
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_span::def_id::LOCAL_CRATE;
use rustc_span::{DUMMY_SP, Span};
use tracing::{debug, instrument};

use crate::error;
use crate::diagnostics;
use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use crate::ty::normalize_erasing_regions::NormalizationError;
use crate::ty::print::{FmtPrinter, Print};
Expand Down Expand Up @@ -618,7 +618,7 @@ impl<'tcx> Instance<'tcx> {
Ok(None) => {
let type_length = type_length(args);
if !tcx.type_length_limit().value_within_limit(type_length) {
tcx.dcx().emit_fatal(error::TypeLengthLimit {
tcx.dcx().emit_fatal(diagnostics::TypeLengthLimit {
// We don't use `def_span(def_id)` so that diagnostics point
// to the crate root during mono instead of to foreign items.
// This is arguably better.
Expand Down
11 changes: 6 additions & 5 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,12 @@ impl<'tcx> SizeSkeleton<'tcx> {
Limit(0) => Limit(2),
limit => limit * 2,
};
let reported = tcx.dcx().emit_err(crate::error::RecursionLimitReachedSizeSkeleton {
span,
ty,
suggested_limit,
});
let reported =
tcx.dcx().emit_err(crate::diagnostics::RecursionLimitReachedSizeSkeleton {
span,
ty,
suggested_limit,
});
return Err(tcx.arena.alloc(LayoutError::ReferencesError(reported)));
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub use self::typeck_results::{
Rust2024IncompatiblePatInfo, SplattedDef, TypeckResults, UserType, UserTypeAnnotationIndex,
UserTypeKind,
};
use crate::error::{OpaqueHiddenTypeMismatch, TypeMismatchReason};
use crate::diagnostics::{OpaqueHiddenTypeMismatch, TypeMismatchReason};
use crate::metadata::{AmbigModChild, ModChild};
use crate::middle::privacy::EffectiveVisibilities;
use crate::mir::{Body, CoroutineLayout, CoroutineSavedLocal, MirPhase, SourceInfo};
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc_span::Span;
use rustc_span::def_id::DefId;
use tracing::{debug, instrument, trace};

use crate::error::ConstNotUsedTraitAlias;
use crate::diagnostics::ConstNotUsedTraitAlias;
use crate::ty::{
self, GenericArg, GenericArgKind, RegionExt, Ty, TyCtxt, TypeFoldable, TypeFolder,
TypeSuperFoldable,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl<'tcx> TyCtxt<'tcx> {
Limit(0) => Limit(2),
limit => limit * 2,
};
let reported = self.dcx().emit_err(crate::error::RecursionLimitReached {
let reported = self.dcx().emit_err(crate::diagnostics::RecursionLimitReached {
span: cause.span,
ty,
suggested_limit,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/verify_ich.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn incremental_verify_ich_failed<'tcx>(
let old_in_panic = INSIDE_VERIFY_PANIC.replace(true);

if old_in_panic {
tcx.dcx().emit_err(crate::error::Reentrant);
tcx.dcx().emit_err(crate::diagnostics::Reentrant);
} else {
let run_cmd = if was_invoked_from_cargo() {
format!("run `cargo clean -p {}` or `cargo clean`", tcx.crate_name(LOCAL_CRATE))
Expand All @@ -75,7 +75,7 @@ fn incremental_verify_ich_failed<'tcx>(
};

let dep_node = tcx.dep_graph.data().unwrap().prev_node_of(prev_index);
tcx.dcx().emit_err(crate::error::IncrementCompilation {
tcx.dcx().emit_err(crate::diagnostics::IncrementCompilation {
run_cmd,
dep_node: format!("{dep_node:?}"),
});
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/eii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::iter;
use rustc_data_structures::fx::FxIndexMap;
use rustc_hir::attrs::{EiiDecl, EiiImpl};
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc_middle::error::DuplicateEiiImpls;
use rustc_middle::diagnostics::DuplicateEiiImpls;
use rustc_middle::ty::TyCtxt;
use rustc_session::config::CrateType;

Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_query_impl/src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ pub(crate) fn create_cycle_error<'tcx>(

let mut cycle_stack = Vec::new();

use crate::error::StackCount;
use crate::diagnostics::StackCount;
let stack_bottom = frames[0].tagged_key.catch_description(tcx);
let stack_count = if frames.len() == 1 {
StackCount::Single { stack_bottom: stack_bottom.clone() }
Expand All @@ -433,7 +433,7 @@ pub(crate) fn create_cycle_error<'tcx>(
for i in 1..frames.len() {
let frame = &frames[i];
let span = frame.tagged_key.catch_default_span(tcx, frames[(i + 1) % frames.len()].span);
cycle_stack.push(crate::error::CycleStack {
cycle_stack.push(crate::diagnostics::CycleStack {
span: if span == prev { DUMMY_SP } else { span },
desc: frame.tagged_key.catch_description(tcx),
});
Expand All @@ -442,7 +442,7 @@ pub(crate) fn create_cycle_error<'tcx>(

let cycle_usage = usage.as_ref().map(|usage| {
let cycle_span = usage.tagged_key.catch_default_span(tcx, usage.span);
crate::error::CycleUsage {
crate::diagnostics::CycleUsage {
span: if cycle_span != span { cycle_span } else { DUMMY_SP },
usage: usage.tagged_key.catch_description(tcx),
}
Expand All @@ -464,9 +464,9 @@ pub(crate) fn create_cycle_error<'tcx>(

let alias = if !nested {
if is_all_def_kind(DefKind::TyAlias) {
Some(crate::error::Alias::Ty)
Some(crate::diagnostics::Alias::Ty)
} else if is_all_def_kind(DefKind::TraitAlias) {
Some(crate::error::Alias::Trait)
Some(crate::diagnostics::Alias::Trait)
} else {
None
}
Expand All @@ -475,16 +475,16 @@ pub(crate) fn create_cycle_error<'tcx>(
};

if nested {
tcx.sess.dcx().create_err(crate::error::NestedCycle {
tcx.sess.dcx().create_err(crate::diagnostics::NestedCycle {
span,
cycle_stack,
stack_bottom: crate::error::NestedCycleBottom { stack_bottom },
stack_bottom: crate::diagnostics::NestedCycleBottom { stack_bottom },
cycle_usage,
stack_count,
note_span: (),
})
} else {
tcx.sess.dcx().create_err(crate::error::Cycle {
tcx.sess.dcx().create_err(crate::diagnostics::Cycle {
span,
cycle_stack,
stack_bottom,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_query_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub use crate::execution::{CollectActiveJobsKind, collect_active_query_jobs};
pub use crate::job::{QueryJobMap, break_query_cycle, print_query_stack};

mod dep_kind_vtables;
mod error;
mod diagnostics;
mod execution;
mod handle_cycle_error;
mod job;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_query_impl/src/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use rustc_middle::verify_ich::incremental_verify_ich;
use rustc_serialize::{Decodable, Encodable};
use rustc_span::def_id::LOCAL_CRATE;

use crate::error::{QueryOverflow, QueryOverflowNote};
use crate::diagnostics::{QueryOverflow, QueryOverflowNote};
use crate::execution::{all_inactive, should_verify_loaded_value};
use crate::job::find_dep_kind_root;
use crate::query_impl::for_each_query_vtable;
Expand Down
Loading