diff --git a/Cargo.lock b/Cargo.lock index 975c1aef86..c2779afc2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1013,6 +1013,7 @@ dependencies = [ "chalk-solve", "ena", "insta", + "itertools", "log", "ra_arena", "ra_db", diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 59efc1c31d..c863112c0f 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml @@ -8,6 +8,7 @@ authors = ["rust-analyzer developers"] doctest = false [dependencies] +itertools = "0.9.0" arrayvec = "0.5.1" smallvec = "1.2.0" 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 0a8932dae0..fa8e4d1ad1 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 @@ use std::fmt; use chalk_ir::{AliasTy, Goal, Goals, Lifetime, Parameter, ProgramClauseImplication, TypeName}; +use itertools::Itertools; use super::{from_chalk, Interner}; use crate::{db::HirDatabase, CallableDef, TypeCtor}; @@ -133,14 +134,15 @@ impl DebugContext<'_> { }; let trait_data = self.0.trait_data(trait_); let params = alias.substitution.parameters(&Interner); - write!( - fmt, - "<{:?} as {}<{:?}>>::{}", - ¶ms[0], - trait_data.name, - ¶ms[1..], - type_alias_data.name - ) + write!(fmt, "<{:?} as {}", ¶ms[0], trait_data.name,)?; + if params.len() > 1 { + write!( + fmt, + "<{}>", + ¶ms[1..].iter().format_with(", ", |x, f| f(&format_args!("{:?}", x))), + )?; + } + write!(fmt, ">::{}", type_alias_data.name) } pub fn debug_ty(