From 11b9845afd1daa845ac9d541fd22f1fdf53436c8 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 10 Aug 2019 12:13:39 +0200 Subject: Improve debug logging a bit --- crates/ra_hir/src/ty.rs | 14 ++++++++++++++ crates/ra_hir/src/ty/traits.rs | 8 ++++---- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index f9cf3ec72..642dd02cb 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs @@ -692,3 +692,17 @@ impl HirDisplay for TraitRef { Ok(()) } } + +impl HirDisplay for Obligation { + fn hir_fmt(&self, f: &mut HirFormatter) -> fmt::Result { + match self { + Obligation::Trait(tr) => write!(f, "Implements({})", tr.display(f.db)), + Obligation::Projection(proj) => write!( + f, + "Normalize({} => {})", + proj.projection_ty.display(f.db), + proj.ty.display(f.db) + ), + } + } +} diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs index 0769e6e17..fde5d8a47 100644 --- a/crates/ra_hir/src/ty/traits.rs +++ b/crates/ra_hir/src/ty/traits.rs @@ -7,7 +7,7 @@ use parking_lot::Mutex; use ra_prof::profile; use rustc_hash::FxHashSet; -use super::{Canonical, GenericPredicate, ProjectionTy, TraitRef, Ty}; +use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty}; use crate::{db::HirDatabase, Crate, ImplBlock, Trait}; use self::chalk::{from_chalk, ToChalk}; @@ -61,7 +61,6 @@ fn solve( ) -> Option { let context = ChalkContext { db, krate }; let solver = db.trait_solver(krate); - debug!("solve goal: {:?}", goal); let solution = solver.lock().solve(&context, goal); debug!("solve({:?}) => {:?}", goal, solution); solution @@ -120,10 +119,11 @@ pub struct ProjectionPredicate { pub(crate) fn trait_solve_query( db: &impl HirDatabase, krate: Crate, - trait_ref: Canonical>, + goal: Canonical>, ) -> Option { let _p = profile("trait_solve_query"); - let canonical = trait_ref.to_chalk(db).cast(); + debug!("trait_solve_query({})", goal.value.value.display(db)); + let canonical = goal.to_chalk(db).cast(); // We currently don't deal with universes (I think / hope they're not yet // relevant for our use cases?) let u_canonical = chalk_ir::UCanonical { canonical, universes: 1 }; -- cgit v1.2.3