Rollup merge of #119538 - nnethercote:cleanup-errors-5, r=compiler-errors

Cleanup error handlers: round 5

More rustc_errors cleanups. A sequel to https://github.com/rust-lang/rust/pull/119171.

r? ````@compiler-errors````
This commit is contained in:
Michael Goulet
2024-01-05 10:57:21 -05:00
committed by GitHub
57 changed files with 369 additions and 464 deletions

View File

@@ -2007,7 +2007,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
};
err.code(error_code!(E0746));
err.set_primary_message("return type cannot have an unboxed trait object");
err.primary_message("return type cannot have an unboxed trait object");
err.children.clear();
let span = obligation.cause.span;
@@ -2712,7 +2712,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
if name == sym::Send { ("`Send`", "sent") } else { ("`Sync`", "shared") };
err.clear_code();
err.set_primary_message(format!(
err.primary_message(format!(
"{future_or_coroutine} cannot be {trait_verb} between threads safely"
));
@@ -2800,7 +2800,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
.unwrap_or_else(|| format!("{future_or_coroutine} is not {trait_name}"));
span.push_span_label(original_span, message);
err.set_span(span);
err.span(span);
format!("is not {trait_name}")
} else {

View File

@@ -3163,14 +3163,14 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
) {
match obligation_cause_code {
ObligationCauseCode::RustCall => {
err.set_primary_message("functions with the \"rust-call\" ABI must take a single non-self tuple argument");
err.primary_message("functions with the \"rust-call\" ABI must take a single non-self tuple argument");
}
ObligationCauseCode::BindingObligation(def_id, _)
| ObligationCauseCode::ItemObligation(def_id)
if self.tcx.is_fn_trait(*def_id) =>
{
err.code(rustc_errors::error_code!(E0059));
err.set_primary_message(format!(
err.primary_message(format!(
"type parameter to bare `{}` trait must be a tuple",
self.tcx.def_path_str(*def_id)
));