about summary refs log tree commit diff
path: root/compiler/rustc_middle
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-08-20 00:46:00 -0400
committerGitHub <noreply@github.com>2025-08-20 00:46:00 -0400
commitef22202db230a47bd82b168684d3580c40531d28 (patch)
treef5d7d90c247244920ac81efb57598ee33d94d8bb /compiler/rustc_middle
parent6e6522980a88f117152dafdaba7f8e21d1bdd3fd (diff)
parentab6f4d62c0aab0f64b663bb572de8a896411b46a (diff)
downloadrust-ef22202db230a47bd82b168684d3580c40531d28.tar.gz
rust-ef22202db230a47bd82b168684d3580c40531d28.zip
Rollup merge of #145623 - compiler-errors:pretty-async-name, r=wesleywiser
Pretty print the name of an future from calling async closure

Fixes https://github.com/rust-lang/rust/issues/145606 by introducing a way to customize the path rendering of async closures' futures in the pretty printer API.
Diffstat (limited to 'compiler/rustc_middle')
-rw-r--r--compiler/rustc_middle/src/ty/print/mod.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs
index e6feafea122..9e6f277ef77 100644
--- a/compiler/rustc_middle/src/ty/print/mod.rs
+++ b/compiler/rustc_middle/src/ty/print/mod.rs
@@ -124,6 +124,15 @@ pub trait Printer<'tcx>: Sized {
         trait_ref: Option<ty::TraitRef<'tcx>>,
     ) -> Result<(), PrintError>;
 
+    fn print_coroutine_with_kind(
+        &mut self,
+        def_id: DefId,
+        parent_args: &'tcx [GenericArg<'tcx>],
+        kind: Ty<'tcx>,
+    ) -> Result<(), PrintError> {
+        self.print_path_with_generic_args(|p| p.print_def_path(def_id, parent_args), &[kind.into()])
+    }
+
     // Defaults (should not be overridden):
 
     #[instrument(skip(self), level = "debug")]
@@ -162,9 +171,10 @@ pub trait Printer<'tcx>: Sized {
                             )) = self.tcx().coroutine_kind(def_id)
                                 && args.len() > parent_args.len()
                             {
-                                return self.print_path_with_generic_args(
-                                    |p| p.print_def_path(def_id, parent_args),
-                                    &args[..parent_args.len() + 1][..1],
+                                return self.print_coroutine_with_kind(
+                                    def_id,
+                                    parent_args,
+                                    args[parent_args.len()].expect_ty(),
                                 );
                             } else {
                                 // Closures' own generics are only captures, don't print them.