aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-05-22 17:05:48 +0100
committerFlorian Diebold <[email protected]>2020-05-22 18:52:06 +0100
commitea265aad64366340fa7986f7f93488300631168c (patch)
treef9875be8e240fd2d339e00b77035713f85660a4e /crates
parent27fe68ad5c908d439af6cfbe7748c56eb6f107fc (diff)
Provide missing Chalk debug methods
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir_ty/src/traits/chalk/interner.rs53
-rw-r--r--crates/ra_hir_ty/src/traits/chalk/tls.rs59
2 files changed, 112 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/traits/chalk/interner.rs b/crates/ra_hir_ty/src/traits/chalk/interner.rs
index d98e5cb2d..060372819 100644
--- a/crates/ra_hir_ty/src/traits/chalk/interner.rs
+++ b/crates/ra_hir_ty/src/traits/chalk/interner.rs
@@ -138,6 +138,59 @@ impl chalk_ir::interner::Interner for Interner {
138 }) 138 })
139 } 139 }
140 140
141 fn debug_fn_def_id(
142 fn_def_id: chalk_ir::FnDefId<Self>,
143 fmt: &mut fmt::Formatter<'_>,
144 ) -> Option<fmt::Result> {
145 tls::with_current_program(|prog| Some(prog?.debug_fn_def_id(fn_def_id, fmt)))
146 }
147 fn debug_const(
148 constant: &chalk_ir::Const<Self>,
149 fmt: &mut fmt::Formatter<'_>,
150 ) -> Option<fmt::Result> {
151 tls::with_current_program(|prog| Some(prog?.debug_const(constant, fmt)))
152 }
153 fn debug_variable_kinds(
154 variable_kinds: &chalk_ir::VariableKinds<Self>,
155 fmt: &mut fmt::Formatter<'_>,
156 ) -> Option<fmt::Result> {
157 tls::with_current_program(|prog| Some(prog?.debug_variable_kinds(variable_kinds, fmt)))
158 }
159 fn debug_variable_kinds_with_angles(
160 variable_kinds: &chalk_ir::VariableKinds<Self>,
161 fmt: &mut fmt::Formatter<'_>,
162 ) -> Option<fmt::Result> {
163 tls::with_current_program(|prog| {
164 Some(prog?.debug_variable_kinds_with_angles(variable_kinds, fmt))
165 })
166 }
167 fn debug_canonical_var_kinds(
168 canonical_var_kinds: &chalk_ir::CanonicalVarKinds<Self>,
169 fmt: &mut fmt::Formatter<'_>,
170 ) -> Option<fmt::Result> {
171 tls::with_current_program(|prog| {
172 Some(prog?.debug_canonical_var_kinds(canonical_var_kinds, fmt))
173 })
174 }
175 fn debug_program_clause(
176 clause: &chalk_ir::ProgramClause<Self>,
177 fmt: &mut fmt::Formatter<'_>,
178 ) -> Option<fmt::Result> {
179 tls::with_current_program(|prog| Some(prog?.debug_program_clause(clause, fmt)))
180 }
181 fn debug_program_clauses(
182 clauses: &chalk_ir::ProgramClauses<Self>,
183 fmt: &mut fmt::Formatter<'_>,
184 ) -> Option<fmt::Result> {
185 tls::with_current_program(|prog| Some(prog?.debug_program_clauses(clauses, fmt)))
186 }
187 fn debug_quantified_where_clauses(
188 clauses: &chalk_ir::QuantifiedWhereClauses<Self>,
189 fmt: &mut fmt::Formatter<'_>,
190 ) -> Option<fmt::Result> {
191 tls::with_current_program(|prog| Some(prog?.debug_quantified_where_clauses(clauses, fmt)))
192 }
193
141 fn intern_ty(&self, ty: chalk_ir::TyData<Self>) -> Box<chalk_ir::TyData<Self>> { 194 fn intern_ty(&self, ty: chalk_ir::TyData<Self>) -> Box<chalk_ir::TyData<Self>> {
142 Box::new(ty) 195 Box::new(ty)
143 } 196 }
diff --git a/crates/ra_hir_ty/src/traits/chalk/tls.rs b/crates/ra_hir_ty/src/traits/chalk/tls.rs
index 5dfd8e3ec..ebf402a07 100644
--- a/crates/ra_hir_ty/src/traits/chalk/tls.rs
+++ b/crates/ra_hir_ty/src/traits/chalk/tls.rs
@@ -244,6 +244,65 @@ impl DebugContext<'_> {
244 ) -> Result<(), fmt::Error> { 244 ) -> Result<(), fmt::Error> {
245 write!(fmt, "{:?}", separator_trait_ref.debug(&Interner)) 245 write!(fmt, "{:?}", separator_trait_ref.debug(&Interner))
246 } 246 }
247
248 pub fn debug_fn_def_id(
249 &self,
250 _fn_def_id: chalk_ir::FnDefId<Interner>,
251 fmt: &mut fmt::Formatter<'_>,
252 ) -> Result<(), fmt::Error> {
253 write!(fmt, "fn")
254 }
255
256 pub fn debug_const(
257 &self,
258 _constant: &chalk_ir::Const<Interner>,
259 fmt: &mut fmt::Formatter<'_>,
260 ) -> fmt::Result {
261 write!(fmt, "const")
262 }
263
264 pub fn debug_variable_kinds(
265 &self,
266 variable_kinds: &chalk_ir::VariableKinds<Interner>,
267 fmt: &mut fmt::Formatter<'_>,
268 ) -> fmt::Result {
269 write!(fmt, "{:?}", variable_kinds.as_slice(&Interner))
270 }
271 pub fn debug_variable_kinds_with_angles(
272 &self,
273 variable_kinds: &chalk_ir::VariableKinds<Interner>,
274 fmt: &mut fmt::Formatter<'_>,
275 ) -> fmt::Result {
276 write!(fmt, "{:?}", variable_kinds.inner_debug(&Interner))
277 }
278 pub fn debug_canonical_var_kinds(
279 &self,
280 canonical_var_kinds: &chalk_ir::CanonicalVarKinds<Interner>,
281 fmt: &mut fmt::Formatter<'_>,
282 ) -> fmt::Result {
283 write!(fmt, "{:?}", canonical_var_kinds.as_slice(&Interner))
284 }
285 pub fn debug_program_clause(
286 &self,
287 clause: &chalk_ir::ProgramClause<Interner>,
288 fmt: &mut fmt::Formatter<'_>,
289 ) -> fmt::Result {
290 write!(fmt, "{:?}", clause.data(&Interner))
291 }
292 pub fn debug_program_clauses(
293 &self,
294 clauses: &chalk_ir::ProgramClauses<Interner>,
295 fmt: &mut fmt::Formatter<'_>,
296 ) -> fmt::Result {
297 write!(fmt, "{:?}", clauses.as_slice(&Interner))
298 }
299 pub fn debug_quantified_where_clauses(
300 &self,
301 clauses: &chalk_ir::QuantifiedWhereClauses<Interner>,
302 fmt: &mut fmt::Formatter<'_>,
303 ) -> fmt::Result {
304 write!(fmt, "{:?}", clauses.as_slice(&Interner))
305 }
247} 306}
248 307
249mod unsafe_tls { 308mod unsafe_tls {