Skip to content

Commit

Permalink
Add explanatory note to async block type mismatch error
Browse files Browse the repository at this point in the history
  • Loading branch information
gurry committed Jun 10, 2024
1 parent 16e8803 commit 251d2d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 4 additions & 0 deletions tests/ui/async-await/coroutine-desc.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ LL | fun(async {}, async {});
|
= note: expected `async` block `{async block@$DIR/coroutine-desc.rs:10:9: 10:17}`
found `async` block `{async block@$DIR/coroutine-desc.rs:10:19: 10:27}`
= note: no two async blocks, even if identical, have the same type
= help: consider pinning your async block and casting it to a trait object
note: function defined here
--> $DIR/coroutine-desc.rs:8:4
|
Expand Down Expand Up @@ -51,6 +53,8 @@ LL | fun((async || {})(), (async || {})());
|
= note: expected `async` closure body `{async closure body@$DIR/coroutine-desc.rs:14:19: 14:21}`
found `async` closure body `{async closure body@$DIR/coroutine-desc.rs:14:36: 14:38}`
= note: no two async blocks, even if identical, have the same type
= help: consider pinning your async block and casting it to a trait object
note: function defined here
--> $DIR/coroutine-desc.rs:8:4
|
Expand Down

0 comments on commit 251d2d0

Please sign in to comment.