1
Fork 0

Add explanatory note to async block type mismatch error

This commit is contained in:
Gurinder Singh 2024-06-10 17:14:49 +05:30
parent 16e8803579
commit 251d2d0d4d
2 changed files with 13 additions and 0 deletions

View file

@ -32,6 +32,15 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
diag.note("no two closures, even if identical, have the same type");
diag.help("consider boxing your closure and/or using it as a trait object");
}
(ty::Coroutine(def_id1, ..), ty::Coroutine(def_id2, ..))
if self.tcx.coroutine_is_async(def_id1)
&& self.tcx.coroutine_is_async(def_id2) =>
{
diag.note("no two async blocks, even if identical, have the same type");
diag.help(
"consider pinning your async block and casting it to a trait object",
);
}
(ty::Alias(ty::Opaque, ..), ty::Alias(ty::Opaque, ..)) => {
// Issue #63167
diag.note("distinct uses of `impl Trait` result in different opaque types");