diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-02-11 01:37:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-11 01:37:57 +0100 |
| commit | 870435b50bf1b80285be8e80cedb4cdeb5419874 (patch) | |
| tree | b17abce11e2019eaaf03ee6f05459d32211dccf4 /compiler/rustc_middle/src | |
| parent | 302301bc3ad465a6f780db3bb8ced5cd1a0fbf0f (diff) | |
| parent | 86ddb53cab48965bcd4b346fc4b0965640cb7615 (diff) | |
| download | rust-870435b50bf1b80285be8e80cedb4cdeb5419874.tar.gz rust-870435b50bf1b80285be8e80cedb4cdeb5419874.zip | |
Rollup merge of #120896 - compiler-errors:coro-closure-kind, r=oli-obk
Print kind of coroutine closure Make sure that we print "async closure" when we have an async closure, rather than calling it generically a ["coroutine-closure"](https://github.com/rust-lang/rust/pull/120361). Fixes #120886 r? oli-obk
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index f90703e6184..5cf90e94907 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -877,7 +877,24 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { ty::CoroutineClosure(did, args) => { p!(write("{{")); if !self.should_print_verbose() { - p!(write("coroutine-closure")); + match self.tcx().coroutine_kind(self.tcx().coroutine_for_closure(did)).unwrap() + { + hir::CoroutineKind::Desugared( + hir::CoroutineDesugaring::Async, + hir::CoroutineSource::Closure, + ) => p!("async closure"), + hir::CoroutineKind::Desugared( + hir::CoroutineDesugaring::AsyncGen, + hir::CoroutineSource::Closure, + ) => p!("async gen closure"), + hir::CoroutineKind::Desugared( + hir::CoroutineDesugaring::Gen, + hir::CoroutineSource::Closure, + ) => p!("gen closure"), + _ => unreachable!( + "coroutine from coroutine-closure should have CoroutineSource::Closure" + ), + } // FIXME(eddyb) should use `def_span`. if let Some(did) = did.as_local() { if self.tcx().sess.opts.unstable_opts.span_free_formats { |
