aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/traits/chalk/tls.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-04-10 21:05:31 +0100
committerFlorian Diebold <[email protected]>2020-04-13 13:31:03 +0100
commit7886513f89795e06eef258e0c54dbd1224c98317 (patch)
treed3eb6af5492c49011acf902c23712f346a1039f7 /crates/ra_hir_ty/src/traits/chalk/tls.rs
parentc388130f5ffbcbe7d3131213a24d12d02f769b87 (diff)
Nicer display of closures in Chalk logs
Diffstat (limited to 'crates/ra_hir_ty/src/traits/chalk/tls.rs')
-rw-r--r--crates/ra_hir_ty/src/traits/chalk/tls.rs24
1 files changed, 22 insertions, 2 deletions
diff --git a/crates/ra_hir_ty/src/traits/chalk/tls.rs b/crates/ra_hir_ty/src/traits/chalk/tls.rs
index d9bbb54a5..0a8932dae 100644
--- a/crates/ra_hir_ty/src/traits/chalk/tls.rs
+++ b/crates/ra_hir_ty/src/traits/chalk/tls.rs
@@ -5,7 +5,7 @@ use chalk_ir::{AliasTy, Goal, Goals, Lifetime, Parameter, ProgramClauseImplicati
5 5
6use super::{from_chalk, Interner}; 6use super::{from_chalk, Interner};
7use crate::{db::HirDatabase, CallableDef, TypeCtor}; 7use crate::{db::HirDatabase, CallableDef, TypeCtor};
8use hir_def::{AdtId, AssocContainerId, Lookup, TypeAliasId}; 8use hir_def::{AdtId, AssocContainerId, DefWithBodyId, Lookup, TypeAliasId};
9 9
10pub use unsafe_tls::{set_current_program, with_current_program}; 10pub use unsafe_tls::{set_current_program, with_current_program};
11 11
@@ -69,7 +69,27 @@ impl DebugContext<'_> {
69 write!(f, "{}::{}", trait_name, name)?; 69 write!(f, "{}::{}", trait_name, name)?;
70 } 70 }
71 TypeCtor::Closure { def, expr } => { 71 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, "}}")?;
73 } 93 }
74 } 94 }
75 Ok(()) 95 Ok(())