1
Fork 0

Remove all eight DiagnosticBuilder::*_with_code methods.

These all have relatively low use, and can be perfectly emulated with
a simpler construction method combined with `code` or `code_mv`.
This commit is contained in:
Nicholas Nethercote 2024-01-03 21:50:36 +11:00
parent bd4e623485
commit 6682f243dc
14 changed files with 84 additions and 180 deletions

View file

@ -1647,7 +1647,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let msg = format!("{kind} `{name}` is private");
let def_span = tcx.def_span(item);
tcx.dcx()
.struct_span_err_with_code(span, msg, rustc_errors::error_code!(E0624))
.struct_span_err(span, msg)
.code_mv(rustc_errors::error_code!(E0624))
.span_label_mv(span, format!("private {kind}"))
.span_label_mv(def_span, format!("{kind} defined here"))
.emit();

View file

@ -1371,7 +1371,7 @@ fn compare_number_of_generics<'tcx>(
let spans = arg_spans(impl_.kind, impl_item.generics);
let span = spans.first().copied();
let mut err = tcx.dcx().struct_span_err_with_code(
let mut err = tcx.dcx().struct_span_err(
spans,
format!(
"{} `{}` has {} {kind} parameter{} but its trait \
@ -1384,8 +1384,8 @@ fn compare_number_of_generics<'tcx>(
pluralize!(trait_count),
kind = kind,
),
DiagnosticId::Error("E0049".into()),
);
err.code(DiagnosticId::Error("E0049".into()));
let msg =
format!("expected {trait_count} {kind} parameter{}", pluralize!(trait_count),);

View file

@ -523,8 +523,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
fn start_diagnostics(&self) -> DiagnosticBuilder<'tcx> {
let span = self.path_segment.ident.span;
let msg = self.create_error_message();
self.tcx.dcx().struct_span_err_with_code(span, msg, self.code())
self.tcx.dcx().struct_span_err(span, msg).code_mv(self.code())
}
/// Builds the `expected 1 type argument / supplied 2 type arguments` message.