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_borrowck/src/diagnostics/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use rustc_middle::ty::{
Unnormalized,
};
use rustc_span::Span;
use rustc_trait_selection::diagnostics::impl_trait_overcapture_suggestion;
use rustc_trait_selection::error_reporting::infer::region::unexpected_hidden_region_diagnostic;
use rustc_trait_selection::errors::impl_trait_overcapture_suggestion;

use crate::MirBorrowckCtxt;
use crate::borrow_set::BorrowData;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/impl_trait_overcaptures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use rustc_middle::{bug, span_bug};
use rustc_session::lint::fcw;
use rustc_session::{declare_lint, declare_lint_pass};
use rustc_span::{Span, Symbol};
use rustc_trait_selection::errors::{
use rustc_trait_selection::diagnostics::{
AddPreciseCapturingForOvercapture, impl_trait_overcapture_suggestion,
};
use rustc_trait_selection::regions::OutlivesEnvironmentBuildExt;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/check_call_recursion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_middle::ty::{self, GenericArg, GenericArgs, Instance, Ty, TyCtxt, Unno
use rustc_session::lint::builtin::UNCONDITIONAL_RECURSION;
use rustc_span::Span;

use crate::errors::UnconditionalRecursion;
use crate::diagnostics::UnconditionalRecursion;
use crate::pass_manager::MirLint;

pub(super) struct CheckCallRecursion;
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir_transform/src/check_const_item_mutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_session::lint::builtin::CONST_ITEM_MUTATION;
use rustc_span::Span;
use rustc_span::def_id::DefId;

use crate::errors;
use crate::diagnostics;

pub(super) struct CheckConstItemMutation;

Expand Down Expand Up @@ -108,7 +108,7 @@ impl<'tcx> Visitor<'tcx> for ConstMutationChecker<'_, 'tcx> {
CONST_ITEM_MUTATION,
lint_root,
span,
errors::ConstMutate::Modify { konst: item },
diagnostics::ConstMutate::Modify { konst: item },
);
}

Expand Down Expand Up @@ -154,7 +154,7 @@ impl<'tcx> Visitor<'tcx> for ConstMutationChecker<'_, 'tcx> {
CONST_ITEM_MUTATION,
lint_root,
span,
errors::ConstMutate::MutBorrow { method_call, konst: item },
diagnostics::ConstMutate::MutBorrow { method_call, konst: item },
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/check_inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl<'tcx> MirLint<'tcx> for CheckForceInline {
if let Err(reason) =
is_inline_valid_on_fn(tcx, def_id).and_then(|_| is_inline_valid_on_body(tcx, body))
{
tcx.dcx().emit_err(crate::errors::InvalidForceInline {
tcx.dcx().emit_err(crate::diagnostics::InvalidForceInline {
attr_span,
callee_span: tcx.def_span(def_id),
callee: tcx.def_path_str(def_id),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_transform/src/check_packed_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc_middle::mir::*;
use rustc_middle::span_bug;
use rustc_middle::ty::{self, TyCtxt};

use crate::{errors, util};
use crate::{diagnostics, util};

pub(super) struct CheckPackedRef;

Expand Down Expand Up @@ -50,7 +50,7 @@ impl<'tcx> Visitor<'tcx> for PackedRefChecker<'_, 'tcx> {
// shouldn't do.
span_bug!(self.source_info.span, "builtin derive created an unaligned reference");
} else {
self.tcx.dcx().emit_err(errors::UnalignedPackedRef {
self.tcx.dcx().emit_err(diagnostics::UnalignedPackedRef {
span: self.source_info.span,
ty_descr: adt.descr(),
align: pack.bytes(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/coroutine/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use rustc_trait_selection::infer::TyCtxtInferExt as _;
use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode, ObligationCtxt};
use tracing::{debug, instrument, trace};

use crate::errors::{MustNotSupend, MustNotSuspendReason};
use crate::diagnostics::{MustNotSupend, MustNotSuspendReason};

const SELF_ARG: Local = Local::arg(0);

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir_transform/src/ffi_unwind_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_session::lint::builtin::FFI_UNWIND_CALLS;
use rustc_target::spec::PanicStrategy;
use tracing::debug;

use crate::errors;
use crate::diagnostics;

// Check if the body of this def_id can possibly leak a foreign unwind into Rust code.
fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool {
Expand Down Expand Up @@ -67,7 +67,7 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool {
FFI_UNWIND_CALLS,
lint_root,
span,
errors::AsmUnwindCall { span },
diagnostics::AsmUnwindCall { span },
);

tainted = true;
Expand Down Expand Up @@ -119,7 +119,7 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool {
FFI_UNWIND_CALLS,
lint_root,
span,
errors::FfiUnwindCall { span, foreign },
diagnostics::FfiUnwindCall { span, foreign },
);

tainted = true;
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_transform/src/function_item_references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_middle::ty::{self, EarlyBinder, GenericArgsRef, Ty, TyCtxt};
use rustc_session::lint::builtin::FUNCTION_ITEM_REFERENCES;
use rustc_span::{Span, Spanned, sym};

use crate::errors;
use crate::diagnostics;

pub(super) struct FunctionItemReferences;

Expand Down Expand Up @@ -179,7 +179,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> {
FUNCTION_ITEM_REFERENCES,
lint_root,
span,
errors::FnItemRef { span, sugg, ident },
diagnostics::FnItemRef { span, sugg, ident },
);
}
}
4 changes: 2 additions & 2 deletions compiler/rustc_mir_transform/src/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl<'tcx> Inliner<'tcx> for ForceInliner<'tcx> {

let call_span = callsite.source_info.span;
let callee = tcx.def_path_str(callsite.callee.def_id());
tcx.dcx().emit_err(crate::errors::ForceInlineFailure {
tcx.dcx().emit_err(crate::diagnostics::ForceInlineFailure {
call_span,
attr_span,
caller_span: tcx.def_span(self.def_id),
Expand All @@ -262,7 +262,7 @@ impl<'tcx> Inliner<'tcx> for ForceInliner<'tcx> {
callee: callee.clone(),
reason,
justification: justification
.map(|sym| crate::errors::ForceInlineJustification { sym, callee }),
.map(|sym| crate::diagnostics::ForceInlineJustification { sym, callee }),
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/known_panics_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use rustc_middle::ty::{self, ConstInt, ScalarInt, Ty, TyCtxt, TypeVisitableExt,
use rustc_span::Span;
use tracing::{debug, instrument, trace};

use crate::errors::{AssertLint, AssertLintKind};
use crate::diagnostics::{AssertLint, AssertLintKind};

pub(super) struct KnownPanicsLint;

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ mod check_pointers;
mod cost_checker;
mod cross_crate_inline;
mod deduce_param_attrs;
mod diagnostics;
mod elaborate_drop;
mod errors;
mod ffi_unwind_calls;
mod lint;
mod lint_tail_expr_drop_order;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc_middle::mir::*;
use rustc_middle::ty::TyCtxt;
use rustc_session::lint::builtin::UNREACHABLE_CODE;

use crate::errors::UnreachableDueToUninhabited;
use crate::diagnostics::UnreachableDueToUninhabited;

/// Lint unreachable code due to uninhabited values from function calls,
/// and remove return edges from those calls.
Expand Down
40 changes: 20 additions & 20 deletions compiler/rustc_mir_transform/src/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use rustc_span::Span;
use rustc_span::edit_distance::find_best_match_for_name;
use rustc_span::symbol::{Symbol, kw, sym};

use crate::errors;
use crate::diagnostics;

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
enum AccessKind {
Expand Down Expand Up @@ -175,7 +175,7 @@ fn maybe_suggest_unit_pattern_typo<'tcx>(
name: Symbol,
span: Span,
ty: Ty<'tcx>,
) -> Option<errors::PatternTypo> {
) -> Option<diagnostics::PatternTypo> {
if let ty::Adt(adt_def, _) = ty.peel_refs().kind() {
let variant_names: Vec<_> = adt_def
.variants()
Expand All @@ -189,7 +189,7 @@ fn maybe_suggest_unit_pattern_typo<'tcx>(
.iter()
.find(|v| v.name == name && matches!(v.ctor, Some((CtorKind::Const, _))))
{
return Some(errors::PatternTypo {
return Some(diagnostics::PatternTypo {
span,
code: with_no_trimmed_paths!(tcx.def_path_str(variant.def_id)),
kind: tcx.def_descr(variant.def_id),
Expand All @@ -213,7 +213,7 @@ fn maybe_suggest_unit_pattern_typo<'tcx>(
&& let Some(position) = names.iter().position(|&n| n == item_name)
&& let Some(&def_id) = constants.get(position)
{
return Some(errors::PatternTypo {
return Some(diagnostics::PatternTypo {
span,
code: with_no_trimmed_paths!(tcx.def_path_str(def_id)),
kind: "constant",
Expand Down Expand Up @@ -275,7 +275,7 @@ fn annotate_mut_binding_to_immutable_binding<'tcx>(
body_def_id: LocalDefId,
assignment_span: Span,
body: &Body<'tcx>,
) -> Option<errors::UnusedAssignSuggestion> {
) -> Option<diagnostics::UnusedAssignSuggestion> {
use rustc_hir as hir;
use rustc_hir::intravisit::{self, Visitor};

Expand Down Expand Up @@ -316,7 +316,7 @@ fn annotate_mut_binding_to_immutable_binding<'tcx>(
Some(mut_ty.ty.span.shrink_to_lo())
};

return Some(errors::UnusedAssignSuggestion {
return Some(diagnostics::UnusedAssignSuggestion {
ty_span,
pre,
// Span of the `mut` before the binding.
Expand Down Expand Up @@ -939,7 +939,7 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> {
.split(&brace_name)
.any(|c| matches!(c.chars().next(), Some('}' | ':')))
})
.map(|&(lit, _)| errors::UnusedVariableStringInterp { lit })
.map(|&(lit, _)| diagnostics::UnusedVariableStringInterp { lit })
.collect::<Vec<_>>()
};

Expand Down Expand Up @@ -997,16 +997,16 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> {
}

let sugg = if from_macro {
errors::UnusedVariableSugg::NoSugg { span: def_span, name }
diagnostics::UnusedVariableSugg::NoSugg { span: def_span, name }
} else {
let typo = maybe_suggest_typo();
errors::UnusedVariableSugg::TryPrefix { spans: vec![def_span], name, typo }
diagnostics::UnusedVariableSugg::TryPrefix { spans: vec![def_span], name, typo }
};
tcx.emit_node_span_lint(
lint::builtin::UNUSED_VARIABLES,
hir_id,
def_span,
errors::UnusedVariable {
diagnostics::UnusedVariable {
name,
string_interp: maybe_suggest_literal_matching_name(name),
sugg,
Expand Down Expand Up @@ -1056,7 +1056,7 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> {
lint::builtin::UNUSED_VARIABLES,
hir_id,
def_span,
errors::UnusedVarAssignedOnly { name, typo },
diagnostics::UnusedVarAssignedOnly { name, typo },
);
continue;
}
Expand All @@ -1067,7 +1067,7 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> {
let any_shorthand = introductions.iter().any(|intro| intro.is_shorthand);

let sugg = if any_shorthand {
errors::UnusedVariableSugg::TryIgnore {
diagnostics::UnusedVariableSugg::TryIgnore {
name: name.to_ident_string(),
shorthands: introductions
.iter()
Expand All @@ -1085,20 +1085,20 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> {
.collect(),
}
} else if from_macro {
errors::UnusedVariableSugg::NoSugg { span: def_span, name }
diagnostics::UnusedVariableSugg::NoSugg { span: def_span, name }
} else if !introductions.is_empty() {
let typo = maybe_suggest_typo();
errors::UnusedVariableSugg::TryPrefix { name, typo, spans: spans.clone() }
diagnostics::UnusedVariableSugg::TryPrefix { name, typo, spans: spans.clone() }
} else {
let typo = maybe_suggest_typo();
errors::UnusedVariableSugg::TryPrefix { name, typo, spans: vec![def_span] }
diagnostics::UnusedVariableSugg::TryPrefix { name, typo, spans: vec![def_span] }
};

tcx.emit_node_span_lint(
lint::builtin::UNUSED_VARIABLES,
hir_id,
spans,
errors::UnusedVariable {
diagnostics::UnusedVariable {
name,
string_interp: maybe_suggest_literal_matching_name(name),
sugg,
Expand Down Expand Up @@ -1147,7 +1147,7 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> {
.rfind(|(_, overwrite_location)| {
location.is_predecessor_of(*overwrite_location, self.body)
})
.map(|&(overwrite_span, _)| errors::UnusedAssignOverwrite {
.map(|&(overwrite_span, _)| diagnostics::UnusedAssignOverwrite {
assigned_span: source_info.span,
overwrite_span,
name,
Expand Down Expand Up @@ -1190,20 +1190,20 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> {
lint::builtin::UNUSED_ASSIGNMENTS,
hir_id,
source_info.span,
errors::UnusedAssign { name, overwrite, help, suggestion },
diagnostics::UnusedAssign { name, overwrite, help, suggestion },
)
}
AccessKind::Param => tcx.emit_node_span_lint(
lint::builtin::UNUSED_ASSIGNMENTS,
hir_id,
source_info.span,
errors::UnusedAssignPassed { name },
diagnostics::UnusedAssignPassed { name },
),
AccessKind::Capture => tcx.emit_node_span_lint(
lint::builtin::UNUSED_ASSIGNMENTS,
hir_id,
decl_span,
errors::UnusedCaptureMaybeCaptureRef { name },
diagnostics::UnusedCaptureMaybeCaptureRef { name },
),
}
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir_transform/src/pass_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_session::Session;
use tracing::trace;

use crate::lint::lint_body;
use crate::{errors, validate};
use crate::{diagnostics, validate};

thread_local! {
/// Maps MIR pass names to a snake case form to match profiling naming style
Expand Down Expand Up @@ -255,14 +255,14 @@ fn run_passes_inner<'tcx>(

let mut unknown_found = false;
for &name in named_passes.difference(&*crate::PASS_NAMES) {
tcx.dcx().emit_warn(errors::UnknownPassName { name });
tcx.dcx().emit_warn(diagnostics::UnknownPassName { name });
unknown_found = true;
}

if unknown_found {
let mut valid_pass_names = crate::PASS_NAMES.iter().copied().collect::<Vec<_>>();
valid_pass_names.sort();
tcx.dcx().emit_note(errors::ValidPassNames { valid_passes: valid_pass_names.into() });
tcx.dcx().emit_note(diagnostics::ValidPassNames { valid_passes: valid_pass_names.into() });
}

// Verify that no passes are missing from the `declare_passes` invocation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ use rustc_middle::ty::{
use rustc_span::{BytePos, DUMMY_SP, DesugaringKind, Pos, Span, sym};
use tracing::{debug, instrument};

use crate::diagnostics::{ObligationCauseFailureCode, TypeErrorAdditionalDiags};
use crate::error_reporting::TypeErrCtxt;
use crate::error_reporting::traits::ambiguity::{
CandidateSource, compute_applicable_impls_for_diagnostics,
};
use crate::errors::{ObligationCauseFailureCode, TypeErrorAdditionalDiags};
use crate::infer;
use crate::infer::relate::{self, RelateResult, TypeRelation};
use crate::infer::{InferCtxt, InferCtxtExt as _, TypeTrace, ValuePairs};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ use rustc_span::{BytePos, DUMMY_SP, Ident, Span, sym};
use tracing::{debug, instrument, warn};

use super::nice_region_error::placeholder_error::Highlighted;
use crate::error_reporting::TypeErrCtxt;
use crate::errors::{
use crate::diagnostics::{
AmbiguousImpl, AmbiguousReturn, AnnotationRequired, InferenceBadError,
SourceKindMultiSuggestion, SourceKindSubdiag,
};
use crate::error_reporting::TypeErrCtxt;
use crate::infer::{InferCtxt, TyOrConstInferVar};

pub enum TypeAnnotationNeeded {
Expand Down
Loading
Loading