diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-11-27 16:03:08 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-27 16:03:08 +0100 |
| commit | 6e6c42c61c5535ffd748b0b1c71b14f2e962da3e (patch) | |
| tree | 5375097616878957e63518741c742518a91beadc /compiler/rustc_middle/src | |
| parent | 9ebffb7c3c89471633494f432822eb1175be2b23 (diff) | |
| parent | c96d888bdfb23122c7823445f471b3d284dd07e6 (diff) | |
| download | rust-6e6c42c61c5535ffd748b0b1c71b14f2e962da3e.tar.gz rust-6e6c42c61c5535ffd748b0b1c71b14f2e962da3e.zip | |
Rollup merge of #104931 - Swatinem:async-pretty, r=eholk
Pretty-print generators with their `generator_kind` After removing `GenFuture`, I special-cased async generators to pretty-print as `impl Future<Output = X>` mainly to avoid too much diagnostics changes originally. This now reverses that change so that async fn/blocks are pretty-printed as `[$async-type@$source-position]` in various diagnostics, and updates the tests that this touches.
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index d5e196b2e9f..bd6d573c162 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -681,25 +681,20 @@ pub trait PrettyPrinter<'tcx>: } ty::Str => p!("str"), ty::Generator(did, substs, movability) => { - // FIXME(swatinem): async constructs used to be pretty printed - // as `impl Future` previously due to the `from_generator` wrapping. - // lets special case this here for now to avoid churn in diagnostics. - let generator_kind = self.tcx().generator_kind(did); - if matches!(generator_kind, Some(hir::GeneratorKind::Async(..))) { - let return_ty = substs.as_generator().return_ty(); - p!(write("impl Future<Output = {}>", return_ty)); - - return Ok(self); - } - p!(write("[")); - match movability { - hir::Movability::Movable => {} - hir::Movability::Static => p!("static "), + let generator_kind = self.tcx().generator_kind(did).unwrap(); + let should_print_movability = + self.should_print_verbose() || generator_kind == hir::GeneratorKind::Gen; + + if should_print_movability { + match movability { + hir::Movability::Movable => {} + hir::Movability::Static => p!("static "), + } } if !self.should_print_verbose() { - p!("generator"); + p!(write("{}", generator_kind)); // FIXME(eddyb) should use `def_span`. if let Some(did) = did.as_local() { let span = self.tcx().def_span(did); |
