1
Fork 0

Rollup merge of #132757 - compiler-errors:yeet-check-wf, r=lcnr

Get rid of `check_opaque_type_well_formed`

Instead, replicate it by improving the span of the opaque in `check_opaque_meets_bounds`.

This has two consequences:
1. We now prefer "concrete type differs" errors, since we'll hit those first before we check the opaque is WF.
2. Spans have gotten slightly worse.

Specifically, (2.) could be improved by adding a new obligation cause that explains that the definition's environment has stronger assumptions than the declaration.

r? lcnr
This commit is contained in:
Jubilee 2024-11-08 20:46:12 -08:00 committed by GitHub
commit 7a4970476e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 395 additions and 418 deletions

View file

@ -2953,6 +2953,22 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
// We hold the `DefId` of the item introducing the obligation, but displaying it
// doesn't add user usable information. It always point at an associated item.
}
ObligationCauseCode::OpaqueTypeBound(span, definition_def_id) => {
err.span_note(span, "required by a bound in an opaque type");
if let Some(definition_def_id) = definition_def_id
// If there are any stalled coroutine obligations, then this
// error may be due to that, and not because the body has more
// where-clauses.
&& self.tcx.typeck(definition_def_id).coroutine_stalled_predicates.is_empty()
{
// FIXME(compiler-errors): We could probably point to something
// specific here if we tried hard enough...
err.span_note(
tcx.def_span(definition_def_id),
"this definition site has more where clauses than the opaque type",
);
}
}
ObligationCauseCode::Coercion { source, target } => {
let source =
tcx.short_ty_string(self.resolve_vars_if_possible(source), long_ty_file);