Improve debug printing without TLS
This commit is contained in:
parent
7c423f5b88
commit
29266ada04
@ -107,66 +107,65 @@ impl chalk_ir::interner::Interner for Interner {
|
||||
opaque_ty: &chalk_ir::OpaqueTy<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| Some(prog?.debug_opaque_ty(opaque_ty, fmt)))
|
||||
Some(write!(fmt, "{:?}", opaque_ty.opaque_ty_id))
|
||||
}
|
||||
|
||||
fn debug_opaque_ty_id(
|
||||
opaque_ty_id: chalk_ir::OpaqueTyId<Self>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| Some(prog?.debug_opaque_ty_id(opaque_ty_id, fmt)))
|
||||
Some(fmt.debug_struct("OpaqueTyId").field("index", &opaque_ty_id.0).finish())
|
||||
}
|
||||
|
||||
fn debug_ty(ty: &chalk_ir::Ty<Interner>, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| Some(prog?.debug_ty(ty, fmt)))
|
||||
Some(write!(fmt, "{:?}", ty.data(&Interner)))
|
||||
}
|
||||
|
||||
fn debug_lifetime(
|
||||
lifetime: &chalk_ir::Lifetime<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| Some(prog?.debug_lifetime(lifetime, fmt)))
|
||||
Some(write!(fmt, "{:?}", lifetime.data(&Interner)))
|
||||
}
|
||||
|
||||
fn debug_generic_arg(
|
||||
parameter: &GenericArg,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| Some(prog?.debug_generic_arg(parameter, fmt)))
|
||||
Some(write!(fmt, "{:?}", parameter.data(&Interner).inner_debug()))
|
||||
}
|
||||
|
||||
fn debug_goal(goal: &Goal<Interner>, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| Some(prog?.debug_goal(goal, fmt)))
|
||||
let goal_data = goal.data(&Interner);
|
||||
Some(write!(fmt, "{:?}", goal_data))
|
||||
}
|
||||
|
||||
fn debug_goals(
|
||||
goals: &chalk_ir::Goals<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| Some(prog?.debug_goals(goals, fmt)))
|
||||
Some(write!(fmt, "{:?}", goals.debug(&Interner)))
|
||||
}
|
||||
|
||||
fn debug_program_clause_implication(
|
||||
pci: &chalk_ir::ProgramClauseImplication<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| Some(prog?.debug_program_clause_implication(pci, fmt)))
|
||||
Some(write!(fmt, "{:?}", pci.debug(&Interner)))
|
||||
}
|
||||
|
||||
fn debug_substitution(
|
||||
substitution: &chalk_ir::Substitution<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| Some(prog?.debug_substitution(substitution, fmt)))
|
||||
Some(write!(fmt, "{:?}", substitution.debug(&Interner)))
|
||||
}
|
||||
|
||||
fn debug_separator_trait_ref(
|
||||
separator_trait_ref: &chalk_ir::SeparatorTraitRef<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| {
|
||||
Some(prog?.debug_separator_trait_ref(separator_trait_ref, fmt))
|
||||
})
|
||||
Some(write!(fmt, "{:?}", separator_trait_ref.debug(&Interner)))
|
||||
}
|
||||
|
||||
fn debug_fn_def_id(
|
||||
@ -179,47 +178,43 @@ impl chalk_ir::interner::Interner for Interner {
|
||||
constant: &chalk_ir::Const<Self>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| Some(prog?.debug_const(constant, fmt)))
|
||||
Some(write!(fmt, "{:?}", constant.data(&Interner)))
|
||||
}
|
||||
fn debug_variable_kinds(
|
||||
variable_kinds: &chalk_ir::VariableKinds<Self>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| Some(prog?.debug_variable_kinds(variable_kinds, fmt)))
|
||||
Some(write!(fmt, "{:?}", variable_kinds.as_slice(&Interner)))
|
||||
}
|
||||
fn debug_variable_kinds_with_angles(
|
||||
variable_kinds: &chalk_ir::VariableKinds<Self>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| {
|
||||
Some(prog?.debug_variable_kinds_with_angles(variable_kinds, fmt))
|
||||
})
|
||||
Some(write!(fmt, "{:?}", variable_kinds.inner_debug(&Interner)))
|
||||
}
|
||||
fn debug_canonical_var_kinds(
|
||||
canonical_var_kinds: &chalk_ir::CanonicalVarKinds<Self>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| {
|
||||
Some(prog?.debug_canonical_var_kinds(canonical_var_kinds, fmt))
|
||||
})
|
||||
Some(write!(fmt, "{:?}", canonical_var_kinds.as_slice(&Interner)))
|
||||
}
|
||||
fn debug_program_clause(
|
||||
clause: &chalk_ir::ProgramClause<Self>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| Some(prog?.debug_program_clause(clause, fmt)))
|
||||
Some(write!(fmt, "{:?}", clause.data(&Interner)))
|
||||
}
|
||||
fn debug_program_clauses(
|
||||
clauses: &chalk_ir::ProgramClauses<Self>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| Some(prog?.debug_program_clauses(clauses, fmt)))
|
||||
Some(write!(fmt, "{:?}", clauses.as_slice(&Interner)))
|
||||
}
|
||||
fn debug_quantified_where_clauses(
|
||||
clauses: &chalk_ir::QuantifiedWhereClauses<Self>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| Some(prog?.debug_quantified_where_clauses(clauses, fmt)))
|
||||
Some(write!(fmt, "{:?}", clauses.as_slice(&Interner)))
|
||||
}
|
||||
|
||||
fn intern_ty(&self, kind: chalk_ir::TyKind<Self>) -> Self::InternedType {
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! Implementation of Chalk debug helper functions using TLS.
|
||||
use std::fmt;
|
||||
use std::fmt::{self, Debug};
|
||||
|
||||
use chalk_ir::{AliasTy, GenericArg, Goal, Goals, Lifetime, ProgramClauseImplication};
|
||||
use chalk_ir::AliasTy;
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::{
|
||||
@ -53,14 +53,6 @@ impl DebugContext<'_> {
|
||||
write!(fmt, "{}::{}", trait_data.name, type_alias_data.name)
|
||||
}
|
||||
|
||||
pub(crate) fn debug_opaque_ty_id(
|
||||
&self,
|
||||
opaque_ty_id: chalk_ir::OpaqueTyId<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Result<(), fmt::Error> {
|
||||
fmt.debug_struct("OpaqueTyId").field("index", &opaque_ty_id.0).finish()
|
||||
}
|
||||
|
||||
pub(crate) fn debug_alias(
|
||||
&self,
|
||||
alias_ty: &AliasTy<Interner>,
|
||||
@ -68,7 +60,7 @@ impl DebugContext<'_> {
|
||||
) -> Result<(), fmt::Error> {
|
||||
match alias_ty {
|
||||
AliasTy::Projection(projection_ty) => self.debug_projection_ty(projection_ty, fmt),
|
||||
AliasTy::Opaque(opaque_ty) => self.debug_opaque_ty(opaque_ty, fmt),
|
||||
AliasTy::Opaque(opaque_ty) => opaque_ty.fmt(fmt),
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,79 +88,6 @@ impl DebugContext<'_> {
|
||||
write!(fmt, ">::{}", type_alias_data.name)
|
||||
}
|
||||
|
||||
pub(crate) fn debug_opaque_ty(
|
||||
&self,
|
||||
opaque_ty: &chalk_ir::OpaqueTy<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Result<(), fmt::Error> {
|
||||
write!(fmt, "{:?}", opaque_ty.opaque_ty_id)
|
||||
}
|
||||
|
||||
pub(crate) fn debug_ty(
|
||||
&self,
|
||||
ty: &chalk_ir::Ty<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Result<(), fmt::Error> {
|
||||
write!(fmt, "{:?}", ty.data(&Interner))
|
||||
}
|
||||
|
||||
pub(crate) fn debug_lifetime(
|
||||
&self,
|
||||
lifetime: &Lifetime<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Result<(), fmt::Error> {
|
||||
write!(fmt, "{:?}", lifetime.data(&Interner))
|
||||
}
|
||||
|
||||
pub(crate) fn debug_generic_arg(
|
||||
&self,
|
||||
parameter: &GenericArg<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Result<(), fmt::Error> {
|
||||
write!(fmt, "{:?}", parameter.data(&Interner).inner_debug())
|
||||
}
|
||||
|
||||
pub(crate) fn debug_goal(
|
||||
&self,
|
||||
goal: &Goal<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Result<(), fmt::Error> {
|
||||
let goal_data = goal.data(&Interner);
|
||||
write!(fmt, "{:?}", goal_data)
|
||||
}
|
||||
|
||||
pub(crate) fn debug_goals(
|
||||
&self,
|
||||
goals: &Goals<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Result<(), fmt::Error> {
|
||||
write!(fmt, "{:?}", goals.debug(&Interner))
|
||||
}
|
||||
|
||||
pub(crate) fn debug_program_clause_implication(
|
||||
&self,
|
||||
pci: &ProgramClauseImplication<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Result<(), fmt::Error> {
|
||||
write!(fmt, "{:?}", pci.debug(&Interner))
|
||||
}
|
||||
|
||||
pub(crate) fn debug_substitution(
|
||||
&self,
|
||||
substitution: &chalk_ir::Substitution<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Result<(), fmt::Error> {
|
||||
write!(fmt, "{:?}", substitution.debug(&Interner))
|
||||
}
|
||||
|
||||
pub(crate) fn debug_separator_trait_ref(
|
||||
&self,
|
||||
separator_trait_ref: &chalk_ir::SeparatorTraitRef<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> Result<(), fmt::Error> {
|
||||
write!(fmt, "{:?}", separator_trait_ref.debug(&Interner))
|
||||
}
|
||||
|
||||
pub(crate) fn debug_fn_def_id(
|
||||
&self,
|
||||
fn_def_id: chalk_ir::FnDefId<Interner>,
|
||||
@ -190,57 +109,6 @@ impl DebugContext<'_> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn debug_const(
|
||||
&self,
|
||||
_constant: &chalk_ir::Const<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> fmt::Result {
|
||||
write!(fmt, "const")
|
||||
}
|
||||
|
||||
pub(crate) fn debug_variable_kinds(
|
||||
&self,
|
||||
variable_kinds: &chalk_ir::VariableKinds<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> fmt::Result {
|
||||
write!(fmt, "{:?}", variable_kinds.as_slice(&Interner))
|
||||
}
|
||||
pub(crate) fn debug_variable_kinds_with_angles(
|
||||
&self,
|
||||
variable_kinds: &chalk_ir::VariableKinds<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> fmt::Result {
|
||||
write!(fmt, "{:?}", variable_kinds.inner_debug(&Interner))
|
||||
}
|
||||
pub(crate) fn debug_canonical_var_kinds(
|
||||
&self,
|
||||
canonical_var_kinds: &chalk_ir::CanonicalVarKinds<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> fmt::Result {
|
||||
write!(fmt, "{:?}", canonical_var_kinds.as_slice(&Interner))
|
||||
}
|
||||
pub(crate) fn debug_program_clause(
|
||||
&self,
|
||||
clause: &chalk_ir::ProgramClause<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> fmt::Result {
|
||||
write!(fmt, "{:?}", clause.data(&Interner))
|
||||
}
|
||||
pub(crate) fn debug_program_clauses(
|
||||
&self,
|
||||
clauses: &chalk_ir::ProgramClauses<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> fmt::Result {
|
||||
write!(fmt, "{:?}", clauses.as_slice(&Interner))
|
||||
}
|
||||
pub(crate) fn debug_quantified_where_clauses(
|
||||
&self,
|
||||
clauses: &chalk_ir::QuantifiedWhereClauses<Interner>,
|
||||
fmt: &mut fmt::Formatter<'_>,
|
||||
) -> fmt::Result {
|
||||
write!(fmt, "{:?}", clauses.as_slice(&Interner))
|
||||
}
|
||||
}
|
||||
|
||||
mod unsafe_tls {
|
||||
|
Loading…
x
Reference in New Issue
Block a user