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

@ -944,13 +944,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
trait_item_span,
trait_path,
} => {
self.dcx().struct_span_err_with_code(
self.dcx().struct_span_err(
span,
format!(
"item `{name}` is an associated {kind}, which doesn't match its trait `{trait_path}`",
),
code,
)
.code_mv(code)
.span_label_mv(span, "does not match trait")
.span_label_mv(trait_item_span, "item in trait")
}

View file

@ -429,8 +429,8 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
let base_error = self.make_base_error(path, span, source, res);
let code = source.error_code(res.is_some());
let mut err =
self.r.dcx().struct_span_err_with_code(base_error.span, base_error.msg.clone(), code);
let mut err = self.r.dcx().struct_span_err(base_error.span, base_error.msg.clone());
err.code(code);
self.suggest_at_operator_in_slice_pat_with_range(&mut err, path);
self.suggest_swapping_misplaced_self_ty_and_trait(&mut err, source, res, base_error.span);