aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/traits/chalk.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-09-09 18:20:39 +0100
committerGitHub <[email protected]>2020-09-09 18:20:39 +0100
commit5c336e266fe09ae9ae6e634513d441cbcde63696 (patch)
tree1572fa9047870f4fc092d74ec62231d7a8d6761d /crates/hir_ty/src/traits/chalk.rs
parent60c8941097f3674ed4b583925603b5ec43833f0c (diff)
parentbf0b194fed03d88b1217e921799638cb80bb9df8 (diff)
Merge #5968
5968: Lookup ADT and associated type names for chalk debugging / tweak chalk interner r=flodiebold a=nathanwhit This PR improves the chalk program writing integration by looking up the names for ADTs and associated types, making the output much more readable. There are also a few small changes to the interner, which gives some nice performance improvements. We clone `Ty`s and `ProgramClause`s relatively often in chalk, so wrapping them in `Arc`s is a perf win. This takes the time for performing type inference on the rust-analyzer codebase from 40s to 33s on my machine. Co-authored-by: Nathan Whitaker <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/traits/chalk.rs')
-rw-r--r--crates/hir_ty/src/traits/chalk.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs
index 17c83b6a4..01b5717a3 100644
--- a/crates/hir_ty/src/traits/chalk.rs
+++ b/crates/hir_ty/src/traits/chalk.rs
@@ -244,13 +244,17 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
244 let id = from_chalk(self.db, trait_id); 244 let id = from_chalk(self.db, trait_id);
245 self.db.trait_data(id).name.to_string() 245 self.db.trait_data(id).name.to_string()
246 } 246 }
247 // FIXME: lookup names 247 fn adt_name(&self, adt_id: chalk_ir::AdtId<Interner>) -> String {
248 fn adt_name(&self, struct_id: chalk_ir::AdtId<Interner>) -> String { 248 let id = from_chalk(self.db, adt_id);
249 let datum = self.db.struct_datum(self.krate, struct_id); 249 match id {
250 format!("{:?}", datum.name(&Interner)) 250 hir_def::AdtId::StructId(id) => self.db.struct_data(id).name.to_string(),
251 hir_def::AdtId::EnumId(id) => self.db.enum_data(id).name.to_string(),
252 hir_def::AdtId::UnionId(id) => self.db.union_data(id).name.to_string(),
253 }
251 } 254 }
252 fn assoc_type_name(&self, assoc_ty_id: chalk_ir::AssocTypeId<Interner>) -> String { 255 fn assoc_type_name(&self, assoc_ty_id: chalk_ir::AssocTypeId<Interner>) -> String {
253 format!("Assoc_{}", assoc_ty_id.0) 256 let id = self.db.associated_ty_data(assoc_ty_id).name;
257 self.db.type_alias_data(id).name.to_string()
254 } 258 }
255 fn opaque_type_name(&self, opaque_ty_id: chalk_ir::OpaqueTyId<Interner>) -> String { 259 fn opaque_type_name(&self, opaque_ty_id: chalk_ir::OpaqueTyId<Interner>) -> String {
256 format!("Opaque_{}", opaque_ty_id.0) 260 format!("Opaque_{}", opaque_ty_id.0)