diff options
author | Florian Diebold <[email protected]> | 2020-04-13 13:39:44 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2020-04-13 13:46:03 +0100 |
commit | 2e7b88b5256bd6c51226b63b93481a77ac901e14 (patch) | |
tree | 598e62fba5a307149a4212232c9d5fb5c188b761 | |
parent | 7886513f89795e06eef258e0c54dbd1224c98317 (diff) |
Nicer display of projections in Chalk logs
-rw-r--r-- | Cargo.lock | 1 | ||||
-rw-r--r-- | crates/ra_hir_ty/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk/tls.rs | 18 |
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"] | |||
8 | doctest = false | 8 | doctest = false |
9 | 9 | ||
10 | [dependencies] | 10 | [dependencies] |
11 | itertools = "0.9.0" | ||
11 | arrayvec = "0.5.1" | 12 | arrayvec = "0.5.1" |
12 | smallvec = "1.2.0" | 13 | smallvec = "1.2.0" |
13 | ena = "0.13.1" | 14 | ena = "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 @@ | |||
2 | use std::fmt; | 2 | use std::fmt; |
3 | 3 | ||
4 | use chalk_ir::{AliasTy, Goal, Goals, Lifetime, Parameter, ProgramClauseImplication, TypeName}; | 4 | use chalk_ir::{AliasTy, Goal, Goals, Lifetime, Parameter, ProgramClauseImplication, TypeName}; |
5 | use itertools::Itertools; | ||
5 | 6 | ||
6 | use super::{from_chalk, Interner}; | 7 | use super::{from_chalk, Interner}; |
7 | use crate::{db::HirDatabase, CallableDef, TypeCtor}; | 8 | use 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 {}", ¶ms[0], trait_data.name,)?; |
137 | fmt, | 138 | if params.len() > 1 { |
138 | "<{:?} as {}<{:?}>>::{}", | 139 | write!( |
139 | ¶ms[0], | 140 | fmt, |
140 | trait_data.name, | 141 | "<{}>", |
141 | ¶ms[1..], | 142 | ¶ms[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( |