1
Fork 0

Rename struct_span_err! as struct_span_code_err!.

Because it takes an error code after the span. This avoids the confusing
overlap with the `DiagCtxt::struct_span_err` method, which doesn't take
an error code.
This commit is contained in:
Nicholas Nethercote 2024-01-04 09:08:36 +11:00
parent 99b1b0f85c
commit 4864cb8aef
46 changed files with 277 additions and 224 deletions

View file

@ -1,5 +1,5 @@
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::struct_span_err;
use rustc_errors::struct_span_code_err;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{DefId, LocalDefId};
@ -462,7 +462,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
late_bound_in_trait_ref,
late_bound_in_ty,
|br_name| {
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
binding.span,
E0582,

View file

@ -7,7 +7,7 @@ use crate::fluent_generated as fluent;
use crate::traits::error_reporting::report_object_safety_error;
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
use rustc_data_structures::unord::UnordMap;
use rustc_errors::{pluralize, struct_span_err, Applicability, Diagnostic, ErrorGuaranteed};
use rustc_errors::{pluralize, struct_span_code_err, Applicability, Diagnostic, ErrorGuaranteed};
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_infer::traits::FulfillmentError;
@ -346,7 +346,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
candidates: Vec<DefId>,
span: Span,
) -> ErrorGuaranteed {
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
self.tcx().dcx(),
name.span,
E0034,
@ -445,7 +445,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
String::new()
};
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
tcx.dcx(),
name.span,
E0220,
@ -697,7 +697,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let names = names.join(", ");
trait_bound_spans.sort();
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
tcx.dcx(),
trait_bound_spans,
E0191,

View file

