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

@ -2356,15 +2356,15 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
},
};
let mut err = self.tcx.dcx().struct_span_err_with_code(
span,
format!("{labeled_user_string} may not live long enough"),
match sub.kind() {
ty::ReEarlyParam(_) | ty::ReLateParam(_) if sub.has_name() => error_code!(E0309),
ty::ReStatic => error_code!(E0310),
_ => error_code!(E0311),
},
);
let mut err = self
.tcx
.dcx()
.struct_span_err(span, format!("{labeled_user_string} may not live long enough"));
err.code(match sub.kind() {
ty::ReEarlyParam(_) | ty::ReLateParam(_) if sub.has_name() => error_code!(E0309),
ty::ReStatic => error_code!(E0310),
_ => error_code!(E0311),
});
'_explain: {
let (description, span) = match sub.kind() {