aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/hir_ty/src/traits.rs9
-rw-r--r--crates/hir_ty/src/traits/chalk.rs22
2 files changed, 19 insertions, 12 deletions
diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs
index 255323717..6a012cd6a 100644
--- a/crates/hir_ty/src/traits.rs
+++ b/crates/hir_ty/src/traits.rs
@@ -3,7 +3,7 @@ use std::sync::Arc;
3 3
4use base_db::CrateId; 4use base_db::CrateId;
5use chalk_ir::cast::Cast; 5use chalk_ir::cast::Cast;
6use chalk_solve::Solver; 6use chalk_solve::{logging_db::LoggingRustIrDatabase, Solver};
7use hir_def::{lang_item::LangItemTarget, TraitId}; 7use hir_def::{lang_item::LangItemTarget, TraitId};
8 8
9use crate::{db::HirDatabase, DebruijnIndex, Substs}; 9use crate::{db::HirDatabase, DebruijnIndex, Substs};
@@ -152,6 +152,9 @@ fn solve(
152 goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal<Interner>>>, 152 goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal<Interner>>>,
153) -> Option<chalk_solve::Solution<Interner>> { 153) -> Option<chalk_solve::Solution<Interner>> {
154 let context = ChalkContext { db, krate }; 154 let context = ChalkContext { db, krate };
155
156 let logging_db = LoggingRustIrDatabase::new(context);
157
155 log::debug!("solve goal: {:?}", goal); 158 log::debug!("solve goal: {:?}", goal);
156 let mut solver = create_chalk_solver(); 159 let mut solver = create_chalk_solver();
157 160
@@ -167,7 +170,7 @@ fn solve(
167 remaining > 0 170 remaining > 0
168 }; 171 };
169 let mut solve = || { 172 let mut solve = || {
170 let solution = solver.solve_limited(&context, goal, should_continue); 173 let solution = solver.solve_limited(&logging_db, goal, should_continue);
171 log::debug!("solve({:?}) => {:?}", goal, solution); 174 log::debug!("solve({:?}) => {:?}", goal, solution);
172 solution 175 solution
173 }; 176 };
@@ -176,6 +179,8 @@ fn solve(
176 let solution = 179 let solution =
177 if is_chalk_debug() { chalk::tls::set_current_program(db, solve) } else { solve() }; 180 if is_chalk_debug() { chalk::tls::set_current_program(db, solve) } else { solve() };
178 181
182 log::debug!("chalk program:\n{}", logging_db);
183
179 solution 184 solution
180} 185}
181 186
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs
index b33653417..08c2c9a3e 100644
--- a/crates/hir_ty/src/traits/chalk.rs
+++ b/crates/hir_ty/src/traits/chalk.rs
@@ -240,20 +240,22 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
240 Substs::empty().to_chalk(self.db) 240 Substs::empty().to_chalk(self.db)
241 } 241 }
242 242
243 fn trait_name(&self, _trait_id: chalk_ir::TraitId<Interner>) -> String { 243 fn trait_name(&self, trait_id: chalk_ir::TraitId<Interner>) -> String {
244 unimplemented!() 244 let id = from_chalk(self.db, trait_id);
245 self.db.trait_data(id).name.to_string()
245 } 246 }
246 fn adt_name(&self, _struct_id: chalk_ir::AdtId<Interner>) -> String { 247 // FIXME: lookup names
247 unimplemented!() 248 fn adt_name(&self, struct_id: chalk_ir::AdtId<Interner>) -> String {
249 format!("Adt_{:?}", struct_id.0).replace("TypeCtorId(", "").replace(")", "")
248 } 250 }
249 fn assoc_type_name(&self, _assoc_ty_id: chalk_ir::AssocTypeId<Interner>) -> String { 251 fn assoc_type_name(&self, assoc_ty_id: chalk_ir::AssocTypeId<Interner>) -> String {
250 unimplemented!() 252 format!("Assoc_{}", assoc_ty_id.0)
251 } 253 }
252 fn opaque_type_name(&self, _opaque_ty_id: chalk_ir::OpaqueTyId<Interner>) -> String { 254 fn opaque_type_name(&self, opaque_ty_id: chalk_ir::OpaqueTyId<Interner>) -> String {
253 unimplemented!() 255 format!("Opaque_{}", opaque_ty_id.0)
254 } 256 }
255 fn fn_def_name(&self, _fn_def_id: chalk_ir::FnDefId<Interner>) -> String { 257 fn fn_def_name(&self, fn_def_id: chalk_ir::FnDefId<Interner>) -> String {
256 unimplemented!() 258 format!("fn_{}", fn_def_id.0)
257 } 259 }
258} 260}
259 261