@ -5,7 +5,7 @@ use crate::astconv::{
};
use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs};
use rustc_ast::ast::ParamKindOrd;
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed, MultiSpan};
use rustc_errors::{struct_span_code_err, Applicability, Diagnostic, ErrorGuaranteed, MultiSpan};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId;
@ -27,7 +27,7 @@ fn generic_arg_mismatch_err(
help: Option<String>,
) -> ErrorGuaranteed {
let sess = tcx.sess;
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
tcx.dcx(),
arg.span(),
E0747,
@ -650,7 +650,7 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes(
if position == GenericArgPosition::Value
&& args.num_lifetime_params() != param_counts.lifetimes
{
struct_span_err!(tcx.dcx(), span, E0794, "{}", msg)
struct_span_code_err!(tcx.dcx(), span, E0794, "{}", msg)
.span_note_mv(span_late, note)
.emit();
} else {

View file

@ -213,7 +213,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let msg = "trait objects must include the `dyn` keyword";
let label = "add `dyn` keyword before this trait";
let mut diag =
rustc_errors::struct_span_err!(tcx.dcx(), self_ty.span, E0782, "{}", msg);
rustc_errors::struct_span_code_err!(tcx.dcx(), self_ty.span, E0782, "{}", msg);
if self_ty.span.can_be_used_for_suggestions()
&& !self.maybe_lint_impl_trait(self_ty, &mut diag)
{

View file

@ -18,8 +18,8 @@ use crate::require_c_abi_if_c_variadic;
use rustc_ast::TraitObjectSyntax;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::{
error_code, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
FatalError, MultiSpan,
error_code, struct_span_code_err, Applicability, Diagnostic, DiagnosticBuilder,
ErrorGuaranteed, FatalError, MultiSpan,
};
use rustc_hir as hir;
use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
@ -866,7 +866,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
traits: &[String],
name: Symbol,
) -> ErrorGuaranteed {
let mut err = struct_span_err!(self.tcx().dcx(), span, E0223, "ambiguous associated type");
let mut err =
struct_span_code_err!(self.tcx().dcx(), span, E0223, "ambiguous associated type");
if self
.tcx()
.resolutions(())
@ -1313,7 +1314,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let msg = format!("expected type, found variant `{assoc_ident}`");
tcx.dcx().span_err(span, msg)
} else if qself_ty.is_enum() {
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
tcx.dcx(),
assoc_ident.span,
E0599,
@ -1354,7 +1355,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
reported
} else if let ty::Alias(ty::Opaque, alias_ty) = qself_ty.kind() {
// `<impl Trait as OtherTrait>::Assoc` makes no sense.
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
tcx.def_span(alias_ty.def_id),
E0667,
@ -1850,7 +1851,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
};
let last_span = *arg_spans.last().unwrap();
let span: MultiSpan = arg_spans.into();
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
self.tcx().dcx(),
span,
E0109,
@ -2601,7 +2602,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let late_bound_in_ret = tcx.collect_referenced_late_bound_regions(&output);
self.validate_late_bound_regions(late_bound_in_args, late_bound_in_ret, |br_name| {
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
decl.output.span(),
E0581,

View file

@ -2,7 +2,7 @@ use crate::astconv::{GenericArgCountMismatch, GenericArgCountResult, OnlySelfBou
use crate::bounds::Bounds;
use crate::errors::TraitObjectDeclaredWithNoTraits;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
use rustc_errors::struct_span_err;
use rustc_errors::struct_span_code_err;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId;
@ -89,7 +89,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
if regular_traits.len() > 1 {
let first_trait = &regular_traits[0];
let additional_trait = &regular_traits[1];
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
tcx.dcx(),
additional_trait.bottom().1,
E0225,
@ -290,7 +290,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
if references_self {
let def_id = i.bottom().0.def_id();
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
i.bottom().1,
E0038,
@ -375,7 +375,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
self.ast_region_to_region(lifetime, None)
} else {
self.re_infer(None, span).unwrap_or_else(|| {
let err = struct_span_err!(
let err = struct_span_code_err!(
tcx.dcx(),
span,
E0228,

View file

@ -37,7 +37,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) {
match tcx.sess.target.is_abi_supported(abi) {
Some(true) => (),
Some(false) => {
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
span,
E0570,
@ -58,7 +58,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) {
// This ABI is only allowed on function pointers
if abi == Abi::CCmseNonSecureCall {
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
span,
E0781,
@ -560,7 +560,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
(0, _) => ("const", "consts", None),
_ => ("type or const", "types or consts", None),
};
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
item.span,
E0044,
@ -687,7 +687,7 @@ fn check_impl_items_against_trait<'tcx>(
ty::ImplPolarity::Negative => {
if let [first_item_ref, ..] = impl_item_refs {
let first_item_span = tcx.def_span(first_item_ref);
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
first_item_span,
E0749,
@ -840,12 +840,12 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
{
let fields = &def.non_enum_variant().fields;
if fields.is_empty() {
struct_span_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit();
struct_span_code_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit();
return;
}
let e = fields[FieldIdx::from_u32(0)].ty(tcx, args);
if !fields.iter().all(|f| f.ty(tcx, args) == e) {
struct_span_err!(tcx.dcx(), sp, E0076, "SIMD vector should be homogeneous")
struct_span_code_err!(tcx.dcx(), sp, E0076, "SIMD vector should be homogeneous")
.span_label_mv(sp, "SIMD elements must have the same type")
.emit();
return;
@ -858,10 +858,10 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
};
if let Some(len) = len {
if len == 0 {
struct_span_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit();
struct_span_code_err!(tcx.dcx(), sp, E0075, "SIMD vector cannot be empty").emit();
return;
} else if len > MAX_SIMD_LANES {
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
sp,
E0075,
@ -884,7 +884,7 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) {
if matches!(t.kind(), ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::RawPtr(_)) =>
{ /* struct([f32; 4]) is ok */ }
_ => {
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
sp,
E0077,
@ -907,7 +907,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
&& let Some(repr_pack) = repr.pack
&& pack as u64 != repr_pack.bytes()
{
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
sp,
E0634,
@ -918,7 +918,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
}
}
if repr.align.is_some() {
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
sp,
E0587,
@ -927,7 +927,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
.emit();
} else {
if let Some(def_spans) = check_packed_inner(tcx, def.did(), &mut vec![]) {
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
tcx.dcx(),
sp,
E0588,
@ -1117,7 +1117,7 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
if def.variants().is_empty() {
if let Some(attr) = tcx.get_attrs(def_id, sym::repr).next() {
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
attr.span,
E0084,
@ -1156,7 +1156,7 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
let disr_non_unit = def.variants().iter().any(|var| !is_unit(var) && has_disr(var));
if disr_non_unit || (disr_units && has_non_units) {
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
tcx.def_span(def_id),
E0732,
@ -1242,7 +1242,7 @@ fn detect_discriminant_duplicate<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
if discrs[i].1.val == discrs[o].1.val {
let err = error.get_or_insert_with(|| {
let mut ret = struct_span_err!(
let mut ret = struct_span_code_err!(
tcx.dcx(),
tcx.def_span(adt.did()),
E0081,
@ -1309,9 +1309,15 @@ pub(super) fn check_type_params_are_used<'tcx>(
&& let ty::GenericParamDefKind::Type { .. } = param.kind
{
let span = tcx.def_span(param.def_id);
struct_span_err!(tcx.dcx(), span, E0091, "type parameter `{}` is unused", param.name,)
.span_label_mv(span, "unused type parameter")
.emit();
struct_span_code_err!(
tcx.dcx(),
span,
E0091,
"type parameter `{}` is unused",
param.name,
)
.span_label_mv(span, "unused type parameter")
.emit();
}
}
}
@ -1329,7 +1335,7 @@ fn opaque_type_cycle_error(
opaque_def_id: LocalDefId,
span: Span,
) -> ErrorGuaranteed {
let mut err = struct_span_err!(tcx.dcx(), span, E0720, "cannot resolve opaque type");
let mut err = struct_span_code_err!(tcx.dcx(), span, E0720, "cannot resolve opaque type");
let mut label = false;
if let Some((def_id, visitor)) = get_owner_return_paths(tcx, opaque_def_id) {

View file

@ -2,7 +2,7 @@ use super::potentially_plural_count;
use crate::errors::LifetimesOrBoundsMismatchOnTrait;
use hir::def_id::{DefId, DefIdMap, LocalDefId};
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticId, ErrorGuaranteed};
use rustc_errors::{pluralize, struct_span_code_err, Applicability, DiagnosticId, ErrorGuaranteed};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::intravisit;
@ -625,7 +625,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
match ocx.eq(&cause, param_env, trait_return_ty, impl_return_ty) {
Ok(()) => {}
Err(terr) => {
let mut diag = struct_span_err!(
let mut diag = struct_span_code_err!(
tcx.dcx(),
cause.span(),
E0053,
@ -972,7 +972,7 @@ fn report_trait_method_mismatch<'tcx>(
let (impl_err_span, trait_err_span) =
extract_spans_for_error_reporting(infcx, terr, &cause, impl_m, trait_m);
let mut diag = struct_span_err!(
let mut diag = struct_span_code_err!(
tcx.dcx(),
impl_err_span,
E0053,
@ -1217,7 +1217,7 @@ fn compare_self_type<'tcx>(
(false, true) => {
let self_descr = self_string(impl_m);
let impl_m_span = tcx.def_span(impl_m.def_id);
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
tcx.dcx(),
impl_m_span,
E0185,
@ -1237,7 +1237,7 @@ fn compare_self_type<'tcx>(
(true, false) => {
let self_descr = self_string(trait_m);
let impl_m_span = tcx.def_span(impl_m.def_id);
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
tcx.dcx(),
impl_m_span,
E0186,
@ -1463,7 +1463,7 @@ fn compare_number_of_method_arguments<'tcx>(
})
.unwrap_or_else(|| tcx.def_span(impl_m.def_id));
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
tcx.dcx(),
impl_span,
E0050,
@ -1530,7 +1530,7 @@ fn compare_synthetic_generics<'tcx>(
let impl_def_id = impl_def_id.expect_local();
let impl_span = tcx.def_span(impl_def_id);
let trait_span = tcx.def_span(trait_def_id);
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
tcx.dcx(),
impl_span,
E0643,
@ -1689,7 +1689,7 @@ fn compare_generic_param_kinds<'tcx>(
let param_impl_span = tcx.def_span(param_impl.def_id);
let param_trait_span = tcx.def_span(param_trait.def_id);
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
tcx.dcx(),
param_impl_span,
E0053,
@ -1836,7 +1836,7 @@ fn compare_const_predicate_entailment<'tcx>(
let (ty, _) = tcx.hir().expect_impl_item(impl_ct_def_id).expect_const();
cause.span = ty.span;
let mut diag = struct_span_err!(
let mut diag = struct_span_code_err!(
tcx.dcx(),
cause.span,
E0326,

View file

@ -2,7 +2,7 @@
//
// We don't do any drop checking during hir typeck.
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{struct_span_err, ErrorGuaranteed};
use rustc_errors::{struct_span_code_err, ErrorGuaranteed};
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
use rustc_infer::infer::{RegionResolutionError, TyCtxtInferExt};
use rustc_middle::ty::util::CheckRegions;
@ -88,8 +88,12 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
let drop_impl_span = tcx.def_span(drop_impl_did);
let item_span = tcx.def_span(self_type_did);
let self_descr = tcx.def_descr(self_type_did);
let mut err =
struct_span_err!(tcx.dcx(), drop_impl_span, E0366, "`Drop` impls cannot be specialized");
let mut err = struct_span_code_err!(
tcx.dcx(),
drop_impl_span,
E0366,
"`Drop` impls cannot be specialized"
);
match arg {
ty::util::NotUniqueParam::DuplicateParam(arg) => {
err.note(format!("`{arg}` is mentioned multiple times"))
@ -154,7 +158,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
let item_span = tcx.def_span(adt_def_id);
let self_descr = tcx.def_descr(adt_def_id.to_def_id());
guar = Some(
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
error.root_obligation.cause.span,
E0367,
@ -186,7 +190,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
}
};
guar = Some(
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
error.origin().span(),
E0367,

View file

@ -8,7 +8,7 @@ use crate::errors::{
};
use hir::def_id::DefId;
use rustc_errors::{struct_span_err, DiagnosticMessage};
use rustc_errors::{struct_span_code_err, DiagnosticMessage};
use rustc_hir as hir;
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
use rustc_middle::ty::{self, Ty, TyCtxt};
@ -29,7 +29,7 @@ fn equate_intrinsic_type<'tcx>(
(own_counts, generics.span)
}
_ => {
struct_span_err!(tcx.dcx(), it.span, E0622, "intrinsic must be a function")
struct_span_code_err!(tcx.dcx(), it.span, E0622, "intrinsic must be a function")
.span_label_mv(it.span, "expected a function")
.emit();
return;

View file

@ -78,7 +78,7 @@ use std::num::NonZeroU32;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::ErrorGuaranteed;
use rustc_errors::{pluralize, struct_span_err, Diagnostic, DiagnosticBuilder};
use rustc_errors::{pluralize, struct_span_code_err, Diagnostic, DiagnosticBuilder};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::intravisit::Visitor;
use rustc_index::bit_set::BitSet;

View file

@ -3,7 +3,9 @@ use crate::constrained_generic_params::{identify_constrained_generic_params, Par
use rustc_ast as ast;
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed};
use rustc_errors::{
pluralize, struct_span_code_err, Applicability, DiagnosticBuilder, ErrorGuaranteed,
};
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId};
use rustc_hir::lang_items::LangItem;
@ -217,7 +219,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
if let hir::Defaultness::Default { .. } = impl_.defaultness {
let mut spans = vec![span];
spans.extend(impl_.defaultness_span);
res = Err(struct_span_err!(
res = Err(struct_span_code_err!(
tcx.dcx(),
spans,
E0750,
@ -1116,7 +1118,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) -> Result<(), ErrorGuarant
|| matches!(trait_def.specialization_kind, TraitSpecializationKind::Marker)
{
for associated_def_id in &*tcx.associated_item_def_ids(def_id) {
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
tcx.def_span(*associated_def_id),
E0714,
@ -1610,7 +1612,7 @@ fn check_method_receiver<'tcx>(
}
fn e0307(tcx: TyCtxt<'_>, span: Span, receiver_ty: Ty<'_>) -> ErrorGuaranteed {
struct_span_err!(tcx.dcx(), span, E0307, "invalid `self` parameter type: {receiver_ty}")
struct_span_code_err!(tcx.dcx(), span, E0307, "invalid `self` parameter type: {receiver_ty}")
.note_mv("type of `self` must be `Self` or a type that dereferences to it")
.help_mv(HELP_FOR_SELF_TYPE)
.emit()
@ -1920,7 +1922,7 @@ fn check_mod_type_wf(tcx: TyCtxt<'_>, module: LocalModDefId) -> Result<(), Error
}
fn error_392(tcx: TyCtxt<'_>, span: Span, param_name: Symbol) -> DiagnosticBuilder<'_> {
struct_span_err!(tcx.dcx(), span, E0392, "parameter `{param_name}` is never used")
struct_span_code_err!(tcx.dcx(), span, E0392, "parameter `{param_name}` is never used")
.span_label_mv(span, "unused parameter")
}

View file

@ -1,5 +1,5 @@
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::struct_span_err;
use rustc_errors::struct_span_code_err;
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
@ -70,7 +70,7 @@ impl<'tcx> InherentOverlapChecker<'tcx> {
match seen_items.entry(norm_ident) {
Entry::Occupied(entry) => {
let former = entry.get();
struct_span_err!(
struct_span_code_err!(
self.tcx.dcx(),
span,
E0592,
@ -104,7 +104,7 @@ impl<'tcx> InherentOverlapChecker<'tcx> {
if let Some(item2) = collision {
let name = item1.ident(self.tcx).normalize_to_macros_2_0();
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
self.tcx.dcx(),
self.tcx.def_span(item1.def_id),
E0592,

View file

@ -6,7 +6,7 @@
// mappings. That mapping code resides here.
use crate::errors;
use rustc_errors::{error_code, struct_span_err};
use rustc_errors::{error_code, struct_span_code_err};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::query::Providers;
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
@ -45,7 +45,7 @@ fn enforce_trait_manually_implementable(
// Disallow *all* explicit impls of traits marked `#[rustc_deny_explicit_impl]`
if tcx.trait_def(trait_def_id).deny_explicit_impl {
let trait_name = tcx.item_name(trait_def_id);
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
tcx.dcx(),
impl_header_span,
E0322,
@ -88,7 +88,7 @@ fn enforce_empty_impls_for_marker_traits(
return;
}
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
tcx.def_span(impl_def_id),
E0715,
@ -173,7 +173,7 @@ fn check_object_overlap<'tcx>(
let mut supertrait_def_ids = traits::supertrait_def_ids(tcx, component_def_id);
if supertrait_def_ids.any(|d| d == trait_def_id) {
let span = tcx.def_span(impl_def_id);
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
span,
E0371,

View file

@ -1,7 +1,7 @@
//! Unsafety checker: every impl either implements a trait defined in this
//! crate or pertains to a type defined in this crate.
use rustc_errors::struct_span_err;
use rustc_errors::struct_span_code_err;
use rustc_hir as hir;
use rustc_hir::Unsafety;
use rustc_middle::ty::TyCtxt;
@ -18,7 +18,7 @@ pub(super) fn check_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
impl_.generics.params.iter().find(|p| p.pure_wrt_drop).map(|_| "may_dangle");
match (trait_def.unsafety, unsafe_attr, impl_.unsafety, impl_.polarity) {
(Unsafety::Normal, None, Unsafety::Unsafe, hir::ImplPolarity::Positive) => {
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
tcx.def_span(def_id),
E0199,
@ -35,7 +35,7 @@ pub(super) fn check_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
}
(Unsafety::Unsafe, _, Unsafety::Normal, hir::ImplPolarity::Positive) => {
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
tcx.def_span(def_id),
E0200,
@ -58,7 +58,7 @@ pub(super) fn check_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
}
(Unsafety::Normal, Some(attr_name), Unsafety::Normal, hir::ImplPolarity::Positive) => {
struct_span_err!(
struct_span_code_err!(
tcx.dcx(),
tcx.def_span(def_id),
E0569,

View file

@ -8,7 +8,7 @@
use rustc_ast::walk_list;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
use rustc_errors::struct_span_err;
use rustc_errors::struct_span_code_err;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::LocalDefId;
@ -737,7 +737,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
// Ensure that the parent of the def is an item, not HRTB
let parent_id = self.tcx.hir().parent_id(hir_id);
if !parent_id.is_owner() {
struct_span_err!(
struct_span_code_err!(
self.tcx.dcx(),
lifetime.ident.span,
E0657,

View file

@ -12,7 +12,7 @@ use crate::constrained_generic_params as cgp;
use min_specialization::check_min_specialization;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::struct_span_err;
use rustc_errors::struct_span_code_err;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{LocalDefId, LocalModDefId};
use rustc_middle::query::Providers;
@ -170,7 +170,7 @@ fn enforce_impl_params_are_constrained(tcx: TyCtxt<'_>, impl_def_id: LocalDefId)
}
fn report_unused_parameter(tcx: TyCtxt<'_>, span: Span, kind: &str, name: Symbol) {
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
tcx.dcx(),
span,
E0207,