@@ -5,7 +5,7 @@ use chalk_ir::{AliasTy, Goal, Goals, Lifetime, Parameter, ProgramClauseImplicati
55
66use super :: { from_chalk, Interner } ;
77use crate :: { db:: HirDatabase , CallableDef , TypeCtor } ;
8- use hir_def:: { AdtId , AssocContainerId , Lookup , TypeAliasId } ;
8+ use hir_def:: { AdtId , AssocContainerId , DefWithBodyId , Lookup , TypeAliasId } ;
99
1010pub use unsafe_tls:: { set_current_program, with_current_program} ;
1111
@@ -69,7 +69,27 @@ impl DebugContext<'_> {
6969 write ! ( f, "{}::{}" , trait_name, name) ?;
7070 }
7171 TypeCtor :: Closure { def, expr } => {
72- write ! ( f, "{{closure {:?} in {:?}}}" , expr. into_raw( ) , def) ?;
72+ write ! ( f, "{{closure {:?} in " , expr. into_raw( ) ) ?;
73+ match def {
74+ DefWithBodyId :: FunctionId ( func) => {
75+ write ! ( f, "fn {}" , self . 0 . function_data( func) . name) ?
76+ }
77+ DefWithBodyId :: StaticId ( s) => {
78+ if let Some ( name) = self . 0 . static_data ( s) . name . as_ref ( ) {
79+ write ! ( f, "body of static {}" , name) ?;
80+ } else {
81+ write ! ( f, "body of unnamed static {:?}" , s) ?;
82+ }
83+ }
84+ DefWithBodyId :: ConstId ( c) => {
85+ if let Some ( name) = self . 0 . const_data ( c) . name . as_ref ( ) {
86+ write ! ( f, "body of const {}" , name) ?;
87+ } else {
88+ write ! ( f, "body of unnamed const {:?}" , c) ?;
89+ }
90+ }
91+ } ;
92+ write ! ( f, "}}" ) ?;
7393 }
7494 }
7595 Ok ( ( ) )
0 commit comments