From ea265aad64366340fa7986f7f93488300631168c Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 22 May 2020 18:05:48 +0200 Subject: Provide missing Chalk debug methods --- crates/ra_hir_ty/src/traits/chalk/interner.rs | 53 ++++++++++++++++++++++++ crates/ra_hir_ty/src/traits/chalk/tls.rs | 59 +++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) (limited to 'crates/ra_hir_ty') 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 { }) } + fn debug_fn_def_id( + fn_def_id: chalk_ir::FnDefId, + fmt: &mut fmt::Formatter<'_>, + ) -> Option { + tls::with_current_program(|prog| Some(prog?.debug_fn_def_id(fn_def_id, fmt))) + } + fn debug_const( + constant: &chalk_ir::Const, + fmt: &mut fmt::Formatter<'_>, + ) -> Option { + tls::with_current_program(|prog| Some(prog?.debug_const(constant, fmt))) + } + fn debug_variable_kinds( + variable_kinds: &chalk_ir::VariableKinds, + fmt: &mut fmt::Formatter<'_>, + ) -> Option { + tls::with_current_program(|prog| Some(prog?.debug_variable_kinds(variable_kinds, fmt))) + } + fn debug_variable_kinds_with_angles( + variable_kinds: &chalk_ir::VariableKinds, + fmt: &mut fmt::Formatter<'_>, + ) -> Option { + tls::with_current_program(|prog| { + Some(prog?.debug_variable_kinds_with_angles(variable_kinds, fmt)) + }) + } + fn debug_canonical_var_kinds( + canonical_var_kinds: &chalk_ir::CanonicalVarKinds, + fmt: &mut fmt::Formatter<'_>, + ) -> Option { + tls::with_current_program(|prog| { + Some(prog?.debug_canonical_var_kinds(canonical_var_kinds, fmt)) + }) + } + fn debug_program_clause( + clause: &chalk_ir::ProgramClause, + fmt: &mut fmt::Formatter<'_>, + ) -> Option { + tls::with_current_program(|prog| Some(prog?.debug_program_clause(clause, fmt))) + } + fn debug_program_clauses( + clauses: &chalk_ir::ProgramClauses, + fmt: &mut fmt::Formatter<'_>, + ) -> Option { + tls::with_current_program(|prog| Some(prog?.debug_program_clauses(clauses, fmt))) + } + fn debug_quantified_where_clauses( + clauses: &chalk_ir::QuantifiedWhereClauses, + fmt: &mut fmt::Formatter<'_>, + ) -> Option { + tls::with_current_program(|prog| Some(prog?.debug_quantified_where_clauses(clauses, fmt))) + } + fn intern_ty(&self, ty: chalk_ir::TyData) -> Box> { Box::new(ty) } 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<'_> { ) -> Result<(), fmt::Error> { write!(fmt, "{:?}", separator_trait_ref.debug(&Interner)) } + + pub fn debug_fn_def_id( + &self, + _fn_def_id: chalk_ir::FnDefId, + fmt: &mut fmt::Formatter<'_>, + ) -> Result<(), fmt::Error> { + write!(fmt, "fn") + } + + pub fn debug_const( + &self, + _constant: &chalk_ir::Const, + fmt: &mut fmt::Formatter<'_>, + ) -> fmt::Result { + write!(fmt, "const") + } + + pub fn debug_variable_kinds( + &self, + variable_kinds: &chalk_ir::VariableKinds, + fmt: &mut fmt::Formatter<'_>, + ) -> fmt::Result { + write!(fmt, "{:?}", variable_kinds.as_slice(&Interner)) + } + pub fn debug_variable_kinds_with_angles( + &self, + variable_kinds: &chalk_ir::VariableKinds, + fmt: &mut fmt::Formatter<'_>, + ) -> fmt::Result { + write!(fmt, "{:?}", variable_kinds.inner_debug(&Interner)) + } + pub fn debug_canonical_var_kinds( + &self, + canonical_var_kinds: &chalk_ir::CanonicalVarKinds, + fmt: &mut fmt::Formatter<'_>, + ) -> fmt::Result { + write!(fmt, "{:?}", canonical_var_kinds.as_slice(&Interner)) + } + pub fn debug_program_clause( + &self, + clause: &chalk_ir::ProgramClause, + fmt: &mut fmt::Formatter<'_>, + ) -> fmt::Result { + write!(fmt, "{:?}", clause.data(&Interner)) + } + pub fn debug_program_clauses( + &self, + clauses: &chalk_ir::ProgramClauses, + fmt: &mut fmt::Formatter<'_>, + ) -> fmt::Result { + write!(fmt, "{:?}", clauses.as_slice(&Interner)) + } + pub fn debug_quantified_where_clauses( + &self, + clauses: &chalk_ir::QuantifiedWhereClauses, + fmt: &mut fmt::Formatter<'_>, + ) -> fmt::Result { + write!(fmt, "{:?}", clauses.as_slice(&Interner)) + } } mod unsafe_tls { -- cgit v1.2.3