aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-04-13 13:39:44 +0100
committerFlorian Diebold <[email protected]>2020-04-13 13:46:03 +0100
commit2e7b88b5256bd6c51226b63b93481a77ac901e14 (patch)
tree598e62fba5a307149a4212232c9d5fb5c188b761
parent7886513f89795e06eef258e0c54dbd1224c98317 (diff)
Nicer display of projections in Chalk logs
-rw-r--r--Cargo.lock1
-rw-r--r--crates/ra_hir_ty/Cargo.toml1
-rw-r--r--crates/ra_hir_ty/src/traits/chalk/tls.rs18
3 files changed, 12 insertions, 8 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 975c1aef8..c2779afc2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1013,6 +1013,7 @@ dependencies = [
1013 "chalk-solve", 1013 "chalk-solve",
1014 "ena", 1014 "ena",
1015 "insta", 1015 "insta",
1016 "itertools",
1016 "log", 1017 "log",
1017 "ra_arena", 1018 "ra_arena",
1018 "ra_db", 1019 "ra_db",
diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml
index 59efc1c31..c863112c0 100644
--- a/crates/ra_hir_ty/Cargo.toml
+++ b/crates/ra_hir_ty/Cargo.toml
@@ -8,6 +8,7 @@ authors = ["rust-analyzer developers"]
8doctest = false 8doctest = false
9 9
10[dependencies] 10[dependencies]
11itertools = "0.9.0"
11arrayvec = "0.5.1" 12arrayvec = "0.5.1"
12smallvec = "1.2.0" 13smallvec = "1.2.0"
13ena = "0.13.1" 14ena = "0.13.1"
diff --git a/crates/ra_hir_ty/src/traits/chalk/tls.rs b/crates/ra_hir_ty/src/traits/chalk/tls.rs
index 0a8932dae..fa8e4d1ad 100644
--- a/crates/ra_hir_ty/src/traits/chalk/tls.rs
+++ b/crates/ra_hir_ty/src/traits/chalk/tls.rs
@@ -2,6 +2,7 @@
2use std::fmt; 2use std::fmt;
3 3
4use chalk_ir::{AliasTy, Goal, Goals, Lifetime, Parameter, ProgramClauseImplication, TypeName}; 4use chalk_ir::{AliasTy, Goal, Goals, Lifetime, Parameter, ProgramClauseImplication, TypeName};
5use itertools::Itertools;
5 6
6use super::{from_chalk, Interner}; 7use super::{from_chalk, Interner};
7use crate::{db::HirDatabase, CallableDef, TypeCtor}; 8use crate::{db::HirDatabase, CallableDef, TypeCtor};
@@ -133,14 +134,15 @@ impl DebugContext<'_> {
133 }; 134 };
134 let trait_data = self.0.trait_data(trait_); 135 let trait_data = self.0.trait_data(trait_);
135 let params = alias.substitution.parameters(&Interner); 136 let params = alias.substitution.parameters(&Interner);
136 write!( 137 write!(fmt, "<{:?} as {}", &params[0], trait_data.name,)?;
137 fmt, 138 if params.len() > 1 {
138 "<{:?} as {}<{:?}>>::{}", 139 write!(
139 &params[0], 140 fmt,
140 trait_data.name, 141 "<{}>",
141 &params[1..], 142 &params[1..].iter().format_with(", ", |x, f| f(&format_args!("{:?}", x))),
142 type_alias_data.name 143 )?;
143 ) 144 }
145 write!(fmt, ">::{}", type_alias_data.name)
144 } 146 }
145 147
146 pub fn debug_ty( 148 pub fn debug_ty(