about summary refs log tree commit diff
path: root/compiler/rustc_middle
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-09-08 08:23:03 +0200
committerGitHub <noreply@github.com>2023-09-08 08:23:03 +0200
commitbef5187e8b4e15ff306bc74fabed582a2e65127f (patch)
treee0bbaa18e112b2bd039cb51e9ce43e68a403135e /compiler/rustc_middle
parent403a18f13dd8f009c3ca31cea56d0c9dfea3c4d5 (diff)
parent748476d94d0fd87a0ee149e49ab3b196bbb08420 (diff)
downloadrust-bef5187e8b4e15ff306bc74fabed582a2e65127f.tar.gz
rust-bef5187e8b4e15ff306bc74fabed582a2e65127f.zip
Rollup merge of #115624 - compiler-errors:rtn-path, r=WaffleLapkin
Print the path of a return-position impl trait in trait when `return_type_notation` is enabled

When we're printing a return-position impl trait in trait, we usually just print it like an opaque. This is *usually* fine, but can be confusing when using `return_type_notation`. Print the path of the method from where the RPITIT originates when this feature gate is enabled.
Diffstat (limited to 'compiler/rustc_middle')
-rw-r--r--compiler/rustc_middle/src/ty/print/pretty.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs
index ac0c88468fa..7191ed7a0f6 100644
--- a/compiler/rustc_middle/src/ty/print/pretty.rs
+++ b/compiler/rustc_middle/src/ty/print/pretty.rs
@@ -1123,6 +1123,17 @@ pub trait PrettyPrinter<'tcx>:
             }
         }
 
+        if self.tcx().features().return_type_notation
+            && let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, .. }) = self.tcx().opt_rpitit_info(def_id)
+            && let ty::Alias(_, alias_ty) = self.tcx().fn_sig(fn_def_id).skip_binder().output().skip_binder().kind()
+            && alias_ty.def_id == def_id
+        {
+            let num_args = self.tcx().generics_of(fn_def_id).count();
+            write!(self, " {{ ")?;
+            self = self.print_def_path(fn_def_id, &args[..num_args])?;
+            write!(self, "() }}")?;
+        }
+
         Ok(self)
     }