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,7 +1,7 @@
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use crate::infer::InferCtxt;
use crate::traits::{Obligation, ObligationCause, ObligationCtxt};
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder};
use rustc_errors::{pluralize, struct_span_code_err, Applicability, DiagnosticBuilder};
use rustc_hir as hir;
use rustc_hir::Node;
use rustc_middle::ty::{self, Ty};
@ -140,7 +140,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
let expected_str = args_str(&expected_args, &found_args);
let found_str = args_str(&found_args, &expected_args);
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
self.dcx(),
span,
E0593,

View file

@ -6,7 +6,7 @@ use rustc_ast::AttrKind;
use rustc_ast::{Attribute, MetaItem, NestedMetaItem};
use rustc_attr as attr;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{struct_span_err, ErrorGuaranteed};
use rustc_errors::{struct_span_code_err, ErrorGuaranteed};
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::ty::GenericArgsRef;
@ -797,7 +797,7 @@ impl<'tcx> OnUnimplementedFormatString {
},
);
} else {
result = Err(struct_span_err!(
result = Err(struct_span_code_err!(
tcx.dcx(),
self.span,
E0230,
@ -816,7 +816,7 @@ impl<'tcx> OnUnimplementedFormatString {
}
// `{:1}` and `{}` are not to be used
Position::ArgumentIs(..) | Position::ArgumentImplicitlyIs(_) => {
let reported = struct_span_err!(
let reported = struct_span_code_err!(
tcx.dcx(),
self.span,
E0231,

View file

@ -13,7 +13,7 @@ use hir::def::CtorOf;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::{
error_code, pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder,
error_code, pluralize, struct_span_code_err, Applicability, Diagnostic, DiagnosticBuilder,
MultiSpan, Style, SuggestionStyle,
};
use rustc_hir as hir;
@ -2145,7 +2145,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
ty::Coroutine(..) => "coroutine",
_ => "function",
};
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
self.dcx(),
span,
E0631,

View file

@ -19,7 +19,7 @@ use crate::traits::{
};
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_errors::{
pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
pluralize, struct_span_code_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
MultiSpan, StashKey, Style,
};
use rustc_hir as hir;
@ -280,7 +280,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
predicate.print(&mut cx).unwrap();
pred_str = cx.into_buffer();
}
let mut err = struct_span_err!(
let mut err = struct_span_code_err!(
self.dcx(),
span,
E0275,
@ -525,7 +525,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
(err_msg, None)
};
let mut err = struct_span_err!(self.dcx(), span, E0277, "{}", err_msg);
let mut err = struct_span_code_err!(self.dcx(), span, E0277, "{}", err_msg);
let mut suggested = false;
if is_try_conversion {
@ -1236,7 +1236,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
span_bug!(span, "const param tys cannot mention other generic parameters");
}
ty::Float(_) => {
struct_span_err!(
struct_span_code_err!(
self.dcx(),
span,
E0741,
@ -1244,7 +1244,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
)
}
ty::FnPtr(_) => {
struct_span_err!(
struct_span_code_err!(
self.dcx(),
span,
E0741,
@ -1252,7 +1252,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
)
}
ty::RawPtr(_) => {
struct_span_err!(
struct_span_code_err!(
self.dcx(),
span,
E0741,
@ -1261,7 +1261,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
}
ty::Adt(def, _) => {
// We should probably see if we're *allowed* to derive `ConstParamTy` on the type...
let mut diag = struct_span_err!(
let mut diag = struct_span_code_err!(
self.dcx(),
span,
E0741,
@ -1293,7 +1293,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
diag
}
_ => {
struct_span_err!(
struct_span_code_err!(
self.dcx(),
span,
E0741,
@ -1731,7 +1731,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
cx.into_buffer()
}))
});
let mut diag = struct_span_err!(self.dcx(), obligation.cause.span, E0271, "{msg}");
let mut diag = struct_span_code_err!(self.dcx(), obligation.cause.span, E0271, "{msg}");
let secondary_span = (|| {
let ty::PredicateKind::Clause(ty::ClauseKind::Projection(proj)) =
@ -2421,7 +2421,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
true,
)
} else {
struct_span_err!(
struct_span_code_err!(
self.dcx(),
span,
E0283,
@ -2664,7 +2664,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
.note_mv(format!("cannot satisfy `{predicate}`"))
} else {
// If we can't find a substitution, just print a generic error
struct_span_err!(
struct_span_code_err!(
self.dcx(),
span,
E0284,
@ -2691,7 +2691,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
err
} else {
// If we can't find a substitution, just print a generic error
struct_span_err!(
struct_span_code_err!(
self.dcx(),
span,
E0284,
@ -2705,7 +2705,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
if self.dcx().has_errors().is_some() || self.tainted_by_errors().is_some() {
return;
}
struct_span_err!(
struct_span_code_err!(
self.dcx(),
span,
E0284